I have a glmm bernoulli brmsfit object. Calling projpred::varsel or cv_varsel gives an error message and no results.
The model code is:
bprior ← c(prior(student_t(3, 0, 2.5), class = ‘b’))
fit1.brmsfit ←
brm(Hypoglycemic60 ~
AgeClass +
Sex +
BMIClass +
ASA2Class +
# CaseYear +
Emergency +
AdmissionType +
AnesthesiaIntervalClass +
BypassDuration +
ElixCount +
IntraopVasoplegia +
IntraopNutrition +
IntraopHypoglycemic +
IntraopHypotensive +
IntraopInotropeVasopressor +
IntraopBetaBlocker +
EBLClass +
PRBCClass +
(1 | MPOGInstitutionID)
,
data = tmp.df,
family = ‘bernoulli’,
prior = bprior,
chains = 4,
seed = 9876,
iter = 2000,
control = list(
max_treedepth = 40)
)
fit1.brmsfit
Family: bernoulli
Links: mu = logit
Formula: Hypoglycemic60 ~ AgeClass + Sex + BMIClass + ASA2Class + Emergency + AdmissionType + AnesthesiaIntervalClass + BypassDuration + ElixCount + IntraopVasoplegia + IntraopHypoglycemic + IntraopHypotensive + IntraopInotropeVasopressor + IntraopBetaBlocker + EBLClass + PRBCClass + (1 | MPOGInstitutionID)
Data: tmp.df (Number of observations: 72610)
Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup draws = 4000
Group-Level Effects:
~MPOGInstitutionID (Number of levels: 29)
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sd(Intercept) 0.63 0.14 0.40 0.95 1.00 1682 2464
The model fitting is OK (Rhat, ESS).
There are a few slightly high k estimates.
Computed from 4000 by 72610 log-likelihood matrix
Estimate SE
elpd_loo -1420.7 80.8
p_loo 44.1 3.2
looic 2841.4 161.6
Monte Carlo SE of elpd_loo is 0.1.
Pareto k diagnostic values:
Count Pct. Min. n_eff
(-Inf, 0.5] (good) 72602 100.0% 1328
(0.5, 0.7] (ok) 8 0.0% 3147
(0.7, 1] (bad) 0 0.0%
(1, Inf) (very bad) 0 0.0%
All Pareto k estimates are ok (k < 0.7).
See help(‘pareto-k-diagnostic’) for details.
The data frame tmp.df has no missing values.
The versions are brms 2.16.3, rstan 2.21.3 and projpred 2.0.2.
fit1.vsel ← varsel(fit1.brmsfit)
Error in model.frame.default(data = data, weights = weights, drop.unused.levels = TRUE, :
object is not a matrix
fit1.vsel ← cv_varsel(fit1.brmsfit)
Warning in cv_varsel.refmodel(refmodel, …) :
K provided, but cv_method is LOO.
Warning: Some Pareto k diagnostic values are slightly high. See help(‘pareto-k-diagnostic’) for details.
[1] “Computing LOOs…”
| | 0%Error in model.frame.default(data = data, weights = weights, drop.unused.levels = TRUE, :
object is not a matrix
I have searched and haven’t found an explanation for this error message.
Nathan
sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] projpred_2.0.2 mice_3.14.0 rstan_2.21.3 StanHeaders_2.21.0-7 loo_2.4.1 Hmisc_4.6-0 Formula_1.2-4 lattice_0.20-44
[9] skimr_2.1.3 readit_1.0.0 brms_2.16.3 Rcpp_1.0.7 stevemisc_1.3.0 broom.mixed_0.2.7 broom_0.7.10 sjlabelled_1.1.8
[17] sjPlot_2.8.10 lme4_1.1-27.1 Matrix_1.3-4 Epi_2.44 cobalt_4.3.1 MatchIt_4.3.2 logistf_1.24 sjmisc_2.8.9
[25] collapse_1.6.5 car_3.0-12 carData_3.0-4 coin_1.4-2 survival_3.2-13 arsenal_3.6.3 tableone_0.13.0 tables_0.9.6
[33] lubridate_1.8.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4 readr_2.1.1 tidyr_1.1.4 tibble_3.1.6
[41] ggplot2_3.3.5 tidyverse_1.3.1 magrittr_2.0.1 tinytex_0.36 rmarkdown_2.11 knitr_1.37