Custom gaussian hurdle family not quite working in brms

I can relate, getting custom_families to work is tricky. I cannot say if your family does what you want, but I did spot a reason why the predictions don’t work as expected.
In the posterior_predict_hurdle_gaussian method, replace [ ,1] with [, i]:

posterior_predict_hurdle_gaussian <- function(i, prep, ...) {
 theta <- prep$dpars$hu[, i]
 mu <- prep$dpars$mu[, i]
 sigma <- prep$dpars$sigma
 ndraws <- prep$nsamples
 
 hu <- runif(ndraws, 0, 1)
 ifelse(hu < theta, 0, rnorm(ndraws, mu, sigma))
}

with this, pp_check looks good for me.

3 Likes