2
$\begingroup$

Could somebody explain to me the theory behind how R calculates the 95% prediction intervals for my 12 step ahead forecasts in (1) a seasonal naive model and (2) a Holt-Winters forecast.

My code is as follows:

library(forecast)
frcA <- snaive(ts.tr, h=12, level=c(95)) 
frcA

Output:

         Point Forecast    Lo 95    Hi 95
Jul 2014         6480.5 6029.462 6931.538
Aug 2014         6675.2 6224.162 7126.238
Sep 2014         6604.1 6153.062 7055.138
Oct 2014         7026.9 6575.862 7477.938
Nov 2014         7391.1 6940.062 7842.138
Dec 2014         9185.3 8734.262 9636.338
Jan 2015         7232.0 6780.962 7683.038
Feb 2015         6348.3 5897.262 6799.338
Mar 2015         7037.1 6586.062 7488.138
Apr 2015         6905.5 6454.462 7356.538
May 2015         7067.9 6616.862 7518.938
Jun 2015         6920.2 6469.162 7371.238

frcC <- hw(ts.tr, seasonal="multiplicative", h=12, level=c(95)) 
frcC

         Point Forecast    Lo 95     Hi 95
Jul 2014       7062.795 6716.461  7409.129
Aug 2014       7129.991 6744.176  7515.805
Sep 2014       7103.689 6686.079  7521.299
Oct 2014       7449.304 6978.850  7919.758
Nov 2014       7777.210 7254.032  8300.387
Dec 2014       9713.066 9021.682 10404.451
Jan 2015       7423.212 6867.086  7979.338
Feb 2015       6563.966 6048.667  7079.266
Mar 2015       7214.877 6623.531  7806.222
Apr 2015       7055.886 6453.977  7657.795
May 2015       7249.189 6607.280  7891.099
Jun 2015       7142.304 6487.339  7797.269

The process I've been trying to follow is on https://www.otexts.org/fpp/2/7, but after obtaining the standard deviation of the residuals, the equation just doesn't check out with what R gives. (139.8464 for Model A, 0.02 for Model B.)

$\endgroup$
  • $\begingroup$ A minimal reproducible example (e.g., using a built-in dataset, like AirPassengers) would help us. That said, there are frequently small differences between implementations of forecasting algorithms that make it hard to exactly reproduce something. Have you looked at the source code (type snaive and hw) and traced that? In addition, it would be good if you could indicate more precisely where the FPP approach and R diverges: is it already in parameter estimates & point forecasts, or only in sigma & PIs (what's "139"?)? $\endgroup$ – Stephan Kolassa Sep 10 '15 at 6:32

Your Answer

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

Browse other questions tagged or ask your own question.