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