Repository navigation
Conversation
…by projpred's own Laplace fit
…cap, fallback deviance, tests against glmer()
…rm by projpred's own Laplace fit
…values, inner convergence, dimnames, tests
# Conflicts: # NEWS.md # R/RcppExports.R # man/projpred-package.Rd # src/RcppExports.cpp
…_mlvl() now sets for cloglog and loglog
…e test reference and reflow the package doc
# Conflicts: # NEWS.md # R/RcppExports.R # man/projpred-package.Rd # src/RcppExports.cpp
# Conflicts: # NEWS.md # R/RcppExports.R # src/RcppExports.cpp
… with non-integer binomial data
# Conflicts: # NEWS.md
# Conflicts: # NEWS.md
aloctavodia
approved these changes
Nov 18, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR continues #644 and is based on its branch. If the only group-level term of a
brms::cumulative()submodel is(1 | <group>), projpred now fits it with its own Laplace fitter instead ofordinal::clmm(). The fitter minimizes the Laplace objective ofclmm()bynlminb()with the exact gradient. The objective and the gradient are in C++ (src/mlvlcumul.cpp). In the benchmark model with only(1 | g),varsel()is 6.7 times faster than on master.cv_varsel()with LOO validated search is 6.1 times faster. With a group-level slope term in the reference model, the speedups are 2.8 (varsel()) and 3.0 (cv_varsel()). The predictor rankings are the same as on master.Speed
Median of 3 runs, in seconds (CSC Roihu, 1 CPU per run, ordinal 2026.7-26; both versions in one job).
(1 | g)varsel()(1 | g)cv_varsel(), LOO validated search(1 + x1 | g)varsel()(1 + x1 | g)cv_varsel(), LOO validated searchbrms::brm()fits with 300 observations, 4 response categories and 6 predictors.varsel()usednterms_max = 6;cv_varsel()usedvalidate_search = TRUE,nloo = 10andnterms_max = 4.lppdandmuvalues was 1.7e-5 (rows 1 and 2) and 1.4e-5 (rows 3 and 4).varsel()and 21,120 of 21,560 incv_varsel()have no slope term. At most one of them used the fallback toclmm(); the others used the new fitter.clmm()fits.The fitter
clmm(): P(y <= j) = F(alpha_j - x'beta - b_g), with group-level intercepts b_g with standard deviation tau. With one grouping variable, the Newton iteration for the conditional modes works per group. The gradient includes the derivative of the conditional modes.logit,probit(alsoprobit_approx),cloglogandcauchit, the links ofbrms::cumulative(). The C++ code also hasloglog.c("projpred_mlvl_cumul", "projpred_mlvl")without the data.clmm()in these cases:clmm()or its optimizers in...;projpred.mlvl_laplace = FALSE(from Fit binomial and Poisson multilevel submodels with group-level intercepts by projpred's own Laplace fitter #644).clmm()and converts the result to classprojpred_mlvl_cumul.clmm()code path. Thus the same seed gives the same draws as on master.get_subparams()keeps the parameter names and order of theclmm()code path, so the column names ofas.matrix.projection()do not change.as_glmerMod()gives an error for these fits.Changes in results
outdminhave classprojpred_mlvl_cumulinstead ofclmm.logit,probitandcauchit, the fitter andclmm()minimize the same function. In the unit tests, the objective of the fitter is equal to or lower than that at theclmm()estimates, and the parameters agree within 1e-3. A prototype of the fitter andclmm()fitted the 2,820 submodels of onevarsel()call on the model of rows 1 and 2. The prototype objective was at most 2.5e-8 higher and at most 2.9e-5 lower than theclmm()objective. The time per fit was 100.5 ms forclmm()and 11.3 ms for the prototype.cloglog:clmm()withoutuseMatrix = TRUEfits theloglogmodel for a single(1 | <group>)term (clmm(): the cloglog and loglog links are swapped in the C link functions runehaubo/ordinal#76). Since Fixclmm()submodel fits with thecloglogandlogloglinks #613, projpred callsclmm()withuseMatrix = TRUEfor this link. The new fitter also fits thecloglogmodel.clmm()reports can differ from the Laplace value at its estimates (up to 2.8e-3 in the 2,820 fits). The fitter reports the Laplace value at the conditional modes.clmm()code path gives a linear predictor ofInf. The new fitter gives a finite value.Tests
test_mlvl_laplace_cumul.R(13 test blocks; no reference model fit, so it also runs on CRAN). It tests:Infat extreme parameters, and the fitter againstclmm();clmm()code path (all links exceptloglog);MASS::polr();divmin_augdat()andsubprd_augdat()with mixed fit classes;cv_varsel()with LOO validated search for a cumulative reference model, where the weight perturbation (Smoother LOO curves with improved SE #603) changes the weights. The rankings and theelpdvalues equal those of theclmm()code path.outdmin_tester_aug()expects classprojpred_mlvl_cumul. The existingclmm()tests turn the fitter off.divmin_augdat().NOT_CRAN=trueon 3968e72 (with master 7b2ac74 merged), ordinal 2026.7-26, 0 failures:test_mlvl_laplace_cumul.Ralso passes on 3968e72.This PR was assisted by Claude.