I would like to get in a data.frame format the means/medians and their credible intervals from brmsMarginalEffects objects like the one below:
library(rstan)
library(brms)
fit <- brm(count ~ log_Age_c + log_Base4_c *
Trt + (1 | patient), data = epilepsy, family =
poisson())
me <- marginal_effects(fit, "log_Base4_c:Trt")
I tried the classical code below but it does not work. I could not find an answer for this in the help document marginal_effects.brmsfit {brms}
df<-as.data.frame(me)
Error in as.data.frame.default(me) :
cannot coerce class ‘"brmsMarginalEffects"’ to
a data.frame
An object of class brmsMarginalEffects, which is a named list with one data.frame per effect containing all information required to generate marginal effects plots.
which implies that your me object should be a list containing a data frame. If that’s the case then either:
In the context of binomial regression, I would appreciate any clarification as to whether the Y values from an object of class brmsMarginalEffects are percentages already.
If not, how could this n be set to 100 to make these Y values percentages in the ME plot or data frame?
For example, given the binomial model from here, to define that the marginal effects must be estimated for n=100 (that is, the Y values must be in percentages), would specifying conditions as: