0
$\begingroup$

I'm stucked and don't know how to solve that problem using thief package in R (actually tsaggragates + reconcile thief) for SNAIVE METHOD. Does anyone can check it and see what is wrong with it? If it's not wrong, what are the possible outcomes or answers for that?

I have an example of time series using train-test approach. As you can check on code below, I separate than in "b" and "c" series. As exampled on reconcilethief documentation, I made different frequencies for each one using tsaggregates() and after, I calculated for each frequency it's SNAIVE forecast.

As mentioned on the article "Forecasting with Temporal Hierarchy", father of THIEF (Am I wrong?), I want to compare the results from estimators: BU, OLS and WS.

The Problem is: When I compare those results on each frequency, they all look the same ONLY for SNAIVE method. For NAIVE, ETS, ARIMA and THETA it works pretty well and get different results.

Am I doing something wrong? What is the possibles outcomes or answers for that result?

PS: I'm not worried if it fits well that data because it is just an example. It is just a practical way to address my problem/difficulties.

#install.packages("forecast")
#install.packages("thief")

library(forecast); library(thief)

#Data
b <- c(1237,1982,1191,1163,1418,1687,2331,2181,1943,1782,177,1871,391,1397,734,712,1006,508,368,767,675,701,989,725,1292,983,1094,1105,928,1246,1604,1163,1390,959,1630,789,1173,910,875,718,655,606,968,716,476,476,655,499,544,1250,359,386,458,947,542,953,1450,1195,1317,957,778,1030,1399,1119,3142,1024,1537,1321,2062,1897,2094,2546,1796,2089,1194,896,727,599,785,674,828,311,375,315,365,314,126,315,372,666,596,589,001,613,498,635,644,1018,873,900,502,121,293,259,311,169,378,153,24,115,250,565,349,201,393,83,327,325,185,307,501,194)
b <- ts(b, start = 1949, frequency = 12)
c <- window(b, start = 1949, end = c(1954,12), frequency = 12)

#Aggregated time series (total and training session)
aggserie = tsaggregates(b)
aggts = tsaggregates(c)
fcs = list()

# Calculating snaives methods for each frequency
for(i in seq_along(aggts)){
  fcs[[i]] = snaive(aggts[[i]], h= freq*frequency(aggts[[i]]))}

# Results for different variance estimator
rt_bu = reconcilethief(fcs, comb = c("bu")); 
rt_ols = reconcilethief(fcs, comb = c("ols")); 
rt_struc = reconcilethief(fcs, comb = c("struc")); 

#Plot for each frequency comparing each estimator (BU, OLS and WS)
par(mfrow=c(2,3), bg = NA); for(i in seq_along(fcs)){
  plot(aggserie[[i]], main=names(aggserie)[i], ylab = "Qty", xlab = "Time"); 
  lines(fcs[[i]]$mean, col='red', type ="b"); 
  lines(rt_struc[[i]]$mean, col = "blue", type = "l"); 
  lines(rt_bu[[i]]$mean, col = "green", type = "l");
  lines(rt_ols[[i]]$mean, col = "brown", type = "l");
}

The image shows the result for each estimator on each frequency. Result for each frequency comparing BU, OLS and WS estimators

And here are the accuracy measurements for 2-monthly frequency (Just change number 2 for another from 1 to 6 to check other frequencies results):

accuracy(rt_struc[[2]],aggserie[[2]])
accuracy(rt_bu[[2]],aggserie[[2]])
accuracy(rt_ols[[2]],aggserie[[2]])

#> accuracy(rt_struc[[2]],aggserie[[2]])
#                      ME     RMSE      MAE        MPE      MAPE     MASE      ACF1 Theil's U
#Training set    32.86667 1398.514 1151.000  -23.67196  64.23187 1.000000 0.7046529        NA
#Test set     -2018.25000 2577.705 2364.417 -252.60259 261.51293 2.054228 0.1678267   5.97304
#> accuracy(rt_bu[[2]],aggserie[[2]])
#                      ME     RMSE      MAE        MPE      MAPE     MASE      ACF1 Theil's U
#Training set    32.86667 1398.514 1151.000  -23.67196  64.23187 1.000000 0.7046529        NA
#Test set     -2018.25000 2577.705 2364.417 -252.60259 261.51293 2.054228 0.1678267   5.97304
#> accuracy(rt_ols[[2]],aggserie[[2]])
#                      ME     RMSE      MAE        MPE      MAPE     MASE      ACF1 Theil's U
#Training set    32.86667 1398.514 1151.000  -23.67196  64.23187 1.000000 0.7046529        NA
#Test set     -2018.25000 2577.705 2364.417 -252.60259 261.51293 2.054228 0.1678267   5.97304
 
$\endgroup$
1
$\begingroup$

The seasonal naive method uses the most recent year of data as the forecast. So the forecasts are already coherent because the data are coherent. Hence, any reconciliation approach using snaive will give the same results.

$\endgroup$

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.