ellisp / forecastHybrid

Convenient functions for ensemble forecasts in R combining approaches from the {forecast} package
GNU General Public License v3.0
79 stars 23 forks source link

ExtractForecasts #81

Closed Dooruj closed 6 years ago

Dooruj commented 6 years ago

This package is very useful. I was running through some of the examples in the documentation, and I might have spotted a bug (But it could be that I am not running the procedures properly, for which I apologise for taking your time). Here's something I tried to run:

v <- cvts(AirPassengers, FUN = "ets", FCFUN = "forecast", rolling = TRUE, windowSize = 12, horizon = 2)

ExtractForecasts works well in this case.

Then I've tried to simply forecast with a constant mean with rolling window:

cv <- cvts(AirPassengers, FUN = "mean", FCFUN = "forecast", rolling = TRUE, windowSize = 12, horizon = 2)

But when I run "extractForecasts(cv, horizon=2)", I get the following error

Error in .cbind.ts(list(...), .makeNamesTs(...), dframe = dframe, union = TRUE) : not all series have the same frequency

Not sure why this should appear. Thanking you,

dashaub commented 6 years ago

@Dooruj Sorry about the delay getting to this. The "forecast" package has a special function meanf() for producing mean forecasts that you can use in this scenario. This should work:

cv1 <- cvts(AirPassengers, FCFUN = meanf, rolling = TRUE, windowSize = 12, horizon = 2)
extractForecasts(cv1, horizon=2)

This mean forecast example is a special case where a workaround exists, so I'll need to investigate your example to see what is going on here. In general the models/forecasts you make with custom functions need to be very careful to preserve the tsp timeseries attributes, so that is my guess about what is going on.

dashaub commented 6 years ago

The documentation examples have been made somewhat more clear that the tsp need to be correct (specifically the frequency). Look at the updated example for using "GMDH" for a more useful example instead of the naive forecast toy example here.