Error with loo() for brmsfit object

loo

#1

Dear all,

I am running into an error for which I cannot find any solution on the forums. After fitting the model with brm(), I apply the loo() function, with argument reloo=TRUE. The error message is:

4 problematic observation(s) found.
The model will be refit 4 times.
Fitting model 1 out of 4 (leaving out observation 129)
Start sampling
Error: ldim %in% 2:4 is not TRUE

Does anyone have a suggestion regarding how to solve this error?

This is the output from sessionInfo()

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] brms_2.2.0 ggplot2_2.2.1 Rcpp_0.12.16

loaded via a namespace (and not attached):
[1] mvtnorm_1.0-7 lattice_0.20-35 zoo_1.8-1 gtools_3.5.0
[5] assertthat_0.2.0 digest_0.6.15 mime_0.5 R6_2.2.2
[9] plyr_1.8.4 ggridges_0.5.0 stats4_3.4.4 coda_0.19-1
[13] colourpicker_1.0 pillar_1.2.2 rlang_0.2.0 lazyeval_0.2.1
[17] miniUI_0.1.1 Matrix_1.2-14 DT_0.4 shinythemes_1.1.1
[21] shinyjs_1.0 stringr_1.3.0 htmlwidgets_1.2 loo_2.0.0
[25] igraph_1.2.1 munsell_0.4.3 shiny_1.0.5 compiler_3.4.4
[29] httpuv_1.4.1 rstan_2.17.3 pkgconfig_2.0.1 base64enc_0.1-3
[33] rstantools_1.5.0 htmltools_0.3.6 tibble_1.4.2 gridExtra_2.3
[37] codetools_0.2-15 threejs_0.3.1 matrixStats_0.53.1 dplyr_0.7.4
[41] later_0.7.1 grid_3.4.4 nlme_3.1-137 xtable_1.8-2
[45] gtable_0.2.0 magrittr_1.5 StanHeaders_2.17.2 scales_0.5.0
[49] stringi_1.1.7 reshape2_1.4.3 promises_1.0.1 bindrcpp_0.2.2
[53] dygraphs_1.1.1.4 xts_0.10-2 tools_3.4.4 glue_1.2.0
[57] markdown_0.8 shinystan_2.4.0 crosstalk_1.0.0 rsconnect_0.8.8
[61] abind_1.4-5 parallel_3.4.4 yaml_2.1.18 inline_0.3.14
[65] colorspace_1.3-2 bridgesampling_0.4-0 bayesplot_1.5.0 bindr_0.1.1
[69] Brobdingnag_1.2-5


#2

Looks like a problem with reloo. Do you have a reproducible example for me?


#3

Hi Paul,

You’re blazing fast. Thanks for developing the package and the effort in maintaining it. This would be the MWE that generates the error.

library(brms)

DFmwe <- read.csv(file = "https://vkfcba.ch.files.1drv.com/y4me8Vod8I9MnDbPxumxT0EmxgsKgfW1KTUuPXHjuMj7Aa6eGdNWQ33EET3C9Zz9qwJyVi2-xZKWdkfffUa4C8nl5EG1jLlkKEFCfeN3PFmvXXuGJo_nQYkHkI8zxXQ7qCauqVI-fCbQ81e6DBBUEk5OJtSv2Ko1UUocBe_JQd789IUQPhTjhBkf0l5R0GDBTsU/data-mwe.csv?download&psid=1", header = TRUE)

model1 <- brm(dv | se(sedv) ~ 1 + time + (1 | CLUSTER),
data = DFmwe, family = gaussian(),
prior = c(set_prior("normal(0,2.5)", class = "b"),
set_prior("normal(0,5)", class = "Intercept")),
chains = 3, seed = 5271,
iter = 10000, warmup = 5000)

print(summary(model1), digits = 3)

LOO(model1, reloo = TRUE)

Thank you again!


#4

Should be fixed now in the dev version of brms from github. See https://github.com/paul-buerkner/brms for instructions how to install the dev version.


#5

I can confirm everything runs smoothly now with the dev version from GitHub. Thanks again, Paul!