Bayesian model comparisons

Bayesian Regression Modeling with rstanarm

Jake Thompson

Psychometrician, ATLAS, University of Kansas

The loo package

  • LOO = leave-one-out
    • Approximated cross validation
    • ?loo-package
    • Using loo for model comparisons
Bayesian Regression Modeling with rstanarm

Using loo on a single model

library(rstanarm)
library(loo)
stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq)

loo(stan_model)
Computed from 4000 by 434 log-likelihood matrix

         Estimate   SE
elpd_loo  -1878.5 14.5
p_loo         2.9  0.3
looic      3757.1 29.0
 ------
Monte Carlo SE of elpd_loo is 0.0.

All Pareto k estimates are good (k < 0.5).
See help('pareto-k-diagnostic') for details.
Bayesian Regression Modeling with rstanarm

Model comparisons with loo

model_1pred <- stan_glm(kid_score ~ mom_iq, data = kidiq)
model_2pred <- stan_glm(kid_score ~ mom_iq * mom_hs, data = kidiq)

loo_1pred <- loo(model_1pred)
loo_2pred <- loo(model_2pred)

compare(loo_1pred, loo_2pred)
elpd_diff        se 
      6.1       3.9
Bayesian Regression Modeling with rstanarm

Model comparisons with loo

compare(loo_1pred, loo_2pred)
elpd_diff        se 
      6.1       3.9
  • Positive = prefer second model
  • Negative = prefer first model
  • Significant difference?
    • Absolute value of difference relative to standard error
Bayesian Regression Modeling with rstanarm

Let's practice!

Bayesian Regression Modeling with rstanarm

Preparing Video For Download...