Statistics
AuraScore 83/100

High-Dimensional Cointegration and Impulse Response Harness

Build an automated Python pipeline script for Johansen cointegration testing, VECM specification, and bootstrapped impulse response estimation.

Deploy this template when evaluating long-run equilibrium relationships across non-stationary macroeconomic or financial time series. It produces production-ready, object-oriented Python code for statistical validation.

Template

Role: Lead Financial Econometrician and Quantitative Macro-Modeler

Context

  • System Endogenous Variables: {{time_series_variables}}
  • Model Order Selection Rule: {{lag_order_criterion}}
  • Rank Determination Critical Value: {{cointegration_rank_threshold}}
  • Resampling Iterations: {{bootstrap_replications_count}}
  • Dynamics Horizon: {{forecast_horizon_periods}}

Task

Develop an industrial-grade, object-oriented Python script utilizing statsmodels and numpy to ingest multivariate time series, evaluate integration orders, estimate a Vector Error Correction Model (VECM), and output orthogonalized, bootstrapped impulse response functions with empirical confidence bands.

Method

  1. Define an ingest module that validates stationarity using Augmented Dickey-Fuller (ADF) and Phillips-Perron (PP) tests for {{time_series_variables}}.
  2. Implement optimal VAR lag length selection algorithm evaluating up to maximum 12 lags guided by {{lag_order_criterion}}.
  3. Conduct Johansen cointegration tests (Trace and Max-Eigenvalue) at {{cointegration_rank_threshold}} to determine cointegrating rank $r$.
  4. Parameterize and estimate the constrained VECM representation, extracting the adjustment speeds (alpha) and long-run cointegrating vectors (beta).
  5. Compute residuals and verify absence of serial autocorrelation using Breusch-Godfrey Lagrange Multiplier tests.
  6. Construct a wild/residual bootstrap engine with {{bootstrap_replications_count}} resamples to generate non-parametric confidence bands.
  7. Propagate structural shocks across {{forecast_horizon_periods}} to calculate orthogonalized Impulse Response Functions (OIRF).
  8. Implement automated validation logging and visualization plotting module using matplotlib.

Constraints

  • Code MUST be fully runnable Python 3.10+ wrapped in a modular class structure with type hints and docstrings.
  • Data input pipeline MUST NOT fail on missing timestamps, implementing strict forward-fill or interpolation guards.
  • All bootstrap loops MUST be vectorized or accelerated using multiprocessing to avoid single-thread bottlenecks.
  • MUST validate that cointegration rank $r > 0$ before proceeding to VECM; otherwise, fallback to difference-stationary VAR.

Output format

Deliver the analysis pipeline structured in the following sections:

  1. Theoretical Specification: A 150-word mathematical summary outlining the error-correction formulation and identification strategy.
  2. Complete Python Script: Well-commented, modular code containing TimeSeriesPreprocessor, VECMEngine, and BootstrapIRF classes with a runnable __main__ demonstration block.
  3. Metric Interpretation Key: A markdown guide explaining how to interpret alpha speed vectors and persistent versus transitory IRF trajectories.

Self-review

  • Ensure the cointegration test accommodates both deterministic trend and intercept options correctly.
  • Verify that the bootstrap engine respects temporal dependence without data leakage.
  • Confirm that impulse response confidence bands are computed accurately at 95% and 68% coverage levels based on {{bootstrap_replications_count}}.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

data-analytics
data-statistics
complex-reasoning-analysis-math
statistics
econometrics
time-series