ARDL
ARDL
- class ARDL(lags=None, order=None, fixed=None, causal=False, trend='c', seasonal=False, deterministic=None, hold_back=None, period=None, missing='none', cov_type='nonrobust', cov_kwds=None, use_t=True, auto_ardl=False, maxlag=None, maxorder=None, ic='bic', glob=False, fixed_oos=None, X_oos=None, dynamic=False)[source]
Autoregressive Distributed Lag (ARDL) Model.
Direct interface for
statsmodels.tsa.ardl.ARDL- Parameters:
- lags{int, list[int]}, optional
Only considered if auto_ardl is False 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}, optional
Only considered if auto_ardl is False If int, uses lags 0, 1, …, order for all exog variables. If sequence[int], uses the
orderfor all variables. If a dict, applies the lags series by series. Ifexogis 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, optional
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’, ‘ctt’}, optional
The trend to include in the model:
‘n’ - No trend.
‘c’ - Constant only.
‘t’ - Time trend only.
‘ct’ - Constant and time trend.
- ‘ctt’ - Constant plus linear plus quadratic time trends.
N.B. The choice of ‘ctt’ requires statsmodels >= 0.15.0.
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’.
- cov_typestr, optional
The covariance estimator to use. The most common choices are listed below. Supports all covariance estimators that are available in
OLS.fit.‘nonrobust’ - The class OLS covariance estimator that assumes homoskedasticity.
‘HC0’, ‘HC1’, ‘HC2’, ‘HC3’ - Variants of White’s (or Eiker-Huber-White) covariance estimator.
HC0is the standard implementation. The other make corrections to improve the finite sample performance of the heteroskedasticity robust covariance estimator.‘HAC’ - Heteroskedasticity-autocorrelation robust covariance estimation. Supports cov_kwds.
maxlagsinteger (required) : number of lags to use.kernelcallable or str (optional)kernelcurrently available kernels are [‘bartlett’, ‘uniform’], default is Bartlett.
use_correctionbool (optional)If true, use small samplecorrection.
- cov_kwdsdict, optional
A dictionary of keyword arguments to pass to the covariance estimator.
nonrobustandHC#do not support cov_kwds.- use_tbool, optional
A flag indicating that inference should use the Student’s t distribution that accounts for model degree of freedom. If False, uses the normal distribution. If None, defers the choice to the cov_type. It also removes degree of freedom corrections from the covariance estimator when cov_type is ‘nonrobust’.
- auto_ardlbool, optional
A flag indicating whether the number of lags should be determined automatically.
- maxlagint, optional
Only considered if auto_ardl is True. The maximum lag to consider for the endogenous variable.
- maxorder{int, dict}
Only considered if auto_ardl is True. If int, sets a common max lag length for all exog variables. If a dict, then sets individual lag length. They keys are column names if exog is a DataFrame or column indices otherwise.
- ic{“aic”, “bic”, “hqic”}, optional
Only considered if auto_ardl is True. The information criterion to use in model selection.
- globbool, optional
Only considered if auto_ardl is True. Whether to consider all possible submodels of the largest model or only if smaller order lags must be included if larger order lags are. If
True, the number of model considered is of the order 2**(maxlag + k * maxorder) assuming maxorder is an int. This can be very large unless k and maxorder are both relatively small. If False, the number of model considered is of the order maxlag*maxorder**k which may also be substantial when k and maxorder are large.- fixed_oosarray_like, optional
An array containing out-of-sample values of the fixed variables. Must have the same number of columns as the fixed array and at least as many rows as the number of out-of-sample forecasts.
- X_oosarray_like, optional
An array containing out-of-sample values of the exogenous variables. Must have the same number of columns as the X and at least as many rows as the number of out-of-sample forecasts.
- dynamic{bool, int, str, datetime, Timestamp}, optional
Integer offset relative to
startat which to begin dynamic prediction. Prior to this observation, true endogenous values will be used for prediction; starting with this observation and continuing through the end of prediction, forecasted endogenous values will be used instead. Datetime-like objects are not interpreted as offsets. They are instead used to find the index location ofdynamicwhich is then used to compute the offset.
- Attributes:
cutoffCut-off = “present time” state of forecaster.
fhForecasting horizon that was passed.
is_fittedWhether
fithas been called.stateState of the estimator.
See also
statsmodels.tsa.ar_model.AutoRegAutoregressive model estimation with optional exogenous regressors
statsmodels.tsa.ardl.UECMUnconstrained Error Correction Model estimation
statsmodels.tsa.statespace.sarimax.SARIMAXSeasonal ARIMA model estimation with optional exogenous regressors
statsmodels.tsa.arima.model.ARIMAARIMA 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
rincluded fixed regressors and \(epsilon_t\) is a white noise shock. IfcausalisTrue, then the 0-th lag of the exogenous variables is not included and the sum starts atm=1.Examples
Use ARDL on macroeconomic data >>> from sktime.datasets import load_macroeconomic >>> from sktime.forecasting.ardl import ARDL >>> from sktime.forecasting.base import ForecastingHorizon >>> data = load_macroeconomic() >>> oos = data.iloc[-5:, :] >>> data = data.iloc[:-5, :] >>> y = data.realgdp >>> X = data[[“realcons”, “realinv”]] >>> X_oos = oos[[“realcons”, “realinv”]] >>> ardl = ARDL(lags=2, order={“realcons”: 1, “realinv”: 2}, trend=”c”) >>> ardl.fit(y=y, X=X) ARDL(lags=2, order={‘realcons’: 1, ‘realinv’: 2}) >>> fh = ForecastingHorizon([1, 2, 3]) >>> y_pred = ardl.predict(fh=fh, X=X_oos)
Methods
check_is_fitted([method_name])Check if the estimator has been fitted.
check_param_validity(X)Check for the validity of entered parameter combination.
clone()Obtain a clone of the object with same hyper-parameters and config.
clone_tags(estimator[, tag_names])Clone tags from another object as dynamic override.
create_test_instance([parameter_set])Construct an instance of the class, using first test parameter set.
create_test_instances_and_names([parameter_set])Create list of all test instances and a list of names for them.
fit(y[, X, fh])Fit forecaster to training data.
fit_predict(y[, X, fh, X_pred])Fit and forecast time series at future horizon.
get_class_tag(tag_name[, tag_value_default])Get class tag value from class, with tag level inheritance from parents.
get_class_tags()Get class tags from class, with tag level inheritance from parent classes.
get_config()Get config flags for self.
get_fitted_params([deep])Get fitted parameters.
get_param_defaults()Get object's parameter defaults.
get_param_names([sort])Get object's parameter names.
get_params([deep])Get a dict of parameters values for this object.
get_pretrained_params([deep])Get pretrained parameters of this estimator.
get_tag(tag_name[, tag_value_default, ...])Get tag value from instance, with tag level inheritance and overrides.
get_tags()Get tags from instance, with tag level inheritance and overrides.
get_test_params([parameter_set])Return testing parameter settings for the estimator.
is_composite()Check if the object is composed of other BaseObjects.
load_from_path(serial)Load object from file location.
load_from_serial(serial)Load object from serialized memory container.
predict([fh, X])Forecast time series at future horizon.
predict_interval([fh, X, coverage])Compute/return prediction interval forecasts.
predict_proba([fh, X, marginal])Compute/return fully probabilistic forecasts.
predict_quantiles([fh, X, alpha])Compute/return quantile forecasts.
predict_residuals([y, X])Return residuals of time series forecasts.
predict_var([fh, X, cov])Compute/return variance forecasts.
pretrain(y[, X, fh])Pre-train forecaster on panel (global) data.
reset()Reset the object to a clean post-init state.
save([path, serialization_format])Save serialized self to bytes-like object or to (.zip) file.
score(y[, X, fh])Scores forecast against ground truth, using MAPE (non-symmetric).
set_config(**config_dict)Set config flags to given values.
set_params(**params)Set the parameters of this object.
set_random_state([random_state, deep, ...])Set random_state pseudo-random seed parameters for self.
set_tags(**tag_dict)Set instance level tag overrides to given values.
summary()Get a summary of the fitted forecaster.
update(y[, X, update_params])Update cutoff value and, optionally, fitted parameters.
update_predict(y[, cv, X, update_params, ...])Make predictions and update model iteratively over the test set.
update_predict_single([y, fh, X, update_params])Update model with new data and make forecasts.

