For the following series, find an appropriate Box-Cox transformation in order to stabilise the variance.
## [1] 0.5167714
## [1] 0.366352
## [1] 0.1919047
## [1] -0.2269461
Why is a Box-Cox transformation unhelpful for the cangas data?
## [1] 0.5767759
## Jan Feb Mar Apr May Jun
## 1960 1.4306 1.3059 1.4022 1.1699 1.1161 1.0113
## Jan Feb Mar Apr May Jun
## 1960 0.39775735 0.28853071 0.37324769 0.16423852 0.11339450 0.01127312
What Box-Cox transformation would you select for your retail data (from Exercise 3 in Section 2.10)?
retaildata <- readxl::read_excel("retail.xlsx", skip=1)
myts <- ts(retaildata[,"A3349873A"], frequency=12, start=c(1982,4))
autoplot(myts)
## [1] 0.1276369
fc_ret <- rwf(myts, drift = TRUE, lambda = lambda_ret, h = 50, level = 80)
fc_ret_biasadj <- rwf(myts, drift = TRUE, lambda = lambda_ret, h = 50, level = 80, biasadj = TRUE)
## Warning in `/.default`(0.5 * fvar * (1 - lambda), (out)^(2 * lambda)): Recycling array of length 1 in array-vector arithmetic is deprecated.
## Use c() or as.vector() instead.
autoplot(myts) +
autolayer(fc_ret, series = "Simple Back Transformation (Medians)") +
autolayer(fc_ret_biasadj$mean, series = "Bias Adjusted (Means)") +
guides(colour = guide_legend(title = "Forecast"))
For your retail time series (from Exercise 3 in Section 2.10):
Split the data into two parts using
Check that your data have been split appropriately by producing the following plot.
Calculate forecasts using snaive applied to myts.train.
Compare the accuracy of your forecasts against the actual values stored in myts.test.
## ME RMSE MAE MPE MAPE MASE
## Training set 7.772973 20.24576 15.95676 4.702754 8.109777 1.000000
## Test set 55.300000 71.44309 55.78333 14.900996 15.082019 3.495907
## ACF1 Theil's U
## Training set 0.7385090 NA
## Test set 0.5315239 1.297866
Check the residuals.
##
## Ljung-Box test
##
## data: Residuals from Seasonal naive method
## Q* = 624.45, df = 24, p-value < 2.2e-16
##
## Model df: 0. Total lags used: 24
Do the residuals appear to be uncorrelated and normally distributed?