tidyboot.data.frame: Non-parametric bootstrap for data frames

Description Usage Arguments Examples

View source: R/tidyboot.R

Description

Computes arbitrary bootstrap statistics on univariate data.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'data.frame'
tidyboot(
  data,
  column = NULL,
  summary_function = mean,
  statistics_functions,
  nboot = 1000,
  ...
)

Arguments

data

A data frame.

column

A column of data to bootstrap over (if not supplied, summary_function and statistic_function must operate over the appropriate data frame).

summary_function

A function to be computed over each set of samples as a data frame, or a function to be computed over each set of samples as a single column of a data frame indicated by column (defaults to mean).

statistics_functions

A function to be computed over each set of samples as a data frame, or a named list of functions to be computed over each set of samples as a single column of a data frame indicated by column.

nboot

The number of bootstrap samples to take (defaults to 1000).

...

Other arguments passed from generic.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Mean and 95% confidence interval for 500 samples from two different normal distributions
require(dplyr)
gauss1 <- tibble(value = rnorm(500, mean = 0, sd = 1), condition = 1)
gauss2 <- tibble(value = rnorm(500, mean = 2, sd = 3), condition = 2)
df <- bind_rows(gauss1, gauss2)

mean_ci_funs <- list("ci_lower" = ci_lower, "mean" = mean, "ci_upper" = ci_upper)
df %>% group_by(condition) %>%
  tidyboot(column = value, summary_function = mean, statistics_functions = mean_ci_funs)

df %>% group_by(condition) %>%
  tidyboot(summary_function = function(x) x %>% summarise(stat = mean(value)),
           statistics_functions = function(x) x %>%
             summarise(across(stat, mean_ci_funs, .names = "{.fn}")))

langcog/tidyboot documentation built on Nov. 17, 2020, 8:20 a.m.