Skip to content

[ENH] Add Pesaran CD panel dependence diagnostic#703

Open
hass-nation wants to merge 1 commit into
bashtage:mainfrom
hass-nation:feature/pesaran-cd-test
Open

[ENH] Add Pesaran CD panel dependence diagnostic#703
hass-nation wants to merge 1 commit into
bashtage:mainfrom
hass-nation:feature/pesaran-cd-test

Conversation

@hass-nation

Copy link
Copy Markdown

Summary

  • add a pesaran_cd cached result property to panel model results
  • implement a standard-normal test statistic container for asymptotic z tests
  • add balanced, unbalanced, and inapplicable-path coverage for the new diagnostic

Motivation

Pesaran's CD test is a widely used panel diagnostic for residual cross-sectional dependence, especially when users want a quick dependence check after fitting pooled, fixed-effects, or random-effects models. linearmodels already exposes panel result diagnostics and residual accessors, so this test fits naturally in the existing results API.

Reference

  • Pesaran, M. H. (2021). "General diagnostic tests for cross-sectional dependence in panels." Empirical Economics, 60(1), 13-50.

Validation

  • python -m pytest linearmodels/tests/shared/test_utility.py linearmodels/tests/panel/test_results.py
  • python -m pytest linearmodels/tests/panel/test_pooled_ols.py::test_results_access linearmodels/tests/panel/test_panel_ols.py::test_results_access linearmodels/tests/panel/test_between_ols.py::test_results_access linearmodels/tests/panel/test_random_effects.py::test_results_access linearmodels/tests/panel/test_firstdifference_ols.py::test_results_access linearmodels/tests/panel/test_fama_macbeth.py::test_fama_macbeth linearmodels/tests/panel/test_fama_macbeth.py::test_fama_macbeth_kernel_smoke
  • python -m ruff check linearmodels/shared/hypotheses.py linearmodels/panel/results.py linearmodels/tests/shared/test_utility.py linearmodels/tests/panel/test_results.py

Add a cached pesaran_cd result property for panel estimators, backed by idiosyncratic residual correlations and a standard-normal test container, with balanced and unbalanced coverage in the panel and shared hypothesis tests. Implements the diagnostic in Pesaran, M. H. (2021), "General diagnostic tests for cross-sectional dependence in panels", Empirical Economics, 60(1), 13-50.

Co-Authored-By: OpenAI Codex <codex@openai.com>
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.52%. Comparing base (b535f55) to head (135602f).

Files with missing lines Patch % Lines
linearmodels/shared/hypotheses.py 90.62% 1 Missing and 2 partials ⚠️
linearmodels/panel/results.py 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #703      +/-   ##
==========================================
- Coverage   99.54%   99.52%   -0.03%     
==========================================
  Files         101      101              
  Lines       17426    17524      +98     
  Branches     1430     1435       +5     
==========================================
+ Hits        17347    17440      +93     
- Misses         29       31       +2     
- Partials       50       53       +3     
Flag Coverage Δ
adder 99.50% <95.00%> (-0.03%) ⬇️
subtractor 99.50% <95.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant