# NOT RUN {
## fit a model
fit <- brm(time | cens(censored) ~ age + sex + (1 + age || patient),
data = kidney, family = "exponential", inits = "0")
## predicted responses
pp <- posterior_predict(fit)
str(pp)
## predicted responses excluding the group-level effect of age
pp <- posterior_predict(fit, re_formula = ~ (1 | patient))
str(pp)
## predicted responses of patient 1 for new data
newdata <- data.frame(
sex = factor(c("male", "female")),
age = c(20, 50),
patient = c(1, 1)
)
pp <- posterior_predict(fit, newdata = newdata)
str(pp)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab