I am trying to generate simulations from a seasonal arima model using the forecast package in R via the following command:
simulate(model_temp)
where model_temp
is the result of applying the arima()
function to my observed time series, and with which, incidentally, I specified the model to be an ARIMA(2,1,2)(0,1,2)[12] model.
However, when I attempt this, I get the following error:
Error in diffinv.vector(x, lag, differences, xi) :
NA/NaN/Inf in foreign function call (arg 1)
Can anybody please explain why this is the case (and how to avoid this problem)?
I should further add, that I know that the model that I applied and resulting in the fit of model_temp
is not the model that generated the series, but nevertheless, I would still like to generate simulations from that model (or any other model for that matter).
Lastly, is it possible to generate simulations from a seasonal ARIMA model by just specifying the ar, d, ma, sar, sd, sma and sigma parameters and without having first created an object of the correct ARIMA type?
Thank you for any help,
Jonathan
This happens when you have missing values, as in the following example.
library(forecast)
x <- WWWusage
x[10] <- NA
fit <- Arima(x,c(3,1,0), seasonal=list(order=c(0,1,1),period=12))
simulate(fit) # Fails
The default arguments simulate future values conditional
on the data, and fails if some values are missing.
If you want an unrelated sample, you can add future=FALSE
.
simulate(fit, future=FALSE) # Does not fail
To simulate from an arbitrary model, you can try to
build a minimal Arima
object,
with only the data needed.
m <- list(
arma=c(3,0,0,1,12,1,1),
model=list(
phi=c(1.17, -0.71, 0.39),
theta=c(0,0,0,0,0,0,0,0,0,0,0,-.79)
),
sigma2=11,
x=NA
)
simulate.Arima(m, nsim=30, future=FALSE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With