Skip to content

ENH: Add Vuong test for non-nested model comparison - #10502

Merged
bashtage merged 1 commit into
statsmodels:mainfrom
ZAABY:add-compare-vuong
Oct 24, 2026
Merged

bashtage merged 1 commit into
statsmodels:mainfrom
ZAABY:add-compare-vuong

Conversation

@ZAABY

@ZAABY ZAABY commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Adds compare_vuong, the Vuong (1989) test for non-nested likelihood models, as requested in #3897.

The test compares two models estimated on the same data through their observation-wise log-likelihoods and returns a z-statistic and p-value, with optional AIC/BIC corrections and one- or two-sided alternatives. It follows the API pattern of the existing compare_cox and compare_j functions.

Design notes:

  • The variance estimator divides by n - 1, matching the R package pscl and Stata (Vuong's original definition divides by n; the difference is asymptotically negligible).
  • Parameter counts for the AIC/BIC corrections include all estimated parameters, including the negative binomial dispersion parameter, following Desmarais and Harden (2013).
  • Comparing a model with itself returns NaN rather than raising, because the variance of the likelihood differences is zero and the test is undefined.
  • Clear errors are raised when a model provides no observation-wise log-likelihood, when the two models use different numbers of observations, or when the dependent variables differ.

Test values were verified against the vuong function of the R package pscl 1.5.9 (the R code is recorded in the test module) on the randhie data shipped with statsmodels, covering Poisson / NegativeBinomial / ZeroInflatedPoisson / Logit / Probit pairings, one-sided alternatives, symmetry under argument swapping, and all error cases.

AI Disclosure

Contributions must comply with the statsmodels AI Policy.

Tick exactly one of the following.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude.
    Used for: drafting the implementation, writing the tests, editing the docstring, debugging.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

@bashtage
bashtage merged commit 21d24c3 into statsmodels:main Oct 24, 2026
6 checks passed
bashtage added a commit that referenced this pull request Oct 25, 2026
Add compare_vuong next to compare_cox, compare_j and compare_encompassing. The Sphinx entries in docs/source/stats.rst already exist. Follow up to gh-10502.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit that referenced this pull request Oct 25, 2026
Add versionadded, use optional for default markers, document the parameter count convention versus pscl and nonnest2, the missing preliminary variance test and the omega == 0 case, correct the reference attribution, and show the example output. Follow up to gh-10502.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit that referenced this pull request Oct 25, 2026
Use default_rng, move imports to module level and test the one-sided alternatives against scipy.stats.norm. Follow up to gh-10502.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
bashtage added a commit that referenced this pull request Oct 25, 2026
ENH: Follow up on #10502, export compare_vuong and complete its docs
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.

ENH diagnostic/specification Vuong test for non-nested hypothesis

2 participants