Skip to content

9/9 Cox elastic net: lambda path ends at 0.05 of the largest value by default (changes results; 6.6x faster) - #134

Merged
DarioS merged 1 commit into
review/8-releasefrom
review/9-coxnet-path
Oct 28, 2026
Merged

DarioS merged 1 commit into
review/8-releasefrom
review/9-coxnet-path

Conversation

@ellispatrick

Copy link
Copy Markdown
Member

Part 9 of the stack (#126 → #133 → this). Based on #133. It can be accepted or rejected on its own: closing it keeps glmnet's default lambda path.

Summary

Changes results (decided by Ellis Patrick's delegation, on the evidence below). The Cox elastic net (classifier = "CoxNet") ends its path of lambda at 0.05 of the largest value by default. glmnet's own default is 0.0001 with more samples than features, 0.01 otherwise. Tuning by C-index is kept.

Why

  • Statistical: lambdas near zero give nearly unpenalised Cox models with dozens of coefficients. With the few events typical of omics cohorts (39 relapses in the protocol's METABRIC data), these overfit, and glmnet converges slowly there (it reported non-convergence at the end of the default path).
  • Precedent: ncvreg ends its path at 0.05 when there are more features than samples.
  • Performance: no loss on the protocol's own analysis; see below.
  • Speed: 6.6× faster on that analysis.

Evidence

Protocol Procedure 2 step 7: merge of clinical, Domain Proportions, Proportions of Parent, Colocalisation and RNA Microarray views; all 31 combinations; 20 × 5 CV; shared folds; 16 cores.

Setting Tuning Time Mean C-index over 31 combinations Best combination
A (glmnet default path) C-index 9.2 min 0.599 0.670
B deviance 9.1 min 0.587 0.646
C (this PR) C-index, path ends at 0.05 1.4 min 0.602 0.672
D deviance, path ends at 0.05 1.4 min 0.587 0.647
E deviance, path stops at 30 features 1.7 min 0.587 0.646
  • Tuning measure: partial likelihood deviance is the textbook way to tune a Cox penalty, but it gave consistently lower C-indexes (−0.012), so C-index tuning stays.
  • The cut at 0.05: with glmnet's default path, cross-validation chose a lambda below 0.05 of the largest in 12% of the 3,100 fold models (median 0.17). Clipping those did not lower the C-index; setting C was best in 21 of 31 combinations.
  • Best combination: the same under every setting, clinical + Domain Proportions + Colocalisation.
  • Caveat: the setting was chosen partly on this data set. The C-index difference is within noise, so the case rests on "no loss, six times faster, statistically sensible".

What changes

  • coxnetTrainInterface passes lambda.min.ratio = 0.05 unless the user gives lambda or lambda.min.ratio (e.g. extraParams = list(train = list(lambda.min.ratio = 1e-4)) restores glmnet's default).
  • A NEWS entry and a test.

Evidence

544 test expectations pass. Scripts and per-combination results: ProjectClassifyR scripts/coxnet_tuning/.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4

…by default (changes results)

Why: lambdas near zero give nearly unpenalised Cox models, which overfit the few events of typical omics
cohorts (39 relapses in the protocol's METABRIC data) and converge slowly. On the protocol's Procedure 2
step 7 (merge of five views, 31 combinations, 20 x 5 CV, 16 cores), compared with glmnet's default path:
- mean C-index over the 31 combinations 0.602 vs 0.599; best in 21 of 31 combinations;
- 1.4 min vs 9.2 min;
- cross-validation had chosen a lambda below 0.05 of the largest in 12% of fold models; clipping those
  did not lower the C-index.
Tuning by partial likelihood deviance was also compared and gave lower C-indexes (0.587), so tuning by
C-index stays. ncvreg uses the same 0.05 when there are more features than samples. Users can still set
lambda or lambda.min.ratio through extraParams.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
@DarioS
DarioS added this pull request to stack #148 October 28, 2026 02:13
@DarioS
DarioS marked this pull request as ready for review October 28, 2026 02:27

@DarioS DarioS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speed improvement but the same accuracy.

@DarioS
DarioS merged commit cd815ec into review/5-maintenance Oct 28, 2026
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