sum_samp_with: Calculate summaries within groups.

Description Usage Arguments Value Examples

View source: R/summarise.R

Description

Calculate summaries for specified group using a summary function and an optional transformation.

Usage

1
sum_samp_with(pred, ..., g = mean, t = identity)

Arguments

pred

The predictions as returned by extract_tidy().

...

The grouping. e.g. n to obtain summaries for each observation.

g

The summary-function. A function of type vector -> scalar.

t

Additional transformation to be applied before sum_fun. A function of type vector -> vector. Defaults to identity.

Value

A tibble with the summaries.

Examples

1
2
3
4
5
6
7
8
 
   f <- sampling(...)
   pred <- extact_tidy(f, y_pred)
   # posterior median for the logarithm of y_pred over n
   sum_pred_with(pred, g = median, t = log)
   # posterior median for the logarithm of y_pred for each observation
   sum_pred_with(pred, n, g = median, t = log)
 

paasim/stanutils documentation built on July 19, 2019, 12:47 a.m.