Modelling Lagged Regressors
In the current state of NeuralProphet development, Lagged Regressor support is
only available when the AR-Net is enabled. This is because they are both handled in a similar way internally
using Feed-Forward Neural Networks and need to specify the
n_lags value. For simplicity, at the moment
we use the same
n_lags value for both the AR-Net and the Lagged Regressors. Therefore, with Lagged Regressors,
the NeuralProphet object is instantiated similar with AR-Net like below.
m = NeuralProphet( n_forecasts=3, n_lags=5, yearly_seasonality=False, weekly_seasonality=False, daily_seasonality=False, )
When fitting the model, the dataframe provided to the
fit function should have additional
columns for your lagged regressors like below.
In this example, we have a Lagged Regressor named
A. You also need to register these
Lagged Regressors with the
NeuralProphet object by calling the
and giving the necessary configs.
m = m.add_lagged_regressor(name='A')
By setting the
only_last_value argument of the
add_lagged_regressor function, the user can
specify either to use only the last known value of the regressor within the input window or
else use the same number of lags as auto-regression. Now you can perform the model fitting and forecasting as usual.
The plotted components should look
You can see the components corresponding to both auto-regression and the Lagged Regressor
The coefficients plot looks like below.
It shows both the AR and Lagged Regressor relevance at the 5 lags corresponding to the input window.