direct_discrete_FWER {DiscreteFWER}R Documentation

Direct Application of Multiple Testing Procedures to Dataset

Description

Apply one of the various FWER adaptation procedures, with or without computing the critical constants, to a data set of 2x2 contingency tables using statistical test functions from package DiscreteTests. If necessary, functions for pre-processing can be passed as well.

Usage

direct_discrete_FWER(
  dat,
  test_fun,
  test_args = NULL,
  alpha = 0.05,
  independence = FALSE,
  single_step = TRUE,
  critical_values = FALSE,
  select_threshold = 1,
  preprocess_fun = NULL,
  preprocess_args = NULL
)

Arguments

dat

input data; must be suitable for the first parameter of the provided preprocess_fun function or, if preprocess_fun is NULL, for the first parameter of the test_fun function.

test_fun

function from package DiscreteTests, i.e. one whose name ends with ⁠*_test_pv⁠ and which performs hypothesis tests and provides an object with p-values and their support sets; can be specified by a single character string (which is automatically checked for being a suitable function from that package and may be abbreviated) or a single function object.

test_args

optional named list with arguments for test_fun; the names of the list fields must match the test function's parameter names. The first parameter of the test function (i.e. the data) MUST NOT be included!

alpha

single real number strictly between 0 and 1 indicating the target FWER level.

independence

single boolean specifying whether the p-values are statistically independent or not.

single_step

single boolean specifying whether to perform a single-step (TRUE) or step-down (FALSE; the default) procedure.

critical_values

single boolean specifying whether critical constants are to be computed.

select_threshold

single real number strictly between 0 and 1 indicating the largest raw p-value to be considered, i.e. only p-values below this threshold are considered and the procedures are adjusted in order to take this selection effect into account; if select_threshold = 1 (the default), all raw p-values are selected.

preprocess_fun

optional function for pre-processing the input data; its result must be suitable for the first parameter of the test_fun function.

preprocess_args

optional named list with arguments for preprocess_fun; the names of the list fields must match the pre-processing function's parameter names. The first parameter of the test function (i.e. the data) MUST NOT be included!

Value

A DiscreteFWER S3 class object whose elements are:

Rejected

rejected raw p-values.

Indices

indices of rejected hypotheses.

Num_rejected

number of rejections.

Adjusted

adjusted p-values.

Critical_constants

critical values (only exists if computations where performed with critical_values = TRUE).

Data

list with input data.

Data$Method

character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'.

Data$Raw_pvalues

observed p-values.

Data$pCDFlist

list of the p-value supports.

Data$FWER_level

FWER level alpha.

Data$Independence

boolean indicating whether the p-values were considered as independent.

Data$Single_step

boolean indicating whether a single-step or step-down procedure was performed.

Data$Data_name

the respective variable names of the input data.

Select

list with data related to p-value selection; only exists if select_threshold < 1.

Select$Threshold

p-value selection threshold (select_threshold).

Select$Effective_Thresholds

results of each p-value CDF evaluated at the selection threshold.

Select$Pvalues

selected p-values that are \leq selection threshold.

Select$Indices

indices of p-values \leq selection threshold.

Select$Scaled

scaled selected p-values.

Select$Number

number of selected p-values \leq selection threshold.

Examples

X1 <- c(4, 2, 2, 14, 6, 9, 4, 0, 1)
X2 <- c(0, 0, 1, 3, 2, 1, 2, 2, 2)
N1 <- rep(148, 9)
N2 <- rep(132, 9)
Y1 <- N1 - X1
Y2 <- N2 - X2
df <- data.frame(X1, Y1, X2, Y2)
df

# Computation of p-values and their supports with Fisher's exact test
library(DiscreteTests)  # for Fisher's exact test
test_results <- fisher_test_pv(df)
raw_pvalues <- test_results$get_pvalues()
pCDFlist <- test_results$get_pvalue_supports()

DBonf <- direct_discrete_FWER(df, "fisher")
summary(DBonf)

DHolm <- direct_discrete_FWER(df, "fisher_test_pv", single_step = FALSE)
summary(DHolm)

DBonf_bin <- direct_discrete_FWER(X1 + X2, "binom_test_pv", 
                                  list(n = N1 + N2, p = 0.05))
summary(DBonf_bin)

DHolm_bin <- direct_discrete_FWER(X1 + X2, "binom", 
                                  list(n = N1 + N2, p = 0.05),
                                  single_step = TRUE)
summary(DHolm_bin)


[Package DiscreteFWER version 1.0.0 Index]