stan-dev / projpred

Projection predictive variable selection
https://mc-stan.org/projpred/
Other
110 stars 26 forks source link

Projpred::cv_varsel() returning “Not enough (non-NA) data to do anything meaningful” error #239

Open tzuffa opened 2 years ago

tzuffa commented 2 years ago

Hello,

When attempting to perform projection predictive variable selection (projpred::cv_varsel()) on a model that includes both an s() spline term(s) and a random effect(s) 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

I have tried installing the latest development version of the projpred package from GitHub to resolve the issue, but the problem persists. I have also tried to rerun the model and variable selection on a Linux-based server with R (4.1.0) and RStudio Server to test whether the problem is not specific to my local Mac/system, but the process stopped with the same error.

I am attaching two small datasets (one with a Gaussian and the other with a binary response) and two reproducible examples that give the error.

gaussian_data <- read.csv("~/ ..... /gaussian_data.csv") # define pathway

fit1 <- brm(y ~ s(x) + (1|group) ,data = gaussian_data ,cores = 4 ,backend = "cmdstanr" ,control = list( adapt_delta = 0.99 ,max_treedepth = 15) ,seed = 123) ref_fit1 <- get_refmodel(fit1) variable_selection_fit1 <- cv_varsel(ref_fit1)

binary_data <- read.csv("~/ ..... /binary_data.csv") # define pathway

fit2 <- brm(y ~ s(x) + (1|group) ,data = binary_data ,family = bernoulli(link = "logit") ,cores = 4 ,backend = "cmdstanr" ,control = list( adapt_delta = 0.99 ,max_treedepth = 15) ,seed = 123) ref_fit2 <- get_refmodel(fit2) variable_selection_fit2 <- cv_varsel(ref_fit2)

Many thanks for looking at this.

Best wishes,

Tom

gaussian_data.csv binary_data.csv

fweber144 commented 2 years ago

@AlejandroCatalina: Since you are the expert for additive models, could you take a look at this? I guess this hasn't been resolved yet in the most recent CRAN release.