Skip to main content

Quantile Cointegrating Regression - Implementation based on Xiao (2009) Journal of Econometrics

Project description

Quantilecoint

Python 3.8+ License: MIT

Quantile Cointegrating Regression - A Python implementation based on Xiao (2009) "Quantile cointegrating regression", Journal of Econometrics, 150, 248-260.

Author

Dr Merwan Roudane
Email: merwanroudane920@gmail.com
GitHub: https://github.com/merwanroudane/quantilecoint

Overview

This package implements quantile regression methods for cointegrated time series, including:

  • Quantile Cointegrating Regression: Estimate cointegrating relationships at different quantiles
  • Fully-Modified Quantile Regression: Bias-corrected estimator for endogenous regressors
  • Augmented Quantile Cointegrating Regression: Uses leads and lags to handle endogeneity
  • Wald Test: Test linear restrictions on cointegrating coefficients
  • Stability Test: Bootstrap-based test for constant vs. time-varying coefficients
  • CUSUM Cointegration Test: Robust test for the null of cointegration

Installation

pip install quantilecoint

Or install from source:

git clone https://github.com/merwanroudane/quantilecoint.git
cd quantilecoint
pip install -e .

Quick Start

import numpy as np
from quantilecoint import QuantileCointegration

# Generate sample data
np.random.seed(42)
n = 200
x = np.cumsum(np.random.randn(n))  # I(1) process
y = 2.0 + 1.5 * x + np.random.randn(n)  # Cointegrated with x

# Fit quantile cointegrating regression
model = QuantileCointegration(y, x, n_lags=4)

# Estimate at different quantiles
results = model.fit(quantiles=[0.1, 0.25, 0.5, 0.75, 0.9])

# Print publication-ready results
print(results.summary())

# Test for constant coefficients
stability_test = model.test_stability()
print(stability_test)

Main Features

1. Quantile Cointegrating Regression

from quantilecoint import QuantileCointegration

model = QuantileCointegration(y, x, n_lags=4)
results = model.fit(tau=0.5)  # Median regression

# Get fully-modified estimates (bias-corrected)
fm_results = model.fit_fully_modified(tau=0.5)

2. Test for Time-Varying Coefficients

# Test H0: β(τ) = β (constant across quantiles)
stability = model.test_stability(
    quantiles=np.arange(0.05, 0.96, 0.05),
    n_bootstrap=1000
)
print(f"Test statistic: {stability.statistic:.4f}")
print(f"Critical values (1%, 5%, 10%): {stability.critical_values}")

3. Wald Test for Restrictions

# Test H0: β = 1
wald = model.wald_test(R=np.array([[0, 1]]), r=np.array([1]), tau=0.5)
print(f"Wald statistic: {wald.statistic:.4f}")
print(f"P-value: {wald.pvalue:.4f}")

4. CUSUM Cointegration Test

# Test null of cointegration
cusum = model.test_cointegration(tau=0.5)
print(f"CUSUM statistic: {cusum.statistic:.4f}")

Output Format

Results are formatted for publication in top journals:

==============================================================================
                    Quantile Cointegrating Regression Results
==============================================================================
Dep. Variable:                      y   No. Observations:                  200
Method:              Quantile Regression (Fully-Modified)
Date:                Mon, 20 Jan 2026   Number of Lags:                      4
Time:                        02:43:00   
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
const          2.0134      0.089     22.623      0.000       1.839       2.188
x              1.4987      0.012    124.892      0.000       1.475       1.522
==============================================================================

Quantile Coefficient Estimates:
------------------------------------------------------------------------------
   τ     β(τ)    Std.Err   95% CI Lower   95% CI Upper
------------------------------------------------------------------------------
  0.10   1.423    0.018       1.388          1.458
  0.25   1.467    0.014       1.440          1.494
  0.50   1.499    0.012       1.475          1.522
  0.75   1.531    0.014       1.504          1.558
  0.90   1.576    0.019       1.539          1.613
------------------------------------------------------------------------------

References

  • Xiao, Z. (2009). Quantile cointegrating regression. Journal of Econometrics, 150(2), 248-260.
  • Koenker, R., & Bassett, G. (1978). Regression quantiles. Econometrica, 46(1), 33-50.
  • Koenker, R., & Xiao, Z. (2006). Quantile autoregression. Journal of the American Statistical Association, 101(475), 980-990.

License

MIT License - see LICENSE file for details.

Citation

If you use this package in your research, please cite:

@software{roudane2026quantilecoint,
  author = {Roudane, Merwan},
  title = {quantilecoint: Quantile Cointegrating Regression in Python},
  year = {2026},
  url = {https://github.com/merwanroudane/quantilecoint}
}

And the original paper:

@article{xiao2009quantile,
  title={Quantile cointegrating regression},
  author={Xiao, Zhijie},
  journal={Journal of Econometrics},
  volume={150},
  number={2},
  pages={248--260},
  year={2009},
  publisher={Elsevier}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantilecoint-1.0.0.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantilecoint-1.0.0-py3-none-any.whl (46.8 kB view details)

Uploaded Python 3

File details

Details for the file quantilecoint-1.0.0.tar.gz.

File metadata

  • Download URL: quantilecoint-1.0.0.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for quantilecoint-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ddc6d6f35879002582bc79e735bafeca9656e054bc2c55b4c5cf304e5eda7a19
MD5 753349577343b1fc22f53cad2a74e835
BLAKE2b-256 f85ee84568bb8b0bec1abb8bfad0c0a039f5b714279217cfc41ee90037a5de60

See more details on using hashes here.

File details

Details for the file quantilecoint-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: quantilecoint-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 46.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for quantilecoint-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f971db7f19d9eceefe3c9f8bcf99ab1e6819fe977f83ce1d9f6d043d4ae04c8a
MD5 4992d161739e1ab8ef7df8619f8117a8
BLAKE2b-256 c96cbea4283f994e54b8895237803e018dca1f3a42cfd0a655fd8467348656a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page