I'm trying to compute a beta-binomial model using the R package brms. However, beta-binomial distributions are not native to this package, so I'm trying to use the custom_family argument, to create the family myself. I've found a vignette for the purpose: https://cran.r-project.org/web/packages/brms/vignettes/brms_customfamilies.html

However, after trying the code in various ways, I get the following syntax error:

"SYNTAX ERROR, MESSAGE(S) FROM PARSER:

No matches for:

beta_binomial2_lpmf(int, real, real, int)

Function beta_binomial2_lpmf not found.

error in 'model445074614f85_file44502d6f3' at line 71, column 65

-------------------------------------------------

69: if (!prior_only) {

70: for (n in 1:N) {

71: target += beta_binomial2_lpmf(Y[n] | mu[n], phi, trials[n]);

^

72: }

-------------------------------------------------

Error in stanc(model_code = paste(program, collapse = "\n"), model_name = model_cppname, :

failed to parse Stan model 'file44502d6f3' due to the above error.

SYNTAX ERROR, MESSAGE(S) FROM PARSER:

No matches for:

beta_binomial2_lpmf(int, real, real, int)

Function beta_binomial2_lpmf not found.

error in 'model44506c6352ff_file44502d6f3' at line 71, column 65

-------------------------------------------------

69: if (!prior_only) {

70: for (n in 1:N) {

71: target += beta_binomial2_lpmf(Y[n] | mu[n], phi, trials[n]);

^

72: }

-------------------------------------------------

Error in stanc(model_code = paste(program, collapse = "\n"), model_name = model_cppname, :

failed to parse Stan model 'file44502d6f3' due to the above error."

The code I'm running when I get this error is as follows:

"log_lik_beta_binomial2

Similar questions and discussions