reloo.brmsfit {brms} | R Documentation |
Compute exact cross-validation for problematic observations
Description
Compute exact cross-validation for problematic observations for which approximate leave-one-out cross-validation may return incorrect results. Models for problematic observations can be run in parallel using the future package.
Usage
## S3 method for class 'brmsfit'
reloo(
x,
loo,
k_threshold = 0.7,
newdata = NULL,
resp = NULL,
check = TRUE,
recompile = NULL,
future_args = list(),
...
)
## S3 method for class 'loo'
reloo(x, fit, ...)
reloo(x, ...)
Arguments
x |
An R object of class |
loo |
An R object of class |
k_threshold |
The threshold at which Pareto |
newdata |
An optional data.frame for which to evaluate predictions. If
|
resp |
Optional names of response variables. If specified, predictions are performed only for the specified response variables. |
check |
Logical; If |
recompile |
Logical, indicating whether the Stan model should be
recompiled. This may be necessary if you are running |
future_args |
A list of further arguments passed to
|
... |
Further arguments passed to
|
fit |
An R object of class |
Details
Warnings about Pareto estimates indicate observations
for which the approximation to LOO is problematic (this is described in
detail in Vehtari, Gelman, and Gabry (2017) and the
loo package documentation).
If there are
observations with
estimates above
k_threshold
, then reloo
will refit the original model
times, each time leaving out one of the
problematic observations. The pointwise contributions of these observations
to the total ELPD are then computed directly and substituted for the
previous estimates from these
observations that are stored in the
original
loo
object.
Value
An object of the class loo
.
See Also
Examples
## Not run:
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
data = epilepsy, family = poisson())
# throws warning about some pareto k estimates being too high
(loo1 <- loo(fit1))
(reloo1 <- reloo(fit1, loo = loo1, chains = 1))
## End(Not run)