Last chance! 50% off unlimited learning
Sale ends in
Moment matching for efficient approximate leave-one-out cross-validation
(LOO-CV). See loo_moment_match
for more details.
# S3 method for brmsfit
loo_moment_match(
x,
loo,
k_threshold = 0.7,
newdata = NULL,
resp = NULL,
check = TRUE,
...
)
An object of class brmsfit
.
An object of class loo
originally created from x
.
The threshold at which Pareto 0.7
.
See pareto_k_ids
for more details.
An optional data.frame for which to evaluate predictions. If
NULL
(default), the original data of the model is used.
NA
values within factors are interpreted as if all dummy
variables of this factor are zero. This allows, for instance, to make
predictions of the grand mean when using sum coding.
Optional names of response variables. If specified, predictions are performed only for the specified response variables.
Logical; If TRUE
(the default), some checks
check are performed if the loo
object was generated
from the brmsfit
object passed to argument fit
.
Further arguments passed to the underlying methods.
Additional arguments initially passed to loo
,
for example, newdata
or resp
need to be passed
again to loo_moment_match
in order for the latter
to work correctly.
An updated object of class loo
.
The moment matching algorithm requires samples
of all variables defined in Stan's parameters
block
to be saved. Otherwise loo_moment_match
cannot be computed.
Thus, please set save_all_pars = TRUE
in the call to brm
,
if you are planning to apply loo_moment_match
to your models.
Paananen, T., Piironen, J., Buerkner, P.-C., Vehtari, A. (2020). Implicitly Adaptive Importance Sampling. preprint arXiv:1906.08850
# NOT RUN {
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
data = epilepsy, family = poisson(),
save_all_pars = TRUE)
# throws warning about some pareto k estimates being too high
(loo1 <- loo(fit1))
(mmloo1 <- loo_moment_match(fit1, loo = loo1))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab