VECM#

class cultivars.multivariate.reduced_form.error_correction.VECM(endog, *, order, rank, cointegration_trend='constant', exog=None, contemporaneous=True, names=None, exog_names=None)[source]#

Vector error-correction model, estimated by Johansen’s reduced-rank ML.

The closed specification: every variable in the panel gets an equation, the rank is fixed by the caller, and the Johansen case names where a constant or trend sits relative to the cointegrating space. order counts lags of the levels system, so order=p carries p - 1 lagged differences and the inherited lag_order_selection chooses it the standard way, on the unrestricted levels VAR. The rank is a property of the data, not of this object, so rank_test() – the trace and maximum-eigenvalue sequence with simulated critical values – can be read from a model built at any rank before committing to one.

Variables:
  • _endog – The validated (nobs, k) panel of levels.

  • _names – Variable labels.

  • _order – Lags of the levels system.

  • _trend – The unrestricted deterministic terms the short-run regression sees, mapped from the Johansen case.

  • _prior – The base slot for a shrinkage prior, unused by this family.

  • _rank – The cointegrating rank.

  • _trend_case (str) – The Johansen case as given.

  • _exog – The exogenous block, (nobs, 0) for this closed model.

  • _exog_names – Exogenous labels, empty here.

  • _contemporaneous – Whether a current exogenous difference would enter; irrelevant without a block.

See also

  • VECMResult – the record fit() returns.

  • VECMX – the conditional model with weakly exogenous integrated regressors.

  • VAR – the levels system this reparameterizes; fit it when the rank test selects k.

References

Johansen, S. (1991). Estimation and hypothesis testing of cointegration vectors in Gaussian vector autoregressive models. Econometrica, 59(6), 1551-1580.

Johansen, S. (1995). Likelihood-Based Inference in Cointegrated Vector Autoregressive Models. Oxford University Press.

Example

Choose the rank from the data, then fit at it:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> common = np.cumsum(rng.standard_normal(300))
>>> y = np.column_stack([common, 2 * common + rng.standard_normal(300)])
>>> model = VECM(y, order=2, rank=1)
>>> model.rank_test(simulations=2000).selected_rank()
1
>>> res = model.fit()
>>> res.n_common_trends, res.normalized_beta().ravel().round(2)
(1, array([ 1.  , -0.49]))

Attributes#

cointegration_trend

The Johansen case.

contemporaneous

Whether the current exogenous difference enters the short-run equation.

endog

The validated sample.

exog

The weakly exogenous block, zero-width for a closed system.

exog_names

Exogenous labels.

is_shrunk

Whether a prior contributes anything to this estimate.

k_cointegrating

every integrated variable plus any restricted term.

k_endog

Number of endogenous variables.

k_exog

Weakly exogenous integrated regressors.

n_regressors

Short-run regressors per equation.

names

Variable labels.

order

Autoregressive order.

prior

The prior on the coefficients; NoPrior when unrestricted.

rank

Cointegrating rank.

trend

Deterministic specification.

Methods#

fit()

Estimate the system at the specified rank and return the result.

lag_order_selection([max_lags])

Score every order from zero to max_lags on one common sample.

rank_test(*[, small_sample, simulations, ...])

Trace and maximum-eigenvalue tests for every candidate rank.