loo_validation.bgmfit {bsitar} | R Documentation |
Perform leave-one-out (loo) cross-validation
Description
The loo_validation() is a wrapper around the
brms::loo()
function to perform approximate leave-one-out
cross-validation based on the posterior likelihood. See brms::loo()
for
more details.
Usage
## S3 method for class 'bgmfit'
loo_validation(
model,
compare = TRUE,
resp = NULL,
pointwise = FALSE,
moment_match = FALSE,
reloo = FALSE,
k_threshold = 0.7,
save_psis = FALSE,
moment_match_args = list(),
reloo_args = list(),
model_names = NULL,
ndraws = NULL,
draw_ids = NULL,
cores = 1,
deriv_model = NULL,
verbose = FALSE,
dummy_to_factor = NULL,
expose_function = FALSE,
usesavedfuns = NULL,
clearenvfuns = NULL,
envir = NULL,
...
)
loo_validation(model, ...)
Arguments
model |
An object of class |
compare |
A flag indicating if the information criteria of the models
should be compared to each other via |
resp |
Optional names of response variables. If specified, predictions are performed only for the specified response variables. |
pointwise |
A flag indicating whether to compute the full
log-likelihood matrix at once or separately for each observation.
The latter approach is usually considerably slower but
requires much less working memory. Accordingly, if one runs
into memory issues, |
moment_match |
A logical argument to indicate whether
|
reloo |
A logical argument to indicate whether |
k_threshold |
The threshold at which pareto |
save_psis |
Should the |
moment_match_args |
An optional |
reloo_args |
An optional |
model_names |
If |
ndraws |
A positive integer indicating the number of posterior draws to
be used in estimation. If |
draw_ids |
An integer indicating the specific posterior draw(s)
to be used in estimation (default |
cores |
Number of cores to be used when running the parallel
computations (if |
deriv_model |
A logical to specify whether to estimate velocity curve
from the derivative function, or the differentiation of the distance curve.
The argument |
verbose |
An optional argument (logical, default |
dummy_to_factor |
A named list (default |
expose_function |
An optional logical argument to indicate whether to
expose Stan functions (default |
usesavedfuns |
A logical (default |
clearenvfuns |
A logical to indicate whether to clear the exposed
function from the environment ( |
envir |
Environment used for function evaluation. The default is
|
... |
Additional arguments passed to the |
Details
See loo::loo_compare()
for details on model comparisons. For
bgmfit
objects, LOO
is an alias of loo
. Use method
brms::add_criterion()
to store information criteria in the fitted model
object for later usage.
Value
If only one model object is provided, then an object of class
loo
is returned. If multiple objects are provided, an object of
class loolist
.
Author(s)
Satpal Sandhu satpal.sandhu@bristol.ac.uk
See Also
Examples
# Fit Bayesian SITAR model
# To avoid mode estimation which takes time, the Bayesian SITAR model fit to
# the 'berkeley_exdata' has been saved as an example fit ('berkeley_exfit').
# See 'bsitar' function for details on 'berkeley_exdata' and 'berkeley_exfit'.
# Check and confirm whether model fit object 'berkeley_exfit' exists
berkeley_exfit <- getNsObject(berkeley_exfit)
model <- berkeley_exfit
loo_validation(model, cores = 1)