Calculate summary statistics

calculate(x, stat = c("mean", "median", "sum", "sd", "prop", "count",
  "diff in means", "diff in medians", "diff in props", "Chisq", "F",
  "slope", "correlation", "t", "z"), order = NULL, ...)

Arguments

x

The output from generate() for computation-based inference or the output from hypothesize() piped in to here for theory-based inference.

stat

A string giving the type of the statistic to calculate. Current options include "mean", "median", "sum", "sd", "prop", "count", "diff in means", "diff in medians", "diff in props", "Chisq", "F", "t", "z", "slope", and "correlation".

order

A string vector of specifying the order in which the levels of the explanatory variable should be ordered for subtraction, where order = c("first", "second") means ("first" - "second") Needed for inference on difference in means, medians, or proportions and t and z statistics.

...

To pass options like na.rm = TRUE into functions like mean(), sd(), etc.

Value

A tibble containing a stat column of calculated statistics.

Examples

# Permutation test for two binary variables mtcars %>% dplyr::mutate(am = factor(am), vs = factor(vs)) %>% specify(am ~ vs, success = "1") %>% hypothesize(null = "independence") %>% generate(reps = 100, type = "permute") %>% calculate(stat = "diff in props", order = c("1", "0"))
#> # A tibble: 100 x 2 #> replicate stat #> <int> <dbl> #> 1 1 -0.0873 #> 2 2 -0.0873 #> 3 3 -0.341 #> 4 4 -0.214 #> 5 5 0.167 #> 6 6 0.0397 #> 7 7 -0.214 #> 8 8 0.0397 #> 9 9 0.0397 #> 10 10 0.167 #> # ... with 90 more rows