I am enjoying working through the excellent text by Hyndman and Athanasopoulos. I'm not sure if this is a minor typo, or if I am doing something wrong. Page 73 shows how to compute PIs for the goog200 data set and uses a residual SD of 6.21. When I use the naive function R reports the same forecasts and PIs as the table on page 74, but the residual SD is 6.1845, which is slightly different.
I am also checking the formulas on pages 64-5. ME, RMSE and MAE match, but MAPE is off in the second decimal place (0.8551 with formula versus 0.8437 in output).
> fit = naive(goog200)
> summary(fit)
Forecast method: Naive method
Model Information:
Call: naive(y = goog200)
Residual sd: 6.1845
Error measures:
ME RMSE MAE MPE MAPE MASE ACF1
Training set 0.6967249 6.208148 3.740697 0.1426616 0.8437137 1 -0.06038617
Forecasts:
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
201 531.4783 523.5222 539.4343 519.3105 543.6460
202 531.4783 520.2267 542.7298 514.2705 548.6861
203 531.4783 517.6980 545.2586 510.4031 552.5534
204 531.4783 515.5661 547.3904 507.1428 555.8138
205 531.4783 513.6880 549.2686 504.2704 558.6862
206 531.4783 511.9900 550.9666 501.6735 561.2830
207 531.4783 510.4285 552.5280 499.2854 563.6711
208 531.4783 508.9751 553.9814 497.0627 565.8939
209 531.4783 507.6101 555.3465 494.9750 567.9815
210 531.4783 506.3190 556.6375 493.0005 569.9561
> mean(fit$residuals, na.rm=T) # Matches ME
[1] 0.6967249
> sqrt(mean(fit$residuals^2, na.rm=T)) # Matches RMSE
[1] 6.208148
> mean(abs(fit$residuals), na.rm=T) # Matches MAE
[1] 3.740697
> mean(abs(100*fit$residuals/fit$fitted), na.rm=T) # MAPE is different from output
[1] 0.8551149
Also minor, but in elementary stats courses PIs for the mean (i.e., average method) are computed with a t distribution, but section 3.5/table 3.1 suggest using the normal distribution. It seems that meanf also uses the t distribution, e.g.,
> set.seed(12345)
> y = ts(rnorm(20))
> fit = meanf(y, h=5)
> fit
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
21 0.07651681 -1.058066 1.2111 -1.712034 1.865068
22 0.07651681 -1.058066 1.2111 -1.712034 1.865068
23 0.07651681 -1.058066 1.2111 -1.712034 1.865068
24 0.07651681 -1.058066 1.2111 -1.712034 1.865068
25 0.07651681 -1.058066 1.2111 -1.712034 1.865068
> mean(y) + c(-1,1)*qt(.975, 19)*sd(y)*sqrt(1+1/20)
[1] -1.712034 1.865068
Thank you!