Reject glmmTMB models fitted with priors in likelihood-ratio tests
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Domain
- data
Research direction
Start at the validation block in R/compare_nested_models.R (lines 94-135, linked in the issue) and determine how a stored glmmTMB fit exposes its priors, since logLik includes them. Add a check that stops when either fitted model carries priors, including identical priors on both sides. Cover it in the testthat suite with the issue's reproduction plus no-prior, NULL and empty-prior cases, and document the restriction in the roxygen help; done means the reproduction now errors while prior-free comparisons are unchanged.
Written by the indexing model from the issue text.
Description
Problem
compare_nested_models() reports an ordinary likelihood-ratio test for models fitted with priors. That test requires maximum-likelihood (ML) fits without priors; glmmTMB uses maximum a posteriori (MAP) estimation when priors are supplied.
The current check accepts these fits. glmmTMB explains MAP here. Its logLik method returns a value that includes priors, so the usual chi-squared calculation is not the required ML test.
Reproduction
set.seed(123)
dat <- data.frame(x = rep(c(-1, 1), each = 50))
dat$y <- 2 * dat$x + rnorm(nrow(dat))
prior <- data.frame(prior = "normal(0,1)", class = "fixef", coef = "x")
restricted <- glmmTMB::glmmTMB(y ~ 1, data = dat)
regularised <- glmmTMB::glmmTMB(y ~ x, data = dat, priors = prior)
dyadMLM::compare_nested_models(restricted, regularised)
Suggested fix
- Check stored fitted models for active priors. If either has priors, stop and ask the user to refit without them.
- Test one fit with priors against one without, and two fits with identical or different priors. Identical priors do not make this test valid.
- Keep fits without priors working, including
NULLand empty prior specifications. - Explain the restriction in the help. Comparing models with priors is a separate task.
Reproduced on 2026-09-10 at c92eb46 with glmmTMB 1.1.14: the converged MAP fit passes validation and produces a chi-squared p-value.
Related: #33.
- Dominant language
- R
- Stars
- 1
- Forks
- 2
- Avg merge
- 9h 28m
- Merged PRs (30d)
- 21
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Pascal-Kueng/dyadMLM
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Pascal-Kueng/dyadMLM#92 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Pascal-Kueng/dyadMLM#83 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Pascal-Kueng/dyadMLM#71 · 2 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Pascal-Kueng/dyadMLM#70 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Pascal-Kueng/dyadMLM#69 ·
Maintainers usually reply within 1 day
All issues in Pascal-Kueng/dyadMLM
Similar issues
-
enhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Breaking 🏴☠️ Consistency :green_apple: :apple:
Difficulty 1/5 Under an hour Newbie friendliness 70/100
easystats/bayestestR#789 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stan-dev/priorsense#150 ·