# Error when running cv\_varsel

**URL:** <https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786>\
**Category:** Modeling\
**Tags:** projpred\
**Created:** [March 14, 2022, 8:15am UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786 "2022-03-14T08:15:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![benlug](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@benlug](https://discourse.mc-stan.org/u/benlug)\
**Post date:** [March 14, 2022, 8:15am UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786/1 "2022-03-14T08:15:59Z")

</div>

Hi,

when using `cv_varsel` from `projpred` I run into the following error:

> Error in if (any(edgevals ← 0 \< bdiff & bdiff \< boundary.tol)) { : missing value where TRUE/FALSE needed

I’m not sure how to interpret this error message. I assume this is due to convergence issues within the projection. Is there a way to investigate further why this error occurs?

Any help is appreciated. Thank you in advance.

---

<div class="post-metadata">

**Author:** ![fweber144](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/fweber144/32/15592_2.png) [@fweber144](https://discourse.mc-stan.org/u/fweber144)\
**Post date:** [March 14, 2022, 8:27am UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786/2 "2022-03-14T08:27:54Z")

</div>

Yes, this sounds like an error produced by the submodel fitter during the projection. Unfortunately, to fix this, a reproducible example is needed (and some session info, at least the projpred version).

---

<div class="post-metadata">

**Author:** ![benlug](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@benlug](https://discourse.mc-stan.org/u/benlug)\
**Post date:** [March 14, 2022, 2:38pm UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786/3 "2022-03-14T14:38:16Z")

</div>

Thank you for your quick response.

A simple example is difficult to produce since the model used is relatively big (high computation time) and I do not know the origin of this problem.

It is a GLMM with a random intercept term. The `projpred` version is 2.02.

---

<div class="post-metadata">

**Author:** ![fweber144](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/fweber144/32/15592_2.png) [@fweber144](https://discourse.mc-stan.org/u/fweber144)\
**Post date:** [March 14, 2022, 2:45pm UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786/4 "2022-03-14T14:45:19Z")

</div>

For GLMMs, there have been some updates to the submodel fitting in the `develop` branch of projpred. You can install it via `devtools::install_github("stan-dev/projpred", ref = "develop")`. Perhaps this solves your problem?

---

<div class="post-metadata">

**Author:** ![benlug](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@benlug](https://discourse.mc-stan.org/u/benlug)\
**Post date:** [March 15, 2022, 8:47am UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786/5 "2022-03-15T08:47:00Z")

</div>

I’ve rerun the model with the latest `projpred` (2.10) and still got the same error message (albeit the projection needed much more time). In addition, I received a warning:

> quick-transfer stage steps exceeded maximum

Some more information:

- The random intercept and residual estimates are relatively lowish (~0.6 - 0.7). Perhaps a submodel does not converge due to the LOO-CV process resulting in 0-estimates for the variance parameters?

- Some Fixed effects are small as well

- When I refit the models without the random intercept cv\_varsel runs without problems → GLMM too complex for the data? Although I find this idea problematic since the reference model has no issues.

---

<div class="post-metadata">

**Author:** ![fweber144](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/fweber144/32/15592_2.png) [@fweber144](https://discourse.mc-stan.org/u/fweber144)\
**Post date:** [March 15, 2022, 9:42am UTC](https://discourse.mc-stan.org/t/error-when-running-cv-varsel/26786/6 "2022-03-15T09:42:57Z")

</div>

> [@benlug](#):
>
> Some more information:
> 
> - The random intercept and residual estimates are relatively lowish (~0.6 - 0.7). Perhaps a submodel does not converge due to the LOO-CV process resulting in 0-estimates for the variance parameters?
> 
> - Some Fixed effects are small as well
> 
> - When I refit the models without the random intercept cv\_varsel runs without problems → GLMM too complex for the data? Although I find this idea problematic since the reference model has no issues.

All this (although the middle point probably doesn’t matter) gives the broad hint that the problem occurs when fitting the multilevel submodels. So it’s related to the lme4 package. The only way I see to fix this is to have a reprex and then to play around with lme4 tuning/control parameters. The `develop` version of projpred allows to pass arguments to `lme4::lmer()`/`lme4::glmer()` (former one for a Gaussian model, latter one for binomial and Poisson models). If you can’t provide a reprex, you would have to play around with lme4 tuning/control parameters yourself. I’m sorry I can’t give a better solution.
