0
$\begingroup$

I am using a regression model that produces non-normal forecast errors. To produce different scenarios, I need to simulate the model error, I can bootstrap from historical errors, however, because the number of simulations I need might be more than then historical errors, I wonder if there is a way to get the empirical distribution and bootstrap from that to get more variety in sampled errors (for example getting the interpolation between different historical errors.)

Here is an example of nonparametric error distribution.

x1 = runif(min = 1, max = 40, n = 100)
x2 = runif(min = -45, max = 0, n= 370)
error <- c(x1, x2)

BootstrapError <- sample(x = error, size = 500, replace  = T)

I appreciate sharing your ideas.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

One approach is to simulate from a kernel density estimate applied to the errors. This is equivalent to a "smoothed bootstrap" and is very easily implemented by simply adding some Gaussian noise to the errors, where the standard deviation of the noise is equal to the bandwidth from the kde.

# Simulate some historical errors
set.seed(666)
x1 = runif(min = 1, max = 40, n = 100)
x2 = runif(min = -45, max = 0, n= 370)
error <- c(x1, x2)

# Compute kernel density estimate
kde <- density(error, bw="SJ")

# Generated smoothed bootstrap sample
BootstrapError <- sample(x = error, size = 500, replace  = TRUE) +
  rnorm(500,0,kde$bw)

# Plot the results
par(mfrow=c(1,2))
hist(error, probability = TRUE, 
     xlim=range(error,BootstrapError), ylim=c(0,0.021))
lines(kde)
hist(BootstrapError, probability = TRUE,
     xlim=range(error,BootstrapError), ylim=c(0,0.021))
lines(kde)

Created on 2020-05-16 by the reprex package (v0.3.0)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.