Hello!
I am trying a BRM model for the first time, with 1 level: this is the code so far:
library(brms)
?brm
model1<-brm(Y~X1+X2+X3+X4+X5+X6+(X1+X2+X3+X3+X4+X5+X5| Level_Variable),data=Mydataset,family = categorical(link = "logit", refcat = NULL),control = list(max_treedepth = 15, adapt_delta=0.9),warmup = 2500,iter = 10000, cores = getOption("mc.cores", 8), thin = 2, chains = 8).
It runs extremely slow, 12hrs passed and still this is what i see:
Now I am aware I didn’t put any prior, could that be the issue?
model.1.1.prior<-get_prior(Y~X1+X2+X3+X4+X5+X6+(X1+X2+X3+X3+X4+X5+X5| Level_Variable),data=Mydataset,family = categorical(link = "logit", refcat = NULL)) #i am a bit confused at the output here; I haven't quite grasped how to use the information per se to get a proper prior.
#model.2.1.prior<-get_prior(Y~X1+X2+X3+X4+X5+X6+(X1+X2+X3+X3+X4+X5+X5| Level_Variable),data=Mydataset,family = sratio("logit")) .....the Y variable is ordinal but this doesn't work; I haven't investigated it more as of yet, due to the immense running hours.
SAMPLING FOR MODEL '662d5ea6d2b4caabd477e8a1873a1a11' NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can't start sampling from this initial value.
model1.1<-brm(Y~X1+X2+X3+X4+X5+X6+(X1+X2+X3+X3+X4+X5+X5| Level_Variable),data=Mydataset,family = categorical(link = "logit", refcat = NULL),prior = model.1.1.prior,control = list(max_treedepth = 15),warmup = 2500, iter = 10000, cores = getOption("mc.cores", 8),thin = 2, chains=8)
When I stopped the code after so many hours I got this message:
Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'-E' not found
>head(Mydataset)
X1 X2 X3 Level_Variable X4 Y X5 X6
3 51 2 2 17 6000 1 45 24
6 23 1 2 3 3000 4 24 15
7 50 1 4 14 10500 2 38 25
14 55 2 2 15 2800 4 43 42
18 59 1 4 3 3600 3 30 18
20 20 2 3 18 5000 4 30 23
Y variable is a category taking values from 1 to 7. It could also be considered ordinal (which is a second step). However, I am guessing that the X4, X5, and X6 variables ( X5 max= 107) could be the case that it creates too many categories for each variable? The the issue is with the LVL_variable that has 21 levels?
apply(Mydataset,2,class)
X1 X2 X3 Level_Variable Y X5
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric"
X6
"numeric"
X1, X5, X4, X6 can be continuous (i.e Age, Payments), then X2, X3, Y are categoricals (1 to 4 i.e). The reason it takes too long is that probably I am definying something wrong. Maybe that model cannot be run with this technique? Any tips would be greatly appreciated.
`sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] brms_2.16.1 Rcpp_1.0.7
loaded via a namespace (and not attached):
[1] nlme_3.1-152 matrixStats_0.61.0 xts_0.12.1 threejs_0.3.3 rstan_2.21.2
[6] tensorA_0.36.2 tools_4.1.1 backports_1.3.0 DT_0.19 utf8_1.2.2
[11] R6_2.5.1 DBI_1.1.1 mgcv_1.8-36 projpred_2.0.2 colorspace_2.0-2
[16] withr_2.4.2 tidyselect_1.1.1 gridExtra_2.3 prettyunits_1.1.1 processx_3.5.2
[21] Brobdingnag_1.2-6 curl_4.3.2 compiler_4.1.1 cli_3.1.0 shinyjs_2.0.0
[26] colourpicker_1.1.1 posterior_1.1.0 scales_1.1.1 dygraphs_1.1.1.6 checkmate_2.0.0
[31] mvtnorm_1.1-3 ggridges_0.5.3 callr_3.7.0 stringr_1.4.0 digest_0.6.28
[36] StanHeaders_2.21.0-7 minqa_1.2.4 base64enc_0.1-3 pkgconfig_2.0.3 htmltools_0.5.2
[41] lme4_1.1-27.1 fastmap_1.1.0 htmlwidgets_1.5.4 rlang_0.4.12 rstudioapi_0.13
[46] shiny_1.7.1 farver_2.1.0 generics_0.1.1 zoo_1.8-9 jsonlite_1.7.2
[51] gtools_3.9.2 crosstalk_1.1.1 dplyr_1.0.7 distributional_0.2.2 inline_0.3.19
[56] magrittr_2.0.1 loo_2.4.1 bayesplot_1.8.1 Matrix_1.3-4 munsell_0.5.0
[61] fansi_0.5.0 abind_1.4-5 lifecycle_1.0.1 stringi_1.7.5 MASS_7.3-54
[66] pkgbuild_1.2.0 plyr_1.8.6 grid_4.1.1 parallel_4.1.1 promises_1.2.0.1
[71] crayon_1.4.1 miniUI_0.1.1.1 lattice_0.20-44 splines_4.1.1 ps_1.6.0
[76] pillar_1.6.4 igraph_1.2.7 boot_1.3-28 markdown_1.1 shinystan_2.5.0
[81] reshape2_1.4.4 codetools_0.2-18 stats4_4.1.1 rstantools_2.1.1 glue_1.4.2
[86] V8_3.4.2 RcppParallel_5.1.4 vctrs_0.3.8 nloptr_1.2.2.2 httpuv_1.6.3
[91] gtable_0.3.0 purrr_0.3.4 assertthat_0.2.1 ggplot2_3.3.5 xfun_0.27
[96] mime_0.12 xtable_1.8-4 coda_0.19-4 later_1.3.0 rsconnect_0.8.24
[101] tibble_3.1.5 shinythemes_1.2.0 tinytex_0.34 gamm4_0.2-6 ellipsis_0.3.2
[106] bridgesampling_1.1-2`