Hi All,

I am experiencing the following issue with projection predictive variable selection, and I would much appreciate advice on what is going on and how to solve it, if possible.

I have a model, for instance:

model ← brm(y ~ fac1 + fac2 + x1 + x2 + s(x3) + (1|group), # x1, x2, x3 are continuous variables

data = data,

prior = priors,

cores = 4, seed = 123,

backend = “cmdstanr”, # (but the same issue occurs also when using “rstan”)

control = list(adapt_delta = 0.95, max_treedepth = 15))

Priors are defined as follows, for instance (but I assume this is not important to my question/problem):

priors = c(

prior(normal(0, 1), class = ‘b’),

prior(student_t(10, 1, 1), class = ‘sigma’),

prior(student_t(10, 1, 1), class = ‘sd’))

prior_summary(model)

prior class coef group resp dpar nlpar bound source

normal(0, 1) b user

normal(0, 1) b fac11 (vectorized)

normal(0, 1) b fac21 (vectorized)

normal(0, 1) b sx3_1 (vectorized)

normal(0, 1) b x1 (vectorized)

normal(0, 1) b x2 (vectorized)

student_t(3, 3, 2.5) Intercept default

student_t(10, 1, 1) sd user

student_t(10, 1, 1) sd group (vectorized)

student_t(10, 1, 1) sd Intercept group (vectorized)

student_t(3, 0, 2.5) sds default

student_t(3, 0, 2.5) sds s(x3) (vectorized)

student_t(10, 1, 1) sigma user

The model runs okay, and its diagnostics look fine as well. So I define the model as the reference model (for further variable selection):

ref_model ← get_refmodel(model)

I try to perform the projection predictive variable selection using the cv_varsel() function, that is:

variable_selection ← cv_varsel(ref_model)

Unfortunately, after a few seconds, the process stops, and I get the following message:

variable_selection ← cv_varsel(ref_model)

[1] “Computing LOOs…”

| | 0%

Error in model.matrix.gamm4(delete.response(terms(formula)), random = random, :

Not enough (non-NA) data to do anything meaningful

In addition: Warning messages:

1: In cv_varsel.refmodel(ref_model) : K provided, but cv_method is LOO.

Please, can someone clarify the error message? Is there any way to make projpred::cv_varsel() work with linear/generalised linear/generalised additive (mixed-effects) models that include both mgcv::s spline term(s) and random effect(s)? I believe the projpred package already supports LMMs/GLMMs/GAMMs - is that correct?

I use R version 4.1.0 on macOS Catalina 10.15.7. Package versions (possibly relevant to my enquiry): cmdstan (2.27.0); cmdstanr (0.4.0); brms (2.16.1); loo (2.4.1); projpred (2.0.2); rstan (2.21.2); rstanarm (2.21.2); StanHeaders (2.21.0-7); mgcv (1.8-36); gamm4 (0.2-6).

Many thanks for your advice!

Best wishes,

Tom