Shortcut for summarize variable with quantiles and mean
Source:R/driver-utils.R
summarise_posterior.Rd
Shortcut for summarize variable with quantiles and mean
Examples
d <- data.frame("a"=sample(1:10, 50, TRUE),
"b"=rnorm(50))
# Summarize posterior for b over grouping of a and also calcuate
# minmum of b (in addition to normal statistics returned)
d <- dplyr::group_by(d, a)
summarise_posterior(d, b, mean.b = mean(b), min=min(b))
#> # A tibble: 10 × 9
#> a p2.5 p25 p50 mean p75 p97.5 mean.b min
#> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 -0.474 -0.290 -0.152 -0.0151 0.0731 0.794 -0.0151 -0.481
#> 2 2 -0.795 -0.355 0.0104 -0.155 0.0447 0.277 -0.155 -0.841
#> 3 3 -1.27 -0.430 0.0833 -0.103 0.231 0.821 -0.103 -1.37
#> 4 4 -0.536 -0.272 0.0213 0.0943 0.424 0.786 0.0943 -0.565
#> 5 5 -0.0587 0.288 0.315 0.537 0.809 1.32 0.537 -0.0972
#> 6 6 -1.25 -0.512 0.0671 0.278 1.08 2.06 0.278 -1.32
#> 7 7 0.0475 0.421 1.15 1.06 1.54 2.26 1.06 0.0448
#> 8 8 0.0164 0.0164 0.0164 0.0164 0.0164 0.0164 0.0164 0.0164
#> 9 9 0.479 0.479 0.479 0.479 0.479 0.479 0.479 0.479
#> 10 10 -1.16 -0.756 -0.205 -0.193 0.0819 1.01 -0.193 -1.20