stan-dev / projpred

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

Fix incompatibility with R < 4.2.0 #427

Closed fweber144 closed 1 year ago

fweber144 commented 1 year ago

Fixes #423. The special case requiring except = NULL in simplify2array() is nterms_max = 0:

data("df_gaussian", package = "projpred")
df_gaussian <- df_gaussian[1:29, ]
dat <- data.frame(y = df_gaussian$y, df_gaussian$x)
library(rstanarm)
rfit <- stan_glm(y ~ X1 + X2 + X3 + X4 + X5,
                 data = dat,
                 chains = 1,
                 iter = 500,
                 seed = 1140350788,
                 refresh = 0)

### If fixed version is not installed:
devtools::load_all(".")
###
### If fixed version is installed:
# library(projpred)
###

cvvs <- cv_varsel(rfit,
                  method = "forward",
                  cv_method = "kfold",
                  K = 2,
                  nclusters = 3,
                  nclusters_pred = 5,
                  nterms_max = 0,
                  seed = 46782345)
l-gorman commented 1 year ago

@fweber144, can confirm that this works for the reprex!

fweber144 commented 1 year ago

Thank you very much for also testing with your reprex :)