Repository navigation
Merged
Conversation
createControl(fitter = "super") resolved pooled logistic regression ("plr")
to the settings of fitter = "default", so a model fit with plr and with lr
on its expanded rows could select different variances (5.84 vs 19.78 on
the cross-validation test case). plr now gets lr's settings: the "kkt"
criterion, the step-down auto-search with the null-model bound and
refinement, per-fold warm starts, active-set cycling and adaptive
intercept steps. The intercept of a plr model is a subject column without
a time-basis column, so lr's extra-step rule applies unchanged (its moment
ratios and rows of work count subjects). On a 50,000-subject plr fit by
coordinate descent: 177 instead of 284 iterations, 4.3 instead of 6.0 s,
coefficients within 1e-6. NEWS 44; no version change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cross-validating a plr censoring model was about twice as slow as lr on 4 threads. Most of the gap was the Hessian block: plr added up its pairs of columns in a cache-unfriendly order, and four concurrent folds made it worse. It now builds the block as lr does, with the densest columns first, cache-sized tiles of subjects, and the same task split on one thread and on several. A Newton iteration also keeps the per-subject layouts of both its free set and its working set instead of rebuilding them, and subjectSums skips subjects that add nothing. 25,000 persons (72,748 person-intervals, 3,821 columns): 218 -> 128 s on 4 threads, 466 -> 402 s on 1 (lr 126 s and 395 s); 1e5 CCW defaults: 2,809 -> 1,385 s (lr 1,509 s), same variances and weights to rounding. New quick test: plr's gradient and Hessian equal lr's on the expanded rows, and are identical on 1 and 3 threads. NEWS 45; no version change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With threads > 1, models with concurrent gradients (plr, and Cox) ran cycleWithConcurrentGradients(), which always swept every coordinate and took no adaptive extra intercept steps. Under fitter = "super" (kkt, active-set cycling, adaptive intercept) a plr fit by coordinate descent therefore depended on the number of threads. The concurrent cycle now skips the coordinates the serial cycle skips, keeps the active-set bookkeeping (lastStepSE, cycleMaxStepSE), and takes the extra intercept steps, ending a run of concurrently computed gradients after an extra intercept step as after a move. The end-of-cycle bookkeeping both cycles share moved to finishCycle(). plr, super, ccd (600 subjects, 172 columns): 2 and 4 threads moved the coefficients by 7e-6 with no extra intercept steps (59 on one thread); now identical bit for bit, with the same 59 steps and iterations. Cox with activeSetEvery on 4 threads: 44 iterations and 5e-10 apart before, identical now. Fits on one thread and threaded fits without an active set or adaptive intercept are unchanged bit for bit. The plr threads test covers it (fails before, passes after). Suite 348 tests / 1904 expectations, 0 failed. NEWS 46; no version change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #122 +/- ##
===========================================
+ Coverage 85.14% 85.42% +0.27%
===========================================
Files 73 73
Lines 15780 15821 +41
===========================================
+ Hits 13436 13515 +79
+ Misses 2344 2306 -38 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Three commits that make pooled logistic regression (
plr) fit, cross-validate and scale likelron its expanded person-interval rows. NEWS items 44–46. No version bump.1.
fitter = "super"fitsplras it fitslr(NEWS 44)createControl(fitter = "super")used to giveplrthe settings offitter = "default". As a result, a model fit withplrand withlron its expanded rows could select different variances: 5.84 against 19.78 on the cross-validation test case.plrnow getslr's settings:"kkt"criterion;The intercept of a
plrmodel is a subject column without a time-basis column, solr's extra-step rule applies unchanged. Its moment ratios and rows of work count subjects.On a 50,000-subject
plrfit by coordinate descent, this took 177 iterations instead of 284 (4.3 s instead of 6.0 s), with coefficients within 1e-6.2. The
plrprox-Newton Hessian block inlr's column order and cache tiles (NEWS 45)Cross-validating a
plrcensoring model was about twice as slow aslr.lr's is:subjectSumsskips subjects that add nothing.plrbeforeplrnowlr(expanded rows)The selected variances and weights are the same to rounding: 6e-7 and 2e-7.
3. Coordinate descent on threads takes the steps it takes on one thread (NEWS 46)
With
threads > 1, models with concurrent gradients (plr, and Cox) rancycleWithConcurrentGradients(). That cycle always swept every coordinate and took no adaptive extra intercept steps. Underfitter = "super", aplrfit by coordinate descent therefore depended on the number of threads.The concurrent cycle now:
The end-of-cycle bookkeeping that both cycles share moved to
finishCycle().Effect:
plr, super, ccd (600 subjects, 172 columns): on 2 and 4 threads the coefficients moved by 7e-6, with no extra intercept steps against 59 on one thread. They are now identical bit for bit, with the same 59 steps and the same iterations.activeSetEveryon 4 threads: 44 iterations against 45, and 5e-10 apart, before. Identical now.Tests
plr's gradient and Hessian block equallr's on the expanded rows, in cache tiles and on threads.developand passes on this branch.test_dir, withoutNOT_CRAN): 348 tests, 1,904 expectations, 0 failed, 0 errors, 30 skipped.🤖 Generated with Claude Code