Loo() error: object 'log_lik_beta_binomial2' not found

Hi,

After running my models in brms, I want to compare a model with and without an interaction on the same dataset. However, I get the following error, for which I could not find what it means.

LOO(perc_mod_BB, percdep_mod_BB)
Error in get(log_lik_fun, draws$family$env) :
object ‘log_lik_beta_binomial2’ not found

When I run waic() I get the same error. Any advice on what this means or how this can be resolved would be much appreciated!

These are the models I ran:
#main model
perc_mod_BB ← brm(slidervalue_p_int | trials(100) ~ f_group + f_emotion_r + f_percentage + f_groupf_emotion_rf_percentage + (1 + f_emotion_r | f_ppn), data = comb_n, family = beta_binomial2, warmup = 1000, iter = 6000, chains = 4, cores = 6, stanvars = stanvars, control = list(max_treedepth = 15))

#model with four-way interaction depression
percdep_mod_BB ← brm(slidervalue_p_int |trials(100) ~ f_group + f_emotion_r + f_percentage + c_dep + f_groupf_emotion_rf_percentage*c_dep + (1 + f_emotion_r * f_percentage | f_ppn), data = comb_n, family = beta_binomial2, init_r=0.1, warmup = 1000, iter = 7000, chains = 4, cores = 6, stanvars = stanvars, control = list(max_treedepth = 15))

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.15

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

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

other attached packages:
[1] gdata_2.18.0 car_3.0-4 carData_3.0-2 loo_2.1.0 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
[8] purrr_0.3.3 readr_1.3.1 tidyr_1.0.0 tibble_2.1.3 tidyverse_1.2.1 foreign_0.8-72 brms_2.10.3
[15] Rcpp_1.0.2 rstan_2.19.2 ggplot2_3.2.1 StanHeaders_2.19.0

loaded via a namespace (and not attached):
[1] colorspace_1.4-1 ellipsis_0.3.0 rio_0.5.16 ggridges_0.5.1 rprojroot_1.3-2 rsconnect_0.8.15
[7] markdown_1.1 fs_1.3.1 base64enc_0.1-3 rstudioapi_0.10 remotes_2.1.0 DT_0.9
[13] lubridate_1.7.4 xml2_1.2.2 bridgesampling_0.7-2 shinythemes_1.1.2 pkgload_1.0.2 zeallot_0.1.0
[19] bayesplot_1.7.0 jsonlite_1.6 broom_0.5.2 shiny_1.4.0 compiler_3.6.0 httr_1.4.1
[25] backports_1.1.5 assertthat_0.2.1 Matrix_1.2-17 fastmap_1.0.1 lazyeval_0.2.2 cli_1.1.0
[31] later_1.0.0 htmltools_0.4.0 prettyunits_1.0.2 tools_3.6.0 igraph_1.2.4.1 coda_0.19-3
[37] gtable_0.3.0 glue_1.3.1 reshape2_1.4.3 cellranger_1.1.0 vctrs_0.2.0 nlme_3.1-139
[43] crosstalk_1.0.0 ps_1.3.0 testthat_2.2.1 openxlsx_4.1.0.1 rvest_0.3.4 mime_0.7
[49] miniUI_0.1.1.1 lifecycle_0.1.0 gtools_3.8.1 devtools_2.2.1 zoo_1.8-6 scales_1.0.0
[55] colourpicker_1.0 hms_0.4.2 promises_1.1.0 Brobdingnag_1.2-6 parallel_3.6.0 inline_0.3.15
[61] shinystan_2.5.0 curl_4.2 memoise_1.1.0 gridExtra_2.3 stringi_1.4.3 desc_1.2.0
[67] dygraphs_1.1.1.6 pkgbuild_1.0.6 zip_2.0.2 rlang_0.4.1 pkgconfig_2.0.3 matrixStats_0.55.0
[73] lattice_0.20-38 rstantools_2.0.0 htmlwidgets_1.5.1 processx_3.4.1 tidyselect_0.2.5 plyr_1.8.4
[79] magrittr_1.5 R6_2.4.0 generics_0.0.2 pillar_1.4.2 haven_2.1.0 withr_2.1.2
[85] xts_0.11-2 abind_1.4-5 modelr_0.1.5 crayon_1.3.4 usethis_1.5.1 grid_3.6.0
[91] readxl_1.3.1 data.table_1.12.2 callr_3.3.2 threejs_0.3.1 digest_0.6.22 xtable_1.8-4
[97] httpuv_1.5.2 stats4_3.6.0 munsell_0.5.0 sessioninfo_1.1.1 shinyjs_1.0

You need to define the function mentioned in the error message before using it.

Hi Paul,

Thank you for your quick reply. I am a bit new to using brms/rstan. I have defined the beta_binomial custom family, but I am not sure how to define the log_lik_beta_binomial2 function. Could you maybe give me some insight in this?

Thanks so much.

Take a look at the brms_customfamilies vignette.

Of course, thank you!