if (FALSE) {
fit <- brm(count ~ zBase * Trt + (1|patient),
data = epilepsy, family = poisson())
# perform k-fold cross validation
(kf <- kfold(fit, save_fits = TRUE, chains = 1))
# define a loss function
rmse <- function(y, yrep) {
yrep_mean <- colMeans(yrep)
sqrt(mean((yrep_mean - y)^2))
}
# predict responses and evaluate the loss
kfp <- kfold_predict(kf)
rmse(y = kfp$y, yrep = kfp$yrep)
}
Run the code above in your browser using DataLab