statsmodels.tsa.ardl.ARDL.from_formula

classmethod ARDL.from_formula(formula, data, lags=0, order=0, trend='n', *, causal=False, seasonal=False, deterministic=None, hold_back=None, period=None, missing='none')[source]

Construct an ARDL from a formula

Parameters:
formulastr

Formula with form dependent ~ independent | fixed. See Examples below.

dataDataFrame

DataFrame containing the variables in the formula.

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.

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. If exog 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.

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.

deterministicDeterministicProcess, 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’.

Returns:
ARDL

The ARDL model instance

Examples

A simple ARDL using the Danish data

>>> from statsmodels.datasets.danish_data import load
>>> from statsmodels.tsa.api import ARDL
>>> data = load().data
>>> mod = ARDL.from_formula("lrm ~ ibo", data, 2, 2)

Fixed regressors can be specified using a |

>>> mod = ARDL.from_formula("lrm ~ ibo | ide", data, 2, 2)

Last update: Dec 16, 2024