# New projpred is now on CRAN

**URL:** <https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954>\
**Category:** Publicity\
**Tags:** projpred\
**Created:** [October 28, 2020, 4:19pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954 "2020-10-28T16:19:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlejandroCatalina](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/alejandrocatalina/32/6093_2.png) [@AlejandroCatalina](https://discourse.mc-stan.org/u/AlejandroCatalina)\
**Post date:** [October 28, 2020, 4:19pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/1 "2020-10-28T16:19:16Z")

</div>

It’s now on CRAN with the latest version!

> **[projpred: Projection Predictive Feature Selection](https://cran.r-project.org/web/packages/projpred/index.html)**
>
> Performs projection predictive feature selection for generalized linear models and generalized linear and additive multilevel models (see, Piironen, Paasiniemi and Vehtari, 2020, \<https://projecteuclid.org/euclid.ejs/1589335310\>, Catalina,...

As mentioned in the NEWS.md, the latest release includes:

We have fully rewritten the internals in several ways. Most importantly, we now leverage maximum likelihood estimation to third parties depending on the reference model’s family. This allows a lot of flexibility and extensibility for various models. Functionality wise, the major updates since the last release are:

- Added support for GLMMs and GAMMs via `lme4` and `gamm4` .
- Formula syntax support internally that allows for easier building upon projections.
- Thanks to the above point, we save some computation by only considering sensible projections during forward search instead of fitting every possible submodel.
- We have added a new argument `search_terms` that allows the user to specify custom unit building blocks of the projections. This can be used to include _fixed terms_ across all projections, for instance. New vignette coming up.
- We have fully changed the way to define custom reference models. The user now provides projection fitting and prediction functions (more information in a new upcoming vignette).

More documentation and vignettes to come.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 28, 2020, 5:44pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/2 "2020-10-28T17:44:12Z")

</div>

I was wondering, but neither @avehtari nor @paul.buerkner knew, can the new projpred project to a linear model if the original formula is like `y ~ s(x)` or does the original formula need to be more like `y ~ x + s(x)`?

---

<div class="post-metadata">

**Author:** ![AlejandroCatalina](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/alejandrocatalina/32/6093_2.png) [@AlejandroCatalina](https://discourse.mc-stan.org/u/AlejandroCatalina)\
**Post date:** [October 28, 2020, 5:58pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/3 "2020-10-28T17:58:53Z")

</div>

I haven’t personally tried it out but my guess is it would work by passing search\_terms = [“x”] to either varsel or cv\_varsel. It would also work by hacking the formula slot in the refmodel object to say ref$formula \<- y ~ x even though the reference model is a GAM.

Best,  
Alejandro

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 28, 2020, 8:20pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/4 "2020-10-28T20:20:25Z")

</div>

It seems like a linear (sub)model is an important special case of a GAMM, so should we be recommending the `y ~ x + s(x)` form so that projpred could find linearity without any additional arguments or hacks?

---

<div class="post-metadata">

**Author:** ![AlejandroCatalina](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/alejandrocatalina/32/6093_2.png) [@AlejandroCatalina](https://discourse.mc-stan.org/u/AlejandroCatalina)\
**Post date:** [October 28, 2020, 8:24pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/5 "2020-10-28T20:24:41Z")

</div>

Wouldn’t that suffer from high correlations as well? I’ll try projecting y ~ x + s(x) and see, but some tests that I did resulted in bad maximum likelihood estimates, because they are harder to find I believe. If the reference model incorporates and properly identifies both terms then both would be projected. Maybe what happens is that fitting y ~ s(x) already fits x + s(x)?

Best,  
Alejandro

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 28, 2020, 8:49pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/6 "2020-10-28T20:49:24Z")

</div>

Hmm. It seems that `y ~ x + s(x)` does not sample well, even though mgcv is making a rank-deficient spline basis. But `varsel(..., search_terms = list("x"))` on a model with `y ~ s(x)` yields

> Error in sub[“kl”, i] : incorrect number of dimensions

Am I doing it wrong? There does not seem to be an example of using the `search_terms` argument.

---

<div class="post-metadata">

**Author:** ![AlejandroCatalina](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/alejandrocatalina/32/6093_2.png) [@AlejandroCatalina](https://discourse.mc-stan.org/u/AlejandroCatalina)\
**Post date:** [October 28, 2020, 9:18pm UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/7 "2020-10-28T21:18:18Z")

</div>

Yes, that was my concern, my experiments with models of the type x + s(x) didn’t sample well either. My guess is that s(x) already includes the linear unpenalized term in libraries like mgcv or gamm4, but I haven’t dig into that.

I’ll confirm tomorrow how to properly set the search\_terms argument for varsel because it’s a parameter that we haven’t really used yet so it’s usage is a bit unexplored. I will add more examples and documentation for it.

Thanks for reporting!

Best,  
Alejandro

---

<div class="post-metadata">

**Author:** ![AlejandroCatalina](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/alejandrocatalina/32/6093_2.png) [@AlejandroCatalina](https://discourse.mc-stan.org/u/AlejandroCatalina)\
**Post date:** [November 9, 2020, 11:55am UTC](https://discourse.mc-stan.org/t/new-projpred-is-now-on-cran/18954/8 "2020-11-09T11:55:04Z")

</div>

I finally came back to this. So it happens that `search_terms` must include the intercept, so the correct syntax would be `search_terms = c("1", "x")`. This is something that is not very intuitive for the user so I’ll change it to detect whether it includes the intercept or not and include it myself automatically otherwise.

Sorry for the late response.
