earowang/hts

Predictions are always flat?

Sbrowneo opened this issue · 8 comments

Hello, I'm new to the hts package so I apologize for any stupid questions I may have. For some reason, regardless of which method or fmethod I use, my forecasts always looks similar to this:

image

In this case, the code is:

fcast<-forecast(train. hts,h=101, fmethod='ets', method="tdgsa")

This is the summary of the hts object:

> train.hts

Hierarchical Time Series
4 Levels
Number of nodes at each level: 1 5 10 120
Total number of series: 136
Number of observations per series: 505
Top level series:
Time Series:
Start = 1
End = 505
Frequency = 1

Is there an obvious reason why the forecast is just the same value for each time period?
If more information is required to provide an answer, please let me know
Thanks and have a good day,

S

You have the frequency set to 1 so forecast doesn't know anything about the seasonality. It looks like your seasonality is around 100 periods, in which case frequency should be 100.

Thanks for the quick response! I was trying to set the frequency but I didn't see how. I set it in the ts object before converting to the hts object, but then it reset to 1 and 'frequency' wasn't an argument when setting the hts object. How can I do this? Or do I need to deal with seasonality before hts forecast?

Thanks again!

S

If you set it in the ts object it should be retained. See https://otexts.com/fpp2/hts.html for an example where this is done with seasonal data.

It turns out when I subsetted my ts object into train and test objects it removed the frequency! I'll give it another go. I usually code in python so I'm liable to make stupid mistakes in R. Thanks again!

Use the window() function for subsetting ts and hts objects

Hello again! I'm trying now to combine the fourier function from 9.5 of your textbook to deal with seasonality. It works on a normal ts object, but when I set xreg=fourier(my.hst,K=11) I get this error:

Error in ...fourier(x, K, 1:NROW(x)) : 
  K must be not be greater than period/2

NROW(hts) seems to be 3, and I couldn't find a way to index hts that would allow it to work. Is there a way to do this?

Thanks again!

S

In an unrelated question (I wasn't sure if I should start a new thread), I was curious to know how an hts forecast would handle partially complete time series. For instance, if one base time series has a length of 100, but base time series #2 is only at 90 and I would like to forecast the remaining 10. Of course I could limit all the time series to 90, but I would prefer to use the information from the series for which I have complete data. How would hst handle the missing values in some of the series, and is there a way to forecast those values aside from removing all rows with NAs?

Thank you, I really appreciate the help!

Best
S

I suggest you ask these questions on http://community.rstudio.com. This is not intended to be a help site.