prm_test: Perform a full permutation test

Description Usage Arguments Author(s) Examples

Description

This function should only be used for academic purposes or small sample sizes (time grows factorially with number of observations) If the "parallel" pacakge is installed, use the global mc.cores option to control level of parallelism

Usage

1
2
prm_test(data, statistics, group_var, statistic_names = names(statistics),
  max_observations = 10)

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
13
14
library(dplyr)
data(mpg)
test_data <- mpg %>% 
  filter(class %in% c('suv', 'compact')) %>%
  sample_n(7) # this just for computational feasibility of illustrative example
prm_res <- prm_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.