ellisp / forecastHybrid

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

individual xreg in forecast.hybridModel #30

Open dashaub opened 8 years ago

dashaub commented 8 years ago

Currently forecast.hybridModel() issues a warning if the xreg was only used for one component model and not the others. This behavior could be kept, but more flexibility would be given by allowing forecast.hybridModel() to accept individual xreg arguments in a.xreg and n.xreg the same way a.args and n.args can be used with hybridModel(). This leads to more verbose function calls, but it is certainly conceivable that a user would want to use different xregs (e.g. fourier terms for seasonality) in different models. Scratchpad code below for demonstrating current xreg usage:

library(forecastHybrid)
dat <- wineind
set.seed(12354)
# Test 1
m <- matrix(rnorm(length(dat)), ncol = 1)
mm <- matrix(rnorm(2 * length(dat)), ncol = 2)
a1 <- auto.arima(dat, xreg = m)
h1 <- hybridModel(dat, a.args = list(xreg = m))
a1
h1$auto.arima
forecast(a1, xreg = m)$mean == forecast(h1, xreg = m)$auto.arima$mean

# Test 2
a2 <- auto.arima(dat, xreg = mm)
h2 <- hybridModel(dat, a.args = list(xreg = data.frame(mm)))
a2
h2$auto.arima
forecast(a2, xreg = mm)$mean == forecast(h2, xreg = mm)$auto.arima$mean
dashaub commented 6 years ago

Changes were made here and previous few commits to address similar problem of xreg used in some models but not others.