Skip to contents

brms's loo_epred(), loo_linpred(), loo_predict(), loo_predictive_interval(), loo_R2(), loo_model_weights(), kfold(), reloo(), loo_moment_match() and loo_subsample(). Each weights or refits posterior draws, and a frmtmb_fit has one parameter vector, so on a fit each refuses and says what to do instead. The first six are computed on draws by the frmtmb.sample package, which registers its methods on these generics: sample with frmtmb.sample::frm_sample() first. The last four refit the sampler or approximate loo() for data too large to evaluate, which neither package does; frm_bootstrap() resamples a fit, and AIC() compares fits.

Usage

loo_epred(object, ...)

loo_linpred(object, ...)

loo_predict(object, ...)

loo_predictive_interval(object, ...)

loo_R2(object, ...)

loo_model_weights(x, ...)

kfold(x, ...)

reloo(x, ...)

loo_moment_match(x, ...)

loo_subsample(x, ...)

# S3 method for class 'frmtmb_fit'
loo_epred(object, ...)

# S3 method for class 'frmtmb_fit'
loo_linpred(object, ...)

# S3 method for class 'frmtmb_fit'
loo_predict(object, ...)

# S3 method for class 'frmtmb_fit'
loo_predictive_interval(object, ...)

# S3 method for class 'frmtmb_fit'
loo_R2(object, ...)

# S3 method for class 'frmtmb_fit'
loo_model_weights(x, ...)

# S3 method for class 'frmtmb_fit'
kfold(x, ...)

# S3 method for class 'frmtmb_fit'
reloo(x, ...)

# S3 method for class 'frmtmb_fit'
loo_moment_match(x, ...)

# S3 method for class 'frmtmb_fit'
loo_subsample(x, ...)

Arguments

object, x

A frmtmb_fit, or (with frmtmb.sample loaded) draws.

...

Passed to methods.

Value

These methods signal an error on a maximum-likelihood fit.

Examples

set.seed(1)
dd <- data.frame(x = rnorm(40))
dd$y <- rnorm(40, 1 + 0.5 * dd$x, 1)
fit <- frm(bf(y ~ x), family = gaussian(), data = dd)
try(loo_predict(fit))
#> Error : loo_predict() weights posterior draws by their leave-one-out importance ratios, and this is a maximum-likelihood fit with one parameter vector. Sample first: loo_predict(frmtmb.sample::frm_sample(fit))
try(kfold(fit))
#> Error : kfold() refits the sampler on modified data, and neither frmtmb nor frmtmb.sample does that, on a fit or on draws. frm_bootstrap() resamples a maximum-likelihood fit, and AIC() compares fits
try(loo_subsample(fit))
#> Error : loo_subsample() approximates loo() on a subsample of the observations, and neither frmtmb nor frmtmb.sample builds it, on a fit or on draws. loo(frmtmb.sample::frm_sample(fit)) computes the full estimate; AIC() compares fits