robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.1k stars 340 forks source link

multivariate nnetar #263

Open gabrielcaceres opened 8 years ago

gabrielcaceres commented 8 years ago

Would you be interested in having nnetar being able to jointly fit/forecast multiple time series? (essentially turning it into "nnetVar" to do vector autoregression)

nnet can already handle multiple outputs, so that should be quite straightforward. The only tricky part might be making sure none of the internals of nnetar break when a matrix instead of a vector is being used to create lags, forecast, etc.

robjhyndman commented 8 years ago

Yes. This would be a useful addition. I imagine you would want all of the inputs used in each of the univariate models to be available to each output in the multivariate case. We now have some facilities for multivariate forecasting with the mforecast class, so forecast.nnetar() should return something of class "mforecast" if there is more than one series. Existing functions that return that class are forecast.mlm and forecast.varest

gabrielcaceres commented 8 years ago

I'm not sure I completely follow what you mean regarding the inputs... but if I understand correctly, it should automatically be taken care of since all the inputs and outputs are actually connected in a single network.

There are aspects a multivariate neural network model that are more intrinsically tied together than in regular multivariate regression. The extra output neuron has its own independent parameters (as in multivariate regression), but the coefficients of hidden-layer neurons are shared and jointly estimated for both outputs. In a way, the the hidden-layer parameters are estimated on the pooled data (using all of the available inputs), while the output neurons independently model each series (using the hidden-layer outputs).

robjhyndman commented 8 years ago

OK. Thanks for the explanation. I haven't fitted multiple output ANNs before so I wasn't sure how the input/output relationships worked.