makystats GitHub PyPI FR · EN

ARDL

Autoregressive distributed lag models: bounds test, UECM, restricted ECM, long-run coefficients, CUSUM stability and level forecasts.

README: makystats/ardl/README.md · Formulas: DOCUMENTATION.md

Import

from makystats import ardl, select_ardl_order

Fit and bounds test

res = ardl(y, x=x, lags=2, order=2, case=3).fit()
print(res.summary())
print(res.bounds)            # Pesaran / Narayan F and t
print(res.long_run_table)

# Order selection
tab = select_ardl_order(y, x=x, maxlag=4, maxorder=2, case=3, ic="bic")
# Per-variable maxorder: maxorder={"R": 2, "oil": 1}

Cases (deterministic)

caseMeaning
1No constant, no trend
2Restricted constant
3Unrestricted constant
4Restricted trend
5Unrestricted constant and trend

fixed= regressors may be placed outside the cointegrating relation.

Long run and plots

df_lr = res.long_run_fitted()   # y, fitted_lr (y*), ect
res.plot_long_run()
res.plot_long_run_fitted()

Restricted ECM

Careful removal of coefficients (often insignificant). General-to-specific selection implies pre-test bias. The bounds F remains that of the unrestricted model.

res.restrict_ecm(drop=["D.R.L1"])
res.restrict_ecm(pvalue=0.10, keep_levels=True)  # protects α and x.L1

Forecasts

Conditional on future paths of x (required if the model has exogenous regressors).

exog_f = np.full((10, 1), x.iloc[-1])

fc = res.forecast(steps=10, exog_future=exog_f, conf_int=True)

res.restrict_ecm(drop=["D.R.L1"])
fc_e = res.forecast_ecm(
    steps=10, exog_future=exog_f, restricted=True, level=True, conf_int=True
)
MethodContent of forecast
forecast(...)Levels (ARDL)
forecast_ecm(..., level=True)Levels (default)
forecast_ecm(..., level=False)Differences Δy

Results (after fit)

Attribute / methodContent
params, coef, coefficientsARDL coefficient Series
bse, pvalues, tvaluesInference
coef_tableCoeff / Std.Err / t / Prob.
cov_params()OLS covariance
conf_int(alpha=0.05)Coefficient CIs
aic, bic, hqic, llfICs and log-likelihood
nobs, df_model, df_resid, sigma2Sizes and variance
rsquared, rsquared_adjFit quality
residuals, fitted_valuesIndexed series
long_run, long_run_tableLong-run multipliers

Diagnostics

res.diagnostic_summary(lags_lb=10, nlags_arch=5)
res.test_normality()
res.test_heteroskedasticity(5)
res.test_serial_correlation(10)
res.plot_diagnostics()
res.plot_cusum(alpha=0.05)   # alpha=0.05 or 0.10