Skip to content

Re-add print.compare.loo(simplify=) #366

Description

@mattansb

Previous version of {loo} had the option to show full ELPD info for the compared models, but this is now lost:

library(loo)
#> Warning: package 'loo' was built under R version 4.5.3
#> This is loo version 2.9.0.9000
#> - Online documentation and vignettes at mc-stan.org/loo
#> - As of v2.0.0 loo defaults to 1 core but we recommend using as many as possible. Use the 'cores' argument or set options(mc.cores = NUM_CORES) for an entire session.
#> - Windows 10 users: loo may be very slow if 'mc.cores' is set in your .Rprofile file (see https://github.com/stan-dev/loo/issues/94).
LL <- example_loglik_array()
loo1 <- loo(LL)     # should be worst model when compared
loo2 <- loo(LL + 1) # should be second best model when compared
loo3 <- loo(LL + 2) # should be best model when compared

comp <- loo_compare(loo1, loo2, loo3)

All the info is there, but not shown in print:

names(comp)
#>  [1] "model"       "elpd_diff"   "se_diff"     "p_worse"     "diag_diff"  
#>  [6] "diag_elpd"   "elpd_loo"    "se_elpd_loo" "p_loo"       "se_p_loo"   
#> [11] "looic"       "se_looic"

print(comp, simplify = FALSE)
#>   model elpd_diff se_diff p_worse diag_diff diag_elpd
#>  model3       0.0     0.0      NA                    
#>  model2     -32.0     0.0    1.00   N < 100          
#>  model1     -64.0     0.0    1.00   N < 100
#> 
#> Diagnostic flags present.
#> See ?`loo-glossary` (sections `diag_diff` and `diag_elpd`)
#> or https://mc-stan.org/loo/reference/loo-glossary.html.

Created on 2026-06-06 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions