# One step-ahead forecasts in R

I would like to compare one-step ahead forecasts on a given time series for ARIMA and UCM (using KFAS library). I have split my time series in train and validation, that I will use to understand which model performs better.

After reading the anwswer to this post: Difference between first one-step ahead forecast and first forecast from fitted model, I understood the following explanation for Arima:

So fitted(fit) gives one-step forecasts of observations 1, 2, ... It is possible to produce a "forecast" for observation 1 as a forecast is simply the expected value of that observation given the model and any preceding history.

fitted(refit) gives one-step forecasts of observations 401, 402, .... So it uses the model estimated on observations 1...400, but it uses the data from time 401...500.

What I don't understand is how to make one-step forecasts on observations 401, 402, .. using data from time 1.. 400 and (possibly?) the calculated forecasts up to previous time. I want to pretend not to know data 401..500 and compare the one-step forecasts with them.

Thank you for any help on this.
Francesca

(hi, i cant comment so

1. arima (1,0,0) = ar (1) need 1 previous observation ar (2) need 2 previous observations

2. arima do calculate with training data value of coeficients (for ar (1) its like: intercept and ar1

you can calculate coeficients arima(data[1:400] or you can also arima(data[1:472]

(1) so you always need previous (current data) to make 1 step prediction

(2) you can use the same values of coeficients or you can update them as new data are comming

• Thank you for your help. Practically speaking, should I loop 100 times, applying forecast using the previously trained cofficients , h=1, and the train timeseries followed by the already forecasted observations? I tried this: predictions <- c(rep(NA,len_validation)) # last 100 observations temp_ts <- ts_train # first 400 observations for (i in 1:len_validation) { temp_mod<- Arima(temp_ts, model = mod1.5) predictions[i] <- forecast(temp_mod, h = 1)\$mean temp_ts <- ts(c(temp_ts,predictions[i])) } but it seems to return the same as forecast(mod1.5, h=len_validation) Feb 26 at 5:12
• (i didnt work with re-using model..i can onlyguess: if at 1:400 , prediction for h=100 ....for example 500th data point - is 100% exactly same as model trained 1:499 for h=1.....it tells that data are "very deterministic" ... how can i guess weather for 100th day,..with same precision as waited 99 days and guess tomorrow .... but i checked rdocumentation.org/packages/forecast/versions/8.13/topics/Arima and it is possible - i think it points, that data are strong deterministic, cycled....if its for school, i personaly would mention both results and point to good data stability : ) Feb 26 at 11:14