Description Usage Arguments Value See Also Examples

Compute and evaluate predictions after performing K-fold
cross-validation via `kfold`

.

1 | ```
kfold_predict(x, method = c("predict", "fitted"), resp = NULL, ...)
``` |

`x` |
Object of class |

`method` |
The method used to make predictions. Either |

`resp` |
Optional names of response variables. If specified, predictions are performed only for the specified response variables. |

`...` |
Further arguments passed to |

A `list`

with two slots named `'y'`

and `'yrep'`

.
Slot `y`

contains the vector of observed responses.
Slot `yrep`

contains the matrix of predicted responses,
with rows being posterior draws and columns being observations.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
## Not run:
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)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.