I work for an auditing firm and perform time series analysis with reference to the online training("Forecasting Using R" at DataCamp) and the books.
In order to deepen my understanding, I have recalculated various methods myself, but I cannot reproduce the prediction interval of the holt-winters' multiplicative function.
(Although, I can do that of the holt-winters' additive function.)
Perhaps my formula is wrong, but it would be helpful if someone could teach me the correct formula.
Packages
library(fpp2)
Create a data
mydata <- c(10,30,20,40,20,50,40,60,50,70,60,90)
Create a ts object called myts
myts <- ts(mydata, start = c(2019, 1), frequency = 4)
Holt-Winters' additive
fc_hwa <- hw(myts, seasonal = "additive", h = 4)
autoplot(fc_hwa) # Create an autoplot
sd_resid <- sqrt(fc_hwa$model$sigma2) # SD of Residuals
pf <- fc_hwa$mean[1] # Value of Point forecast
(ans1 <- pf + sd_resid * qnorm(0.975)) # Culculate the upper of 95% prediction interval
(ans2 <- as.numeric(fc_hwa$upper[1, 2])) # The upper of 95% prediction interval of the model
identical(ans1, ans2) # Identical
Holt-Winters' multiplicative
fc_hwm <- hw(myts, seasonal = "multiplicative", h = 4)
autoplot(fc_hwm)
sd_resid <- sqrt(fc_hwm$model$sigma2)
pf <- fc_hwm$mean[1]
(ans1 <- pf + sd_resid * qnorm(0.975)) # Too low!
(ans2 <- as.numeric(fc_hwm$upper[1, 2]))
identical(ans1, ans2) # Not identical!