statsmodels.tsa.ardl.ARDL¶
- class statsmodels.tsa.ardl.ARDL(endog, lags, exog=None, order=0, trend='c', *, fixed=None, causal=False, seasonal=False, deterministic=None, hold_back=None, period=None, missing='none')[source]¶
Autoregressive Distributed Lag (ARDL) Model
- Parameters:
- endogarray_like
A 1-d endogenous response variable. The dependent variable.
- lags{
int
,list
[int
]} The number of lags to include in the model if an integer or the list of lag indices to include. For example, [1, 4] will only include lags 1 and 4 while lags=4 will include lags 1, 2, 3, and 4.
- exogarray_like
Exogenous variables to include in the model. Either a DataFrame or an 2-d array-like structure that can be converted to a NumPy array.
- order{
int
, sequence[int
],dict
} If int, uses lags 0, 1, …, order for all exog variables. If sequence[int], uses the
order
for all variables. If a dict, applies the lags series by series. Ifexog
is anything other than a DataFrame, the keys are the column index of exog (e.g., 0, 1, …). If a DataFrame, keys are column names.- fixedarray_like
Additional fixed regressors that are not lagged.
- causalbool,
optional
Whether to include lag 0 of exog variables. If True, only includes lags 1, 2, …
- trend{‘n’, ‘c’, ‘t’, ‘ct’},
optional
The trend to include in the model:
‘n’ - No trend.
‘c’ - Constant only.
‘t’ - Time trend only.
‘ct’ - Constant and time trend.
The default is ‘c’.
- seasonalbool,
optional
Flag indicating whether to include seasonal dummies in the model. If seasonal is True and trend includes ‘c’, then the first period is excluded from the seasonal terms.
- deterministic
DeterministicProcess
,optional
A deterministic process. If provided, trend and seasonal are ignored. A warning is raised if trend is not “n” and seasonal is not False.
- hold_back{
None
,int
},optional
Initial observations to exclude from the estimation sample. If None, then hold_back is equal to the maximum lag in the model. Set to a non-zero value to produce comparable models with different lag length. For example, to compare the fit of a model with lags=3 and lags=1, set hold_back=3 which ensures that both models are estimated using observations 3,…,nobs. hold_back must be >= the maximum lag in the model.
- period{
None
,int
},optional
The period of the data. Only used if seasonal is True. This parameter can be omitted if using a pandas object for endog that contains a recognized frequency.
- missing{“none”, “drop”, “raise”},
optional
Available options are ‘none’, ‘drop’, and ‘raise’. If ‘none’, no NaN checking is done. If ‘drop’, any observations with NaNs are dropped. If ‘raise’, an error is raised. Default is ‘none’.
See also
statsmodels.tsa.ar_model.AutoReg
Autoregressive model estimation with optional exogenous regressors
statsmodels.tsa.ardl.UECM
Unconstrained Error Correction Model estimation
statsmodels.tsa.statespace.sarimax.SARIMAX
Seasonal ARIMA model estimation with optional exogenous regressors
statsmodels.tsa.arima.model.ARIMA
ARIMA model estimation
Notes
The full specification of an ARDL is
\[Y_t = \delta_0 + \delta_1 t + \delta_2 t^2 + \sum_{i=1}^{s-1} \gamma_i I_{[(\mod(t,s) + 1) = i]} + \sum_{j=1}^p \phi_j Y_{t-j} + \sum_{l=1}^k \sum_{m=0}^{o_l} \beta_{l,m} X_{l, t-m} + Z_t \lambda + \epsilon_t\]where \(\delta_\bullet\) capture trends, \(\gamma_\bullet\) capture seasonal shifts, s is the period of the seasonality, p is the lag length of the endogenous variable, k is the number of exogenous variables \(X_{l}\), \(o_l\) is included the lag length of \(X_{l}\), \(Z_t\) are
r
included fixed regressors and \(\epsilon_t\) is a white noise shock. Ifcausal
isTrue
, then the 0-th lag of the exogenous variables is not included and the sum starts atm=1
.Examples
>>> from statsmodels.tsa.api import ARDL >>> from statsmodels.datasets import danish_data >>> data = danish_data.load_pandas().data >>> lrm = data.lrm >>> exog = data[["lry", "ibo", "ide"]]
A basic model where all variables have 3 lags included
>>> ARDL(data.lrm, 3, data[["lry", "ibo", "ide"]], 3)
A dictionary can be used to pass custom lag orders
>>> ARDL(data.lrm, [1, 3], exog, {"lry": 1, "ibo": 3, "ide": 2})
Setting causal removes the 0-th lag from the exogenous variables
>>> exog_lags = {"lry": 1, "ibo": 3, "ide": 2} >>> ARDL(data.lrm, [1, 3], exog, exog_lags, causal=True)
A dictionary can also be used to pass specific lags to include. Sequences hold the specific lags to include, while integers are expanded to include [0, 1, …, lag]. If causal is False, then the 0-th lag is excluded.
>>> ARDL(lrm, [1, 3], exog, {"lry": [0, 1], "ibo": [0, 1, 3], "ide": 2})
When using NumPy arrays, the dictionary keys are the column index.
>>> import numpy as np >>> lrma = np.asarray(lrm) >>> exoga = np.asarray(exog) >>> ARDL(lrma, 3, exoga, {0: [0, 1], 1: [0, 1, 3], 2: 2})
- Attributes:
ar_lags
The autoregressive lags included in the model
ardl_order
The order of the ARDL(p,q)
causal
Flag indicating that the ARDL is causal
deterministic
The deterministic used to construct the model
df_model
The model degrees of freedom.
dl_lags
The lags of exogenous variables included in the model
endog_names
Names of endogenous variables.
exog_names
Names of exogenous variables included in model
fixed
The fixed data used to construct the model
hold_back
The number of initial obs.
period
The period of the seasonal component.
seasonal
Flag indicating that the model contains a seasonal component.
trend
The trend used in the model.
Methods
fit
(*[, cov_type, cov_kwds, use_t])Estimate the model parameters.
from_formula
(formula, data[, lags, order, ...])Construct an ARDL from a formula
hessian
(params)The Hessian matrix of the model.
information
(params)Fisher information matrix of model.
Initialize the model (no-op).
loglike
(params)Log-likelihood of model.
predict
(params[, start, end, dynamic, exog, ...])In-sample prediction and out-of-sample forecasting.
score
(params)Score vector of model.
Properties
The autoregressive lags included in the model
The order of the ARDL(p,q)
Flag indicating that the ARDL is causal
The deterministic used to construct the model
The model degrees of freedom.
The lags of exogenous variables included in the model
Names of endogenous variables.
Names of exogenous variables included in model
The fixed data used to construct the model
The number of initial obs.
The period of the seasonal component.
Flag indicating that the model contains a seasonal component.
The trend used in the model.