Skip to content

Adapt the tests to lme4 2.1-0 - #577

Open
avehtari wants to merge 2 commits into
masterfrom
adapt-tests-lme4
Open

avehtari wants to merge 2 commits into
masterfrom
adapt-tests-lme4

Conversation

@avehtari

Copy link
Copy Markdown
Member

Summary

lme4 2.1-0 reached CRAN on 2026-10-23. With it, master fails 5 expectations in test_augdat.R and test_datafit.R, and so do the CI runs (see, e.g. #573 to #576). This PR adapts the two tests and changes no package code.

A separate issue will open discussion on what we should do with the code

This PR was assisted by Claude.

Causes

test_augdat.R:244 and :308 compare the traditional and the augmented-data projection of a Bernoulli reference model. For submodels with group-level terms, both projections call lme4::glmer(), which the test setup runs with nAGQ = 30.

lme4 computes the objective for the group-level parameters with binomial()$aic. That function rounds non-integer responses (traditional projection) and non-integer weights (augmented-data projection); lme4/lme4#682 describes the rounding. Up to lme4 2.0-6, nAGQ > 1 used the deviance residuals, which do not round, and the two projections agreed. In 2.1-0, glmerAGQ() uses the same aic() term as the Laplace approximation (lme4 NEWS: "normalizing constants are now included in the log-likelihoods and deviances of models fitted with nAGQ>1"; reported in lme4/lme4#1011). Now the two projections fit different rounded objectives. In the test data the rounded responses separate the data: in 4 of the 6 traditional projections, the largest fixed effect is between 38 and 60 in absolute value, against at most 1.7 with lme4 2.0-6.

nAGQ = 0 does not rescue the comparison. It makes the fixed effects agree in most fits, but the group-level standard deviation still comes from the rounded objective, and one setup still differs.

test_datafit.R:252 checks that the full-data ranking contains only terms of the formula. The default search terms also contain the linear term of each smooth term, for example s.1 for s(s.1). With lme4 2.1-0 and gamm4 0.3-0, the forward search for rstanarm.gamm.brnll picks (1 | z.1) + s.1 at the second step, where it used to pick (1 | z.1) + s(s.1). Both are valid results, and the check for the CV rankings already accepts such linear terms.

Changes

  • test_augdat.R: the two comparisons skip submodels with group-level terms. They now cover the submodels fitted by fit_glm_ridge_callback(), which is what their titles say. I removed the extra tolerances for the group-level case. The test setup still runs these projections, so other tests still use them.
  • helpers/testers.R: vsel_tester() accepts the linear terms of smooth terms in the full-data ranking, as it already did for the CV rankings.
  • NEWS.md entry.

The rounding also affects projections onto binomial submodels with group-level terms outside the tests, with any lme4 version at the default nAGQ = 1. I will open a separate issue for that.

Tests

On master 73cf0ee with gamm4 0.3-0, test_augdat.R and test_datafit.R give 5 failures with lme4 2.1-0 and none with lme4 2.0-6. With this PR, the full suite passes with NOT_CRAN=true under both lme4 versions: 253 tests, 0 failures (55 655 expectations with lme4 2.0-6, 55 401 with lme4 2.1-0). Both runs show the warnings of master plus a CHOLMOD "not positive definite" warning in test_div_minimizer.R. That warning appears with both lme4 versions and did not appear in our earlier runs of master with gamm4 0.2.7. Tested with R 4.6.1, brms 2.23.0, rstanarm 2.32.2, gamm4 0.3-0, and lme4 2.0-6 and 2.1-0, on CSC Roihu (Linux, AMD EPYC).

This branch has not been deployed

No deployments
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