0
$\begingroup$

In this post it was asked how to do one step ahead forecasts using Arima form the forecast package. Now I'm using an example with hourly seasonal data and would like to do something similar but the forecast will be 24 hours ahead. When I get new 24 hours of data I will add them up and produce another 24h forecast. Again without re-estimating the model.

I'm not sure whether the following code is right since the fitted values are theoretically only for the next hour but not for the next 24 hours:

library(expsmooth)
data(utility)
n=length(utility)
y=ts(log(utility[1:(n-28*24)]),f=24)
new.data=ts(log(utility[(n-28*24+1):n]))

library(forecast)
model = auto.arima(y)
newfit <- Arima(new.data, model=model)
onestep.for <- fitted(newfit)
$\endgroup$
1
$\begingroup$

As you point out, fitted values are one-step forecasts, whereas you seem to want forecasts from 1 to 24 steps ahead. So you can use

forecast(newfit, h=24)
$\endgroup$
  • $\begingroup$ Many thanks I will use a loop that updates newfit and forecast(newfit, h=24)then $\endgroup$ – nopeva Apr 13 '13 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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