RainbowStats ยท Time-series commands

VECM_MODEL

Estimate long-run combinations and short-run adjustment, with native statistical checks.

Syntax

EC=VECM_MODEL(levelsList,varLags,rank)

Use levels or logarithms of positive levels. The model constructs first differences internally; do not pass DIFF or LOGDIFF inputs. Lag and rank arguments must be finite positive integers, with rank less than the number of variables.

Complete example

Levels=SERIES_BETWEEN(SAME_DATE_RANGE(LOG(INDPRO),LOG(PAYEMS)),19750101,20191231)
EC=VECM_MODEL(Levels,13,1)
EXTRACT(EC,"slideshow")

The example assumes rank one; it does not prove cointegration. The native slideshow now shows the statistical checks alongside the fitted model. SAME_DATE_RANGE may change frequency and date labels; inspect the resulting series before choosing lag counts.

Lag convention and deterministic terms

varLags is the equivalent levels-VAR order. Order 12 includes 11 lagged differences; order 13 includes 12. Thus VAR_MODEL(LOGDIFF(Levels),12) and VECM_MODEL(Levels,13,rank) match the number of lagged changes, but effective samples still require checking.

An unrestricted intercept enters each change equation. No deterministic trend or restricted long-run constant is estimated. A stationary cointegrating combination can have a nonzero mean: raw ECT zero is not automatically the economic equilibrium.

Native diagnostics

EXTRACT keyResult and interpretation
rank_testJohansen trace and maximum-eigenvalue statistics; constant/no-trend 90%, 95%, 99% critical values and sequential ranks for up to 12 variables. The supplied fitted rank is retained. There are no chi-square rank-test p-values.
unit_rootADF tests of the input levels with a constant and constant plus trend, and first differences with a constant. AIC chooses lagged differences from 0 through an adaptive maximum of 12. MacKinnon p-values and finite-sample critical values are shown.
unit_root:24ADF checks with a requested maximum of 24 lagged differences. An insufficient sample is reported as unavailable rather than fabricating a result.
lag_selectionUnrestricted levels-VAR orders 1 through an adaptive maximum of 24, with intercept and an identical estimation window for every candidate. Reports AIC, BIC, HQIC and FPE. This is not a rank-specific VECM likelihood search.
lag_selection:12Use a requested maximum candidate levels order of 12, subject to common-sample degrees of freedom. This changes the diagnostic search, not the fitted model.
autocorrelationAdjusted multivariate portmanteau test. Default horizon is min(n-1, max(36,varLags+12)); unavailable cases are explained. Null: zero residual autocovariances through that horizon.
autocorrelation:36Request a residual horizon of 36. Require horizon at least the levels order, less than residual observations, and positive test degrees of freedom.
stabilityLevels-VAR companion roots. A k-variable, rank-r VECM normally has k-r roots at +1; these are not automatically instability. Remaining roots must be inside the unit circle. Johansen canonical eigenvalues are a different object.

Diagnostics are computed in Java with the existing Apache Commons Math dependency and cached on the fitted model. No Python runtime or new command registration is needed.

Numeric extracts for scripts and MCP

trace_rank_5pct and maxeig_rank_5pct return sequential 5% test ranks, possibly zero or full rank. aic_lag and bic_lag return the selected levels orders from the default common-sample unrestricted VAR search. whiteness_p returns the default residual test probability; whiteness_p:36 requests horizon 36. largest_transient_root, expected_unit_roots and observed_unit_roots expose stability summaries.

Unavailable scalar results return explanatory strings, not fabricated numbers. Do not automatically reuse a recommended rank without inspecting integration properties, short-run dynamics and the supported model rank range.

Existing extracts

cointegration presents beta and its normalization; adjustment presents matching alpha scales; short_run presents gamma; fitted returns predicted first differences; residuals returns observed minus fitted differences; equilibrium_errors returns raw lagged-level beta combinations. eigenvalues displays the canonical Johansen eigenvalues. diagnostics retains the in-sample fit summary. slideshow combines model explanations, native tests and charts.

When the input is a logarithm, fitted changes are fractional log changes, not automatically multiplied by 100. Rescaling beta requires the inverse rescaling of alpha; a beta coefficient is not automatically a structural elasticity.

What the checks establish

Rank and lag remain explicit assumptions. A recommended rank of zero suggests investigating a differenced VAR; full rank calls for checking stationarity and a levels VAR. The command does not silently fit those alternatives.

Failure to reject a unit root does not prove I(1), and a stationary input can contribute to estimated cointegration rank. These are conventional tests, not structural-break or heteroskedasticity-robust inference. The upgrade does not automatically seasonally adjust, select deterministic terms, test structural breaks or validate future forecast accuracy.

Common-range preparation follows the installed series implementation; remaining date mismatches, nonfinite observations and rank-deficient designs are rejected. Verify regular observation spacing separately.

Available extracts

Save the command result in a variable, then use EXTRACT(result, "key"). Availability can depend on the input form and fitted model.

In indexed patterns such as beta:n, replace n with the required index.