MyNixOS website logo
Description

Tidyverse-Compatible Bootstrapping.

Compute arbitrary non-parametric bootstrap statistics on data in tidy data frames.

tidyboot

tidyboot let's you compute arbitrary non-parametric bootstrap statistics on data in tidy data frames.

Installation

You can install tidyboot from CRAN with:

install.packages("tidyboot")

You can install tidyboot from github with:

# install.packages("devtools")
devtools::install_github("langcog/tidyboot")

Examples

For the simplest use case of bootstrapping the mean and getting the mean and confidence interval of that estimate, use the convenience function tidyboot_mean(), specifying which column has the relevant values to compute the mean over:

library(dplyr)
library(tidyboot)

gauss1 <- data_frame(value = rnorm(500, mean = 0, sd = 1), condition = 1)
gauss2 <- data_frame(value = rnorm(500, mean = 2, sd = 3), condition = 2)
df <- bind_rows(gauss1, gauss2)

df %>%
  group_by(condition) %>%
  tidyboot_mean(column = value)
#> # A tibble: 2 x 6
#>   condition     n empirical_stat  ci_lower        mean   ci_upper
#>       <dbl> <int>          <dbl>     <dbl>       <dbl>      <dbl>
#> 1         1   500    -0.02292831 -0.114664 -0.02196269 0.06232765
#> 2         2   500     2.02781100  1.755141  2.02955494 2.30626508

For bootstrapping any statistic and any properties of its sampling distribution, use tidyboot().

You can provide the statistic to be estimated either as a function and a column to compute it over, or as function that takes the whole dataframe and computes the relevant value.

Similarly, you can provide the properties of the sampling distribution to be computed either as a named list of functions and a column to compute them over, or a function that takes the whole dataframe and returns the relevant values.

df %>%
  group_by(condition) %>%
  tidyboot(column = value, summary_function = median,
           statistics_functions = list("mean" = mean, "sd" = sd))
#> # A tibble: 2 x 5
#>   condition     n empirical_median         mean         sd
#>       <dbl> <int>            <dbl>        <dbl>      <dbl>
#> 1         1   500     -0.006468345 -0.005842842 0.05544625
#> 2         2   500      1.995112455  2.011381756 0.20658963
df %>%
  group_by(condition) %>%
  tidyboot(summary_function = function(x) x %>% summarise(median = median(value)),
           statistics_functions = function(x) x %>% summarise_at(vars(median), funs(mean, sd)))
#> # A tibble: 2 x 5
#>   condition     n empirical_median         mean         sd
#>       <dbl> <int>            <dbl>        <dbl>      <dbl>
#> 1         1   500     -0.006468345 -0.006287976 0.05505858
#> 2         2   500      1.995112455  2.006877243 0.20645516
Metadata

Version

0.1.1

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows