Learn R Programming

blmeco (version 1.0)

loo.cv: Bayesian leave-one-out cross-validation

Description

Bayesian leave-one-out cross-validation based on the log pointwise predictive density

Usage

loo.cv(mod, nsim = 100, bias.corr = FALSE)

Arguments

mod
an object obtained by the functions lm or glm
nsim
number of Monte Carlo simulations used to describe the posterior distributions. Computing time is large!
bias.corr
The leave-one-out cross-validation underestimates predictive fit because each prediction is conditioned n-1 data points. For large n this bias is negligible. For small n, a bias correction is recommended.

Value

  • LOO.CVleave-one-out cross-validation estimate of out-of-sample predictive fit, (log pointwise predictive density)
  • bias.corrected.LOO.CVbias corrected leave-one-out cross-validation estimate of out-of-sample predictive fit, (log pointwise predictive density)
  • minus2times_lppd-2*LOO.CV, transformed LOO.CV to scale of deviance
  • est.peffestimate for the number of effective parameters

Details

For details see Gelman et al. (2014) p 175

References

Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A and Rubin DB (2014) Bayesian Data Analysis, Third edn. CRC Press.

See Also

ocv

Examples

Run this code
x <- runif(20)
y <- 2+0.5*x+rnorm(20, 0, 1)
mod <- lm(y~x)
loo.cv(mod, bias.corr=TRUE)  # increase nsim!!

Run the code above in your browser using DataLab