Problem running diagnostics for beta binomial distribution

Hi all, I used the code for running diagnostics on my beta-binomial model from this vignette.

See this link for vignette


log_lik_beta_binomial2 <- function(i, prep) {
  mu <- prep$dpars$mu[, i]
  phi <- prep$dpars$phi
  trials <- prep$data$vint1[i]
  y <- prep$data$Y[i]
  beta_binomial2_lpmf(y, mu, phi, trials)
}

The model converges fine. However, I get the following error when I try to run any diagnostics.

"argument “prep” is missing, with no default"

What seems to be the problem here?

Hey @Afreen_Khalid, welcome to the Stan forums. Do you mean that you get errors when running exactly the code in the vignette or that you get errors when trying to adapt the code from the vignette to your specific model? If the latter, can you share the rest of your code?

Hi!

I solved this problem. I just needed to run library(simulations) to simulate ‘prep’

1 Like