Extract and return the model summary using cmdstanr::summary()
.
Arguments
- model_output
List. Model output generated by
run_model()
.- variables
Character vector. Specific variables (e.g.,
"strata_raw[1]"
) or variable types (e.g.,"strata_raw"
) for which to calculate metrics. IfNULL
(default) all variables are returned.
See also
Other model assessment functions:
get_convergence()
,
get_model_vars()
Examples
# Temporarily suppress convergence warning for legibility
# "The ESS has been capped to avoid unstable estimates."
opts <- options(warn = -1)
# Using the example model for Pacific Wrens
get_summary(pacific_wren_model)
#> # A tibble: 10,495 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 lp__ -1.38e+4 -1.38e+4 39.1 37.0 -1.38e+4 -1.37e+4 1.04 25.7
#> 2 strata_raw[… -9.02e-1 -8.62e-1 0.481 0.430 -1.58e+0 -3.39e-1 1.01 61.6
#> 3 strata_raw[… -2.09e-1 -2.26e-1 0.173 0.199 -4.08e-1 1.03e-1 0.985 29.4
#> 4 strata_raw[… -1.06e-1 -3.28e-2 0.499 0.433 -8.51e-1 6.60e-1 1.02 35.8
#> 5 strata_raw[… 1.57e+0 1.60e+0 0.322 0.308 9.96e-1 2.03e+0 1.15 50.6
#> 6 strata_raw[… -1.93e-1 -2.18e-1 0.243 0.266 -5.67e-1 1.71e-1 1.03 30.0
#> 7 strata_raw[… 1.47e+0 1.32e+0 0.514 0.430 8.40e-1 2.37e+0 1.07 31.6
#> 8 strata_raw[… -1.18e+0 -1.23e+0 0.561 0.475 -1.98e+0 -2.01e-1 0.992 36.2
#> 9 strata_raw[… 1.87e+0 1.85e+0 0.399 0.417 1.18e+0 2.48e+0 1.04 28.4
#> 10 strata_raw[… -1.00e+0 -9.39e-1 0.350 0.348 -1.44e+0 -5.31e-1 0.973 53.0
#> # ℹ 10,485 more rows
#> # ℹ 1 more variable: ess_tail <dbl>
get_summary(pacific_wren_model, variables = "strata_raw")
#> # A tibble: 19 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 strata_ra… -0.902 -0.862 0.481 0.430 -1.58 -0.339 1.01 61.6 37.7
#> 2 strata_ra… -0.209 -0.226 0.173 0.199 -0.408 0.103 0.985 29.4 49.6
#> 3 strata_ra… -0.106 -0.0328 0.499 0.433 -0.851 0.660 1.02 35.8 49.6
#> 4 strata_ra… 1.57 1.60 0.322 0.308 0.996 2.03 1.15 50.6 56.9
#> 5 strata_ra… -0.193 -0.218 0.243 0.266 -0.567 0.171 1.03 30.0 56.9
#> 6 strata_ra… 1.47 1.32 0.514 0.430 0.840 2.37 1.07 31.6 22.4
#> 7 strata_ra… -1.18 -1.23 0.561 0.475 -1.98 -0.201 0.992 36.2 49.6
#> 8 strata_ra… 1.87 1.85 0.399 0.417 1.18 2.48 1.04 28.4 49.6
#> 9 strata_ra… -1.00 -0.939 0.350 0.348 -1.44 -0.531 0.973 53.0 17.3
#> 10 strata_ra… -0.289 -0.326 0.307 0.299 -0.747 0.228 0.970 64.1 56.9
#> 11 strata_ra… -0.209 -0.184 0.236 0.234 -0.571 0.154 1.07 25.2 56.9
#> 12 strata_ra… 0.243 0.153 0.271 0.257 -0.0613 0.700 0.994 64.1 56.9
#> 13 strata_ra… -0.717 -0.637 0.261 0.207 -1.11 -0.418 1.02 46.5 18.9
#> 14 strata_ra… -1.00 -1.02 0.358 0.358 -1.51 -0.368 1.11 64.1 49.6
#> 15 strata_ra… 0.522 0.503 0.229 0.216 0.220 0.936 0.996 64.1 36.3
#> 16 strata_ra… -0.904 -0.908 0.483 0.510 -1.65 -0.264 0.999 57.1 56.9
#> 17 strata_ra… -0.450 -0.473 0.326 0.358 -0.975 0.0383 0.997 34.2 23.5
#> 18 strata_ra… 1.04 0.978 0.320 0.389 0.608 1.58 1.04 39.1 17.3
#> 19 strata_ra… 0.454 0.455 0.226 0.186 0.186 0.856 1.05 26.5 49.6
get_summary(pacific_wren_model, variables = "strata_raw[9]")
#> # A tibble: 1 × 10
#> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 strata_raw[9] -1.00 -0.939 0.350 0.348 -1.44 -0.531 0.973 53.0 17.3
# Restore warnings
options(opts)