Consider this simple example
> WWWusage %>% as_tibble() %>% head()
# A tibble: 6 x 1
x
<dbl>
1 88
2 84
3 85
4 85
5 84
6 85
I know I can fit a ARIMA
model using the forecast
package. This is easy.
> fit <- auto.arima(WWWusage)
> fit
Series: WWWusage
ARIMA(1,1,1)
Coefficients:
ar1 ma1
0.6504 0.5256
s.e. 0.0842 0.0896
sigma^2 estimated as 9.995: log likelihood=-254.15
AIC=514.3 AICc=514.55 BIC=522.08
The problem is that I would like to predict the one-step ahead forecast in my training sample. That is, how can I have a column prediction
in my original data which contains the predictions from fit
?
Using forecast
will only return the forecasts for obs. 101
to 110
(out-of-sample).
> forecast(fit)
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
101 218.8805 214.8288 222.9322 212.6840 225.0770
102 218.1524 208.4496 227.8552 203.3133 232.9915
I want all the previous (in-sample) forecasts as well (using the same parameters). Like doing broom:augment()
with lm
.
How can I do that here?
Thanks!