# Combining splines with LASSO in clinical prediction models

**URL:** <https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595>\
**Category:** modeling strategy\
**Tags:** prediction\
**Created:** [January 10, 2026, 11:12am UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595 "2026-01-10T11:12:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthur\_albuquerque](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/arthur_albuquerque/32/3269_2.png) [@arthur\_albuquerque](https://discourse.datamethods.org/u/arthur_albuquerque)\
**Post date:** [January 10, 2026, 11:12am UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/1 "2026-01-10T11:12:13Z")

</div>

I want to include restricted cubic splines while developing a clinical prediction model with a multinomial outcome. However, I also want to apply LASSO for shrinkage.

I know that one could fit a grouped-LASSO to ensure that pairs of linear terms parameterizing each spline are either included or excluded together. Unfortunately there is no R package that applies this approach for multinomial models.

**Should I include restricted cubic spline basis functions in the model matrix before fitting LASSO?**

I understand that a major drawback would be that standard LASSO penalizes basis functions independently. Thus it might select the 3rd/2nd basis function of a spline while dropping the 1st.

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [January 10, 2026, 12:59pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/2 "2026-01-10T12:59:33Z")

</div>

I don’t think it will be valid to use any technique that doesn’t always consider all basis functions simultaneously.

Note that `lasso` has a very low probability of selecting the right features as shown in a link inside [Challenges of High-Dimensional Data Analysis](https://hbiostat.org/hdata). If you are just using `lasso` for shrinkage I would definitely use ridge regression instead. Are you doing feature selection? Why? Why not use unsupervised learning (data reduction) which is more stable and doesn’t try to separate hard-to-separate predictors?

---

<div class="post-metadata">

**Author:** ![arthur\_albuquerque](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/arthur_albuquerque/32/3269_2.png) [@arthur\_albuquerque](https://discourse.datamethods.org/u/arthur_albuquerque)\
**Post date:** [January 10, 2026, 1:18pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/3 "2026-01-10T13:18:27Z")

</div>

I was indeed planning to use LASSO for both variable selection (combined with expert input before) and shrinkage, as mentioned in a previous post: [Optimism Correction after LASSO in clinical prediction models - #12 by arthur\_albuquerque](https://discourse.datamethods.org/t/optimism-correction-after-lasso-in-clinical-prediction-models/28579/12)

In that post you also mentioned using unsupervised learning, I have to delve more into this subject. In general I only see backward stepwise or LASSO for variable selection in high-quality articles about clinical prediction models. Not sure I have seen an applied example of unsupervised learning in this context.

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [January 10, 2026, 4:40pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/4 "2026-01-10T16:40:46Z")

</div>

Unsupervised learning (e.g., variable clustering or nonlinear principal components) has been used larger in high-dimensional situations and not so much with regular clinical variables. But it works well in your setting, typically better than variable selection. It is more interpretable in the sense of being more stable and not requiring arbitrary decisions about which collinear variables to exclude. Unsupervised learning doesn’t usually have to be accounted for in resampling validation, unless the methods you propose to use.

---

<div class="post-metadata">

**Author:** ![stephenrho](https://discourse.datamethods.org/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@stephenrho](https://discourse.datamethods.org/u/stephenrho)\
**Post date:** [January 12, 2026, 4:17pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/5 "2026-01-12T16:17:46Z")

</div>

If you want splines and shrinkage/penalization (and are using R) you could consider `mgcv::multinom` [R: GAM multinomial logistic regression](https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/multinom.html)

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [January 12, 2026, 5:43pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/6 "2026-01-12T17:43:15Z")

</div>

The `mgcv` package is excellent. I’d be interested to learn the form of penalization it uses for multinomial logistic models. What we need is a penalty that pushes towards similar shapes of effects across outcome categories.

---

<div class="post-metadata">

**Author:** ![arthur\_albuquerque](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/arthur_albuquerque/32/3269_2.png) [@arthur\_albuquerque](https://discourse.datamethods.org/u/arthur_albuquerque)\
**Post date:** [January 12, 2026, 5:45pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/7 "2026-01-12T17:45:32Z")

</div>

Yes, in lasso through `glmnet` we can use the argument `type.multinomial = "grouped"`. It would be interesting if `mgcv` provides a similar approach.

---

<div class="post-metadata">

**Author:** ![stephenrho](https://discourse.datamethods.org/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@stephenrho](https://discourse.datamethods.org/u/stephenrho)\
**Post date:** [January 12, 2026, 6:37pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/8 "2026-01-12T18:37:11Z")

</div>

It looks to be possible to use the _same_ smooth across multiple outcome categories (see last [example](https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/multinom.html))

---

<div class="post-metadata">

**Author:** ![arthur\_albuquerque](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/arthur_albuquerque/32/3269_2.png) [@arthur\_albuquerque](https://discourse.datamethods.org/u/arthur_albuquerque)\
**Post date:** [January 12, 2026, 7:52pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/9 "2026-01-12T19:52:52Z")

</div>

Yes, thanks.

Now I wonder if it does matter to use grouped instead of the ungrouped approach in multinomial models. In LASSO, “grouped” ensures covariates are all in our out together. But is this important at all?

The end user of a CPM doesn’t really care what coefficients are present in each multinomial sub-model.

---

<div class="post-metadata">

**Author:** ![f2harrell](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/f2harrell/32/165_2.png) [@f2harrell](https://discourse.datamethods.org/u/f2harrell)\
**Post date:** [January 13, 2026, 12:00pm UTC](https://discourse.datamethods.org/t/combining-splines-with-lasso-in-clinical-prediction-models/28595/10 "2026-01-13T12:00:57Z")

</div>

A semi-related side note: likelihood ratio and Wald tests for association need to have all coefficients present that were ever given a chance to be present. Chunk tests need well-defined pre-specified degrees of freedom.
