mcr_test: Perform a Monte Carlo randomization test

Description Usage Arguments Author(s) Examples

Description

Simulate a permutation test of arbitrary statistics using a simple randomization (i.e. non-clustered) scheme Note that mcrd_test and mcr_anova convenience functions cover common use cases and should be preferred for interactive, non-programmatic use If the "parallel" pacakge is installed, use the global mc.cores option to control level of parallelism

Usage

1
2
mcr_test(data, statistics, group_var, statistic_names = names(statistics),
  trials = 1000)

Arguments

data

a data frame to draw statistics from

statistics

a function or vector of functions accepting a data frame, returning a scalar statistic

group_var

a character, singular column name in the data representing groups.

statistic_names

the names of statistics that are computed. must be specified if the supplied statistics do not have names

trials

the number of Monte Carlo trials to perform

Author(s)

kholub

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(dplyr)
data(mpg)
test_data <- mpg %>% filter(class %in% c('suv', 'compact'))
mcr_res <- mcr_test(test_data, c(median_difference = function(df) {
                                                                      group_medians <- df %>%
                                                                        group_by(class) %>%
                                                                        summarize(
                                                                          median = median(hwy))
                                                                      as.numeric(group_medians[group_medians$class == 'suv', 'median']) -
                                                                         as.numeric(group_medians[group_medians$class == 'compact', 'median'])
                                                                     }),
                      'class')

holub008/nymph documentation built on June 4, 2019, 10:47 a.m.