I recently got a new computer and the vignette on beta-binomial models using brms now doesn’t work. The beta-binomial models run fine, but in post-processing them, it seems like the stan functions are unrecognizable.

```
# load data
data("cbpp", package = "lme4")
head(cbpp)
# define custom family
beta_binomial2 <- custom_family(
"beta_binomial2", dpars = c("mu", "phi"),
links = c("logit", "log"), lb = c(NA, 0),
type = "int", vars = "vint1[n]"
)
stan_funs <- "
real beta_binomial2_lpmf(int y, real mu, real phi, int T) {
return beta_binomial_lpmf(y | T, mu * phi, (1 - mu) * phi);
}
int beta_binomial2_rng(real mu, real phi, int T) {
return beta_binomial_rng(T, mu * phi, (1 - mu) * phi);
}
"
stanvars <- stanvar(scode = stan_funs, block = "functions")
# run model
fit2 <- brm(
incidence | vint(size) ~ period + (1|herd), data = cbpp,
family = beta_binomial2, stanvars = stanvars
)
# post-processing
expose_functions(fit2, vectorize = TRUE)
log_lik_beta_binomial2 <- function(i, prep) {
mu <- brms::get_dpar(prep, "mu", i = i)
phi <- brms::get_dpar(prep, "phi", i = i)
trials <- prep$data$vint1[i]
y <- prep$data$Y[i]
beta_binomial2_lpmf(y, mu, phi, trials)
}
loo(fit2)
```

The last line produces this error:

```
> loo(fit2)
Error in beta_binomial2_lpmf(y, mu, phi, trials) :
could not find function "beta_binomial2_lpmf"
```

Here are my specs:

R version 4.1.1 (2021-08-10)

Platform: x86_64-apple-darwin17.0 (64-bit)

Running under: macOS Big Sur 11.3.1

rstan_2.26.4

StanHeaders_2.26.4

brms_2.16.2