Skip to content

Conversation

ajinkya-k
Copy link
Contributor

Issue #683 talks about adding StatsModels.lrtest. If I understood the code correctly, the only thing that was different from likelihoodratiotest was checking if models are nested. I implemented an StatsModels.isnested function that takes any number of MixedModels, and used that to implement StatsModels.lrtest

Did behavior change? Did you add need features? If so, please update NEWS.md

  • add entry in NEWS.md
  • after opening this PR, add a reference and run docs/NEWS-update.jl to update the cross-references.

Should we release your changes right away? If so, bump the version:

  • I've bumped the version appropriately

@ajinkya-k
Copy link
Contributor Author

@dmbates let me know what you think

Copy link

codecov bot commented Mar 18, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 97.08%. Comparing base (7b37191) to head (c9e6ed9).

Files with missing lines Patch % Lines
src/likelihoodratiotest.jl 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #811      +/-   ##
==========================================
- Coverage   97.33%   97.08%   -0.26%     
==========================================
  Files          36       36              
  Lines        3490     3499       +9     
==========================================
  Hits         3397     3397              
- Misses         93      102       +9     
Flag Coverage Δ
current 96.74% <0.00%> (-0.25%) ⬇️
minimum 97.08% <0.00%> (-0.26%) ⬇️
nightly 96.66% <0.00%> (-0.26%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@palday
Copy link
Member

palday commented Mar 18, 2025

@ajinkya-k this shouldn't be necessary if StatsModels is loaded: lrtest is a generic function. Using current releases:

julia> using MixedModels; using StatsModels: lrtest; using MixedModels: dataset

julia> fm0 = lmm(@formula(reaction ~ 1 + (1|subj)), dataset(:sleepstudy));

julia> fm1 = lmm(@formula(reaction ~ 1 + days + (1 + days|subj)), dataset(:sleepstudy));

julia> lrtest(fm0, fm1)
Likelihood-ratio test: 2 models fitted on 180 observations
─────────────────────────────────────────────────────────
     DOF  ΔDOF     LogLik   Deviance     Chisq  p(>Chisq)
─────────────────────────────────────────────────────────
[1]    3        -955.2705  1910.5411                     
[2]    6     3  -875.9697  1751.9393  158.6017     <1e-33
─────────────────────────────────────────────────────────

@ajinkya-k
Copy link
Contributor Author

interesting! in that case the issue can also be closed right?

@palday
Copy link
Member

palday commented Mar 18, 2025

interesting! in that case the issue can also be closed right?

The fix for the original issue is more like #814 😄

@palday palday closed this Mar 18, 2025
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.

2 participants