Closed bgoodri closed 5 years ago
It seems that just adding "betareg"
as one of the classes of the stanreg object avoids this error:
example(stan_betareg, ask = FALSE)
fake_dat$group <- rep(1:10, each = 20)
fit <- stan_glmer(y ~ x + (1 | group), data = fake_dat, family = mgcv::betar,
prior_aux = exponential(2))
class(fit) <- c(class(fit), "betareg")
posterior_predict(fit) # No error
Some internal stuff uses inherits(object, "betareg")
sometimes, which works for stan_betareg()
but not for stan_glm(family = mgcv::betar)
. I don't know if doing this is totally safe though as there many be unintended consequences when applying other methods to the object.
Also, I agree about using standalone GQ if possible. Would take a decent bit of work probably.
Summary:
posterior_predict()
fails for models estimated withfamily = mgcv::betar
. It does not find theeta
element of the list.Description:
https://discourse.mc-stan.org/t/rstanarm-mgcv-betar-family/2947/5?u=bgoodri
We should perhaps think about using the standalone generated quantities feature that is (sort of) in rstan for all the
posterior_linpred
andposterior_predict
stuff.