Roji
Roji

Reputation: 113

hts package in R

I want to use optimal comination method of hts package in r to get hierarchical forecasts with single exponential smoothing (SES) forecasting method, I read in the manual that avaialble forecast methods are ets, arima and rw. I'm wondering if it is possible to use other forecast methods like SES? I tried to use the following code but I get an error.

library(forecast)    
library(hts)

mydata <- matrix(rnorm(103*2, mean = 200, sd = 20), nrow = 103, ncol = 2)

data <- hts(mydata)
tdata=window(data,1,70)# training data
test=window(data,71,103)# test data
alldata <- aggts(tdata)

allf <- matrix(NA, nrow = 33, ncol = ncol(alldata))#all forecast 

for(i in 1:ncol(alldata))
  allf[,i] <- ses((alldata[,i]), h = 33)$mean# generate forecasts usign SES

tdata.f <- combinef(allf, data$nodes, weights = NULL, keep = "gts")

Upvotes: 0

Views: 398

Answers (1)

Stephan Kolassa
Stephan Kolassa

Reputation: 8267

?ets tells you how to specify a model with additive error, no trend and no seasonality, which is SES in state space form. Adding the parameter model="ANN" should work. This will be passed on to ets().

Upvotes: 1

Related Questions