The summarise_draws() (and summarize_draws()) methods provide a quick way to get a table of summary statistics and diagnostics. These methods will convert an object to a draws object if it isn't already. For convenience, a summary() method for draws objects is also provided as an alias for summarise_draws() if the input object is already a draws object.

summarise_draws(x, ...)

summarize_draws(x, ...)

# S3 method for draws
summarise_draws(x, ..., .args = list())

# S3 method for draws
summary(object, ...)

default_summary_measures()

default_convergence_measures()

default_mcse_measures()

Arguments

x, object

A draws object or one coercible to a draws object.

...

Name-value pairs of summary functions. The name will be the name of the variable in the result unless the function returns a named vector in which case the latter names are used. Functions can be passed in all formats supported by as_function(). See the 'Examples' section below for examples.

.args

Optional list of additional arguments passed to the summary functions.

Value

The summarise_draws() methods return a tibble data frame. The first column, "variable", contains the variable names and the remaining columns contain summary statistics and diagnostics.

Details

By default, the following summary functions are used: mean(), median(), sd(), mad(), quantile2(), rhat(), ess_bulk(), and ess_tail(). The functions default_summary_measures(), default_convergence_measures(), and default_mcse_measures() return character vectors of names of the default measures included in the package.

Examples

x <- example_draws("eight_schools") class(x)
#> [1] "draws_array" "draws" "array"
str(x)
#> 'draws_array' num [1:100, 1:4, 1:10] 2.01 1.46 5.81 6.85 1.81 ... #> - attr(*, "dimnames")=List of 3 #> ..$ iteration: chr [1:100] "1" "2" "3" "4" ... #> ..$ chain : chr [1:4] "1" "2" "3" "4" #> ..$ variable : chr [1:10] "mu" "tau" "theta[1]" "theta[2]" ...
summarise_draws(x)
#> # A tibble: 10 x 10 #> variable mean median sd mad q5 q95 rhat ess_bulk ess_tail #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 mu 4.18 4.16 3.40 3.57 -0.854 9.39 1.02 558. 322. #> 2 tau 4.16 3.07 3.58 2.89 0.309 11.0 1.01 246. 202. #> 3 theta[1] 6.75 5.97 6.30 4.87 -1.23 18.9 1.01 400. 254. #> 4 theta[2] 5.25 5.13 4.63 4.25 -1.97 12.5 1.02 564. 372. #> 5 theta[3] 3.04 3.99 6.80 4.94 -10.3 11.9 1.01 312. 205. #> 6 theta[4] 4.86 4.99 4.92 4.51 -3.57 12.2 1.02 695. 252. #> 7 theta[5] 3.22 3.72 5.08 4.38 -5.93 10.8 1.01 523. 306. #> 8 theta[6] 3.99 4.14 5.16 4.81 -4.32 11.5 1.02 548. 205. #> 9 theta[7] 6.50 5.90 5.26 4.54 -1.19 15.4 1.00 434. 308. #> 10 theta[8] 4.57 4.64 5.25 4.89 -3.79 12.2 1.02 355. 146.
summarise_draws(x, "mean", "median")
#> # A tibble: 10 x 3 #> variable mean median #> <chr> <dbl> <dbl> #> 1 mu 4.18 4.16 #> 2 tau 4.16 3.07 #> 3 theta[1] 6.75 5.97 #> 4 theta[2] 5.25 5.13 #> 5 theta[3] 3.04 3.99 #> 6 theta[4] 4.86 4.99 #> 7 theta[5] 3.22 3.72 #> 8 theta[6] 3.99 4.14 #> 9 theta[7] 6.50 5.90 #> 10 theta[8] 4.57 4.64
summarise_draws(x, default_convergence_measures())
#> # A tibble: 10 x 4 #> variable rhat ess_bulk ess_tail #> <chr> <dbl> <dbl> <dbl> #> 1 mu 1.02 558. 322. #> 2 tau 1.01 246. 202. #> 3 theta[1] 1.01 400. 254. #> 4 theta[2] 1.02 564. 372. #> 5 theta[3] 1.01 312. 205. #> 6 theta[4] 1.02 695. 252. #> 7 theta[5] 1.01 523. 306. #> 8 theta[6] 1.02 548. 205. #> 9 theta[7] 1.00 434. 308. #> 10 theta[8] 1.02 355. 146.
summarise_draws(x, mean, mcse = mcse_mean)
#> # A tibble: 10 x 3 #> variable mean mcse #> <chr> <dbl> <dbl> #> 1 mu 4.18 0.150 #> 2 tau 4.16 0.213 #> 3 theta[1] 6.75 0.319 #> 4 theta[2] 5.25 0.202 #> 5 theta[3] 3.04 0.447 #> 6 theta[4] 4.86 0.189 #> 7 theta[5] 3.22 0.232 #> 8 theta[6] 3.99 0.222 #> 9 theta[7] 6.50 0.250 #> 10 theta[8] 4.57 0.273
summarise_draws(x, ~quantile(.x, probs = c(0.4, 0.6)))
#> # A tibble: 10 x 3 #> variable `40%` `60%` #> <chr> <dbl> <dbl> #> 1 mu 3.41 5.35 #> 2 tau 2.47 3.96 #> 3 theta[1] 4.95 7.01 #> 4 theta[2] 4.32 6.13 #> 5 theta[3] 2.54 5.33 #> 6 theta[4] 3.78 6.11 #> 7 theta[5] 2.69 4.69 #> 8 theta[6] 2.92 5.47 #> 9 theta[7] 4.81 7.33 #> 10 theta[8] 3.50 5.92
# illustrate use of '.args' ws <- rexp(ndraws(x)) summarise_draws(x, weighted.mean, .args = list(w = ws))
#> # A tibble: 10 x 2 #> variable weighted.mean #> <chr> <dbl> #> 1 mu 4.24 #> 2 tau 4.28 #> 3 theta[1] 6.85 #> 4 theta[2] 5.13 #> 5 theta[3] 3.28 #> 6 theta[4] 5.09 #> 7 theta[5] 3.66 #> 8 theta[6] 3.66 #> 9 theta[7] 6.21 #> 10 theta[8] 4.17