In R after calibrating in sample the coefficient for an ARMA model, how can I generate the error which would result of using the same coefficients on another set, out-of-sample, of data ?
Let's say that insamp contains my in sample series, I calibrate an ARMA(5,2) by typing:
det_fit = arima(insamp , c(5,0,2));
Now I want to compute the error on the outsamp series (I divided arbitrarily the series in two halves insamp and outsamp).
If the model was an AR(5), this is what I did:
detrended_outsamp_forecast_ts = det_fit$coef["intercept"] +
det_fit$coef["ar1"] * c(rep(NA,1), outsamp) +
det_fit$coef["ar2"] * c(rep(NA,2), outsamp) +
det_fit$coef["ar3"] * c(rep(NA,3), outsamp) +
det_fit$coef["ar4"] * c(rep(NA,4), outsamp) +
det_fit$coef["ar5"] * c(rep(NA,5), outsamp);
Which is very long and not generic.
Is there anybody who wrote a function to apply the ARMA coefficients on an arbitrary time-series ?