Title: | FWER-Based Multiple Testing Procedures with Adaptation for Discrete Tests |
---|---|
Description: | Implementations of several multiple testing procedures that control the family-wise error rate (FWER) designed specifically for discrete tests. Included are discrete adaptations of the Bonferroni, Holm, Hochberg and Šidák procedures as described in the papers Döhler (2010) "Validation of credit default probabilities using multiple-testing procedures" <doi:10.21314/JRMV.2010.062> and Zhu & Guo (2019) "Family-Wise Error Rate Controlling Procedures for Discrete Data" <doi:10.1080/19466315.2019.1654912>. The main procedures of this package take as input the results of a test procedure from package 'DiscreteTests' or a set of observed p-values and their discrete support under their nulls. A shortcut function to apply discrete procedures directly to data is also provided. |
Authors: | Sebastian Döhler [aut, ctb] , Florian Junge [aut, ctb, cre] |
Maintainer: | Florian Junge <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.0 |
Built: | 2024-11-27 15:29:57 UTC |
Source: | https://github.com/disohda/discretefwer |
This package implements adaptions for discrete tests of the Bonferroni, Holm, Hochberg and Šidák procedures for control of the family-wise error rate (FWER).
The main function discrete_FWER()
makes all four procedures available to
the user. DBonferroni()
, DHolm()
, DHochberg()
and DSidak()
are wrapper functions that enable the user to access them directly. Their
main parameters are either a
DiscreteTestResults
object from
package DiscreteTests or a vector of
raw observed p-values and a list whose elements are the discrete supports
of the CDFs of the -values.
The function direct_discrete_FWER()
is a wrapper for
DiscreteFDR::generate.pvalues()
and discrete_FWER()
, which applies
discrete procedures directly to data.
Maintainer: Florian Junge [email protected] (ORCID) [contributor]
Authors:
Sebastian Döhler [email protected] (ORCID) [contributor]
Döhler, S. (2010). Validation of credit default probabilities using multiple-testing procedures. Journal of Risk Model Validation, 4(4), 59-92. doi:10.21314/JRMV.2010.062
Zhu, Y., & Guo, W. (2019). Family-Wise Error Rate Controlling Procedures for Discrete Data. Statistics in Biopharmaceutical Research, 12(1), 117-128. doi:10.1080/19466315.2019.1654912
Useful links:
Report bugs at https://github.com/DISOhda/DiscreteFWER/issues
DBonferroni()
is a wrapper function of discrete_FWER()
for computing
the discrete Bonferroni procedure for tests with an arbitrary dependency
structure. It simply passes its arguments to discrete_FWER()
with fixed
independence = FALSE
and single_step = TRUE
.
DBonferroni(test_results, ...) ## Default S3 method: DBonferroni( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DBonferroni( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
DBonferroni(test_results, ...) ## Default S3 method: DBonferroni( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DBonferroni( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
test_results |
either a numeric vector with |
... |
further arguments to be passed to or from other methods. They are ignored here. |
pCDFlist |
list of the supports of the CDFs of the |
alpha |
single real number strictly between 0 and 1 indicating the target FWER level. |
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 |
pCDFlist_indices |
list of numeric vectors containing the test indices that indicate to which raw |
Computing critical constants (critical_values = TRUE
) requires considerably
more execution time, especially if the number of unique supports is large.
We recommend that users should only have them calculated when they need them,
e.g. for illustrating the rejection set in a plot or other theoretical
reasons. Setting (critical_values = FALSE
) is sufficient for obtaining
rejection decisions and adjusted -values.
A DiscreteFWER
S3 class object whose elements are:
Rejected |
rejected raw |
Indices |
indices of rejected hypotheses. |
Num_rejected |
number of rejections. |
Adjusted |
adjusted |
Critical_constants |
critical values (only exists if computations where performed with |
Data |
list with input data. |
Data$Method |
character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'. |
Data$Raw_pvalues |
observed |
Data$pCDFlist |
list of the |
Data$FWER_level |
FWER level |
Data$Independence |
boolean indicating whether the |
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 |
Select$Threshold |
|
Select$Effective_Thresholds |
results of each |
Select$Pvalues |
selected |
Select$Indices |
indices of |
Select$Scaled |
scaled selected |
Select$Number |
number of selected |
Döhler, S. (2010). Validation of credit default probabilities using multiple-testing procedures. Journal of Risk Model Validation, 4(4), 59-92. doi:10.21314/JRMV.2010.062
Zhu, Y., & Guo, W. (2019). Family-Wise Error Rate Controlling Procedures for Discrete Data. Statistics in Biopharmaceutical Research, 12(1), 117-128. doi:10.1080/19466315.2019.1654912
discrete_FWER()
, DHolm()
, DSidak()
, DHochberg()
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() # d-Bonferroni without critical values; using extracted p-values and supports DBonferroni_fast <- DBonferroni(raw_pvalues, pCDFlist) summary(DBonferroni_fast) # d-Bonferroni with critical values; using test results object DBonferroni_crit <- DBonferroni(test_results, critical_values = TRUE) summary(DBonferroni_crit)
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() # d-Bonferroni without critical values; using extracted p-values and supports DBonferroni_fast <- DBonferroni(raw_pvalues, pCDFlist) summary(DBonferroni_fast) # d-Bonferroni with critical values; using test results object DBonferroni_crit <- DBonferroni(test_results, critical_values = TRUE) summary(DBonferroni_crit)
DHochberg()
is a wrapper function of discrete_FWER()
for computing the
discrete Hochberg step-up procedure for independent or positively correlated
discrete tests. It simply passes its arguments to discrete_FWER()
with
fixed independence = TRUE
and single_step = FALSE
.
DHochberg(test_results, ...) ## Default S3 method: DHochberg( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DHochberg( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
DHochberg(test_results, ...) ## Default S3 method: DHochberg( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DHochberg( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
test_results |
either a numeric vector with |
... |
further arguments to be passed to or from other methods. They are ignored here. |
pCDFlist |
list of the supports of the CDFs of the |
alpha |
single real number strictly between 0 and 1 indicating the target FWER level. |
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 |
pCDFlist_indices |
list of numeric vectors containing the test indices that indicate to which raw |
Computing critical constants (critical_values = TRUE
) requires considerably
more execution time, especially if the number of unique supports is large.
We recommend that users should only have them calculated when they need them,
e.g. for illustrating the rejection set in a plot or other theoretical
reasons. Setting (critical_values = FALSE
) is sufficient for obtaining
rejection decisions and adjusted -values.
A DiscreteFWER
S3 class object whose elements are:
Rejected |
rejected raw |
Indices |
indices of rejected hypotheses. |
Num_rejected |
number of rejections. |
Adjusted |
adjusted |
Critical_constants |
critical values (only exists if computations where performed with |
Data |
list with input data. |
Data$Method |
character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'. |
Data$Raw_pvalues |
observed |
Data$pCDFlist |
list of the |
Data$FWER_level |
FWER level |
Data$Independence |
boolean indicating whether the |
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 |
Select$Threshold |
|
Select$Effective_Thresholds |
results of each |
Select$Pvalues |
selected |
Select$Indices |
indices of |
Select$Scaled |
scaled selected |
Select$Number |
number of selected |
Zhu, Y., & Guo, W. (2019). Family-Wise Error Rate Controlling Procedures for Discrete Data. Statistics in Biopharmaceutical Research, 12(1), 117-128. doi:10.1080/19466315.2019.1654912
discrete_FWER()
, DSidak()
, DBonferroni()
, DHolm
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() # d-Hochberg without critical values; using test results object DHoch_fast <- DHochberg(test_results) summary(DHoch_fast) # d-Hochberg with critical values; using extracted p-values and supports DHoch_crit <- DHochberg(raw_pvalues, pCDFlist, critical_values = TRUE) summary(DHoch_crit)
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() # d-Hochberg without critical values; using test results object DHoch_fast <- DHochberg(test_results) summary(DHoch_fast) # d-Hochberg with critical values; using extracted p-values and supports DHoch_crit <- DHochberg(raw_pvalues, pCDFlist, critical_values = TRUE) summary(DHoch_crit)
DHolm()
is a wrapper function of discrete_FWER()
for computing the
discrete Holm step-down procedure for tests with an arbitrary dependency
structure. It simply passes its arguments to discrete_FWER()
with fixed
independence = FALSE
and single_step = FALSE
.
DHolm(test_results, ...) ## Default S3 method: DHolm( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DHolm( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
DHolm(test_results, ...) ## Default S3 method: DHolm( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DHolm( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
test_results |
either a numeric vector with |
... |
further arguments to be passed to or from other methods. They are ignored here. |
pCDFlist |
list of the supports of the CDFs of the |
alpha |
single real number strictly between 0 and 1 indicating the target FWER level. |
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 |
pCDFlist_indices |
list of numeric vectors containing the test indices that indicate to which raw |
Computing critical constants (critical_values = TRUE
) requires considerably
more execution time, especially if the number of unique supports is large.
We recommend that users should only have them calculated when they need them,
e.g. for illustrating the rejection set in a plot or other theoretical
reasons. Setting (critical_values = FALSE
) is sufficient for obtaining
rejection decisions and adjusted -values.
A DiscreteFWER
S3 class object whose elements are:
Rejected |
rejected raw |
Indices |
indices of rejected hypotheses. |
Num_rejected |
number of rejections. |
Adjusted |
adjusted |
Critical_constants |
critical values (only exists if computations where performed with |
Data |
list with input data. |
Data$Method |
character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'. |
Data$Raw_pvalues |
observed |
Data$pCDFlist |
list of the |
Data$FWER_level |
FWER level |
Data$Independence |
boolean indicating whether the |
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 |
Select$Threshold |
|
Select$Effective_Thresholds |
results of each |
Select$Pvalues |
selected |
Select$Indices |
indices of |
Select$Scaled |
scaled selected |
Select$Number |
number of selected |
Döhler, S. (2010). Validation of credit default probabilities using multiple-testing procedures. Journal of Risk Model Validation, 4(4), 59-92. doi:10.21314/JRMV.2010.062
Zhu, Y., & Guo, W. (2019). Family-Wise Error Rate Controlling Procedures for Discrete Data. Statistics in Biopharmaceutical Research, 12(1), 117-128. doi:10.1080/19466315.2019.1654912
discrete_FWER()
, DBonferroni()
, DSidak()
, DHochberg()
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() # d-Holm without critical values; using extracted p-values and supports DHolm_fast <- DHolm(raw_pvalues, pCDFlist) summary(DHolm_fast) # d-Holm with critical values; using test results object DHolm_crit <- DHolm(test_results, critical_values = TRUE) summary(DHolm_crit)
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() # d-Holm without critical values; using extracted p-values and supports DHolm_fast <- DHolm(raw_pvalues, pCDFlist) summary(DHolm_fast) # d-Holm with critical values; using test results object DHolm_crit <- DHolm(test_results, critical_values = TRUE) summary(DHolm_crit)
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.
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 )
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 )
dat |
input data; must be suitable for the first parameter of the provided |
test_fun |
function from package |
test_args |
optional named list with arguments for |
alpha |
single real number strictly between 0 and 1 indicating the target FWER level. |
independence |
single boolean specifying whether the |
single_step |
single boolean specifying whether to perform a single-step ( |
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 |
preprocess_fun |
optional function for pre-processing the input |
preprocess_args |
optional named list with arguments for |
A DiscreteFWER
S3 class object whose elements are:
Rejected |
rejected raw |
Indices |
indices of rejected hypotheses. |
Num_rejected |
number of rejections. |
Adjusted |
adjusted |
Critical_constants |
critical values (only exists if computations where performed with |
Data |
list with input data. |
Data$Method |
character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'. |
Data$Raw_pvalues |
observed |
Data$pCDFlist |
list of the |
Data$FWER_level |
FWER level |
Data$Independence |
boolean indicating whether the |
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 |
Select$Threshold |
|
Select$Effective_Thresholds |
results of each |
Select$Pvalues |
selected |
Select$Indices |
indices of |
Select$Scaled |
scaled selected |
Select$Number |
number of selected |
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)
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)
Apply a discrete FWER adaptation procedure, with or without computing the critical values, to a set of p-values and their discrete support.
discrete_FWER(test_results, ...) ## Default S3 method: discrete_FWER( test_results, pCDFlist, alpha = 0.05, independence = FALSE, single_step = FALSE, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' discrete_FWER( test_results, alpha = 0.05, independence = FALSE, single_step = FALSE, critical_values = FALSE, select_threshold = 1, ... )
discrete_FWER(test_results, ...) ## Default S3 method: discrete_FWER( test_results, pCDFlist, alpha = 0.05, independence = FALSE, single_step = FALSE, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' discrete_FWER( test_results, alpha = 0.05, independence = FALSE, single_step = FALSE, critical_values = FALSE, select_threshold = 1, ... )
test_results |
either a numeric vector with |
... |
further arguments to be passed to or from other methods. They are ignored here. |
pCDFlist |
list of the supports of the CDFs of the |
alpha |
single real number strictly between 0 and 1 indicating the target FWER level. |
independence |
single boolean specifying whether the |
single_step |
single boolean specifying whether to perform a single-step ( |
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 |
pCDFlist_indices |
list of numeric vectors containing the test indices that indicate to which raw |
Computing critical constants (critical_values = TRUE
) requires considerably
more execution time, especially if the number of unique supports is large.
We recommend that users should only have them calculated when they need them,
e.g. for illustrating the rejection set in a plot or other theoretical
reasons. Setting (critical_values = FALSE
) is sufficient for obtaining
rejection decisions and adjusted -values.
Depending on the choices of independence
and single_step
, one of the
following procedures, is applied:
single-step | stepwise | |
independent | Šidák | Hochberg (step-up) |
not independent | Bonferroni | Holm (step-down) |
Each procedure is available by its own shortcut function:
single-step | stepwise | |
independent | DSidak() |
DHochberg() |
not independent | DBonferroni() |
DHolm() |
A DiscreteFWER
S3 class object whose elements are:
Rejected |
rejected raw |
Indices |
indices of rejected hypotheses. |
Num_rejected |
number of rejections. |
Adjusted |
adjusted |
Critical_constants |
critical values (only exists if computations where performed with |
Data |
list with input data. |
Data$Method |
character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'. |
Data$Raw_pvalues |
observed |
Data$pCDFlist |
list of the |
Data$FWER_level |
FWER level |
Data$Independence |
boolean indicating whether the |
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 |
Select$Threshold |
|
Select$Effective_Thresholds |
results of each |
Select$Pvalues |
selected |
Select$Indices |
indices of |
Select$Scaled |
scaled selected |
Select$Number |
number of selected |
Döhler, S. (2010). Validation of credit default probabilities using multiple-testing procedures. Journal of Risk Model Validation, 4(4), 59-92. doi:10.21314/JRMV.2010.062
Zhu, Y., & Guo, W. (2019). Family-Wise Error Rate Controlling Procedures for Discrete Data. Statistics in Biopharmaceutical Research, 12(1), 117-128. doi:10.1080/19466315.2019.1654912
DiscreteFWER
, DBonferroni()
, DHolm()
,
DSidak()
, DHochberg()
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() # d-Holm without critical values; using test results object DFWER_dep_sd_fast <- discrete_FWER(test_results) summary(DFWER_dep_sd_fast) # d-Holm with critical values; using extracted p-values and supports DFWER_dep_sd_crit <- discrete_FWER(raw_pvalues, pCDFlist, critical_values = TRUE) summary(DFWER_dep_sd_crit) # d-Bonferroni without critical values; using test results object DFWER_dep_fast <- discrete_FWER(test_results, single_step = TRUE) summary(DFWER_dep_fast) # d-Bonferroni with critical values; using extracted p-values and supports DFWER_dep_crit <- discrete_FWER(raw_pvalues, pCDFlist, single_step = TRUE, critical_values = TRUE) summary(DFWER_dep_crit) # d-Hochberg without critical values; using test results object DFWER_ind_su_fast <- discrete_FWER(test_results, independence = TRUE) summary(DFWER_ind_su_fast) # d-Hochberg with critical values; using extracted p-values and supports DFWER_ind_su_crit <- discrete_FWER(raw_pvalues, pCDFlist, independence = TRUE, critical_values = TRUE) summary(DFWER_ind_su_crit) # d-Šidák without critical values; using extracted p-values and supports DFWER_ind_fast <- discrete_FWER(raw_pvalues, pCDFlist, independence = TRUE, single_step = TRUE) summary(DFWER_ind_fast) # d-Šidák with critical values; using test results object DFWER_ind_crit <- discrete_FWER(test_results, independence = TRUE, single_step = TRUE, critical_values = TRUE) summary(DFWER_ind_crit)
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() # d-Holm without critical values; using test results object DFWER_dep_sd_fast <- discrete_FWER(test_results) summary(DFWER_dep_sd_fast) # d-Holm with critical values; using extracted p-values and supports DFWER_dep_sd_crit <- discrete_FWER(raw_pvalues, pCDFlist, critical_values = TRUE) summary(DFWER_dep_sd_crit) # d-Bonferroni without critical values; using test results object DFWER_dep_fast <- discrete_FWER(test_results, single_step = TRUE) summary(DFWER_dep_fast) # d-Bonferroni with critical values; using extracted p-values and supports DFWER_dep_crit <- discrete_FWER(raw_pvalues, pCDFlist, single_step = TRUE, critical_values = TRUE) summary(DFWER_dep_crit) # d-Hochberg without critical values; using test results object DFWER_ind_su_fast <- discrete_FWER(test_results, independence = TRUE) summary(DFWER_ind_su_fast) # d-Hochberg with critical values; using extracted p-values and supports DFWER_ind_su_crit <- discrete_FWER(raw_pvalues, pCDFlist, independence = TRUE, critical_values = TRUE) summary(DFWER_ind_su_crit) # d-Šidák without critical values; using extracted p-values and supports DFWER_ind_fast <- discrete_FWER(raw_pvalues, pCDFlist, independence = TRUE, single_step = TRUE) summary(DFWER_ind_fast) # d-Šidák with critical values; using test results object DFWER_ind_crit <- discrete_FWER(test_results, independence = TRUE, single_step = TRUE, critical_values = TRUE) summary(DFWER_ind_crit)
DSidak()
is a wrapper function of discrete_FWER()
for computing the
discrete Šidák procedure for independent discrete tests. It simply passes its
arguments to discrete_FWER()
with fixed independence = TRUE
and
single_step = TRUE
.
DSidak(test_results, ...) ## Default S3 method: DSidak( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DSidak( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
DSidak(test_results, ...) ## Default S3 method: DSidak( test_results, pCDFlist, alpha = 0.05, critical_values = FALSE, select_threshold = 1, pCDFlist_indices = NULL, ... ) ## S3 method for class 'DiscreteTestResults' DSidak( test_results, alpha = 0.05, critical_values = FALSE, select_threshold = 1, ... )
test_results |
either a numeric vector with |
... |
further arguments to be passed to or from other methods. They are ignored here. |
pCDFlist |
list of the supports of the CDFs of the |
alpha |
single real number strictly between 0 and 1 indicating the target FWER level. |
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 |
pCDFlist_indices |
list of numeric vectors containing the test indices that indicate to which raw |
Computing critical constants (critical_values = TRUE
) requires considerably
more execution time, especially if the number of unique supports is large.
We recommend that users should only have them calculated when they need them,
e.g. for illustrating the rejection set in a plot or other theoretical
reasons. Setting (critical_values = FALSE
) is sufficient for obtaining
rejection decisions and adjusted -values.
A DiscreteFWER
S3 class object whose elements are:
Rejected |
rejected raw |
Indices |
indices of rejected hypotheses. |
Num_rejected |
number of rejections. |
Adjusted |
adjusted |
Critical_constants |
critical values (only exists if computations where performed with |
Data |
list with input data. |
Data$Method |
character string describing the performed algorithm, e.g. 'Discrete Bonferroni procedure'. |
Data$Raw_pvalues |
observed |
Data$pCDFlist |
list of the |
Data$FWER_level |
FWER level |
Data$Independence |
boolean indicating whether the |
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 |
Select$Threshold |
|
Select$Effective_Thresholds |
results of each |
Select$Pvalues |
selected |
Select$Indices |
indices of |
Select$Scaled |
scaled selected |
Select$Number |
number of selected |
Döhler, S. (2010). Validation of credit default probabilities using multiple-testing procedures. Journal of Risk Model Validation, 4(4), 59-92. doi:10.21314/JRMV.2010.062
discrete_FWER()
, DHochberg()
, DBonferroni()
, DHolm()
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() # d-Šidák without critical values; using extracted p-values and supports DSidak_fast <- DSidak(raw_pvalues, pCDFlist) summary(DSidak_fast) # d-Šidák with critical values; using test results object DSidak_crit <- DSidak(test_results, critical_values = TRUE) summary(DSidak_crit)
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() # d-Šidák without critical values; using extracted p-values and supports DSidak_fast <- DSidak(raw_pvalues, pCDFlist) summary(DSidak_fast) # d-Šidák with critical values; using test results object DSidak_crit <- DSidak(test_results, critical_values = TRUE) summary(DSidak_crit)
Computes a histogram of the raw p-values of a DiscreteFWER
object.
## S3 method for class 'DiscreteFWER' hist(x, breaks = "FD", mode = c("raw", "selected"), ...)
## S3 method for class 'DiscreteFWER' hist(x, breaks = "FD", mode = c("raw", "selected"), ...)
x |
an object of class |
breaks |
as in |
mode |
single character string specifying for which $p$-values the
histogram is to be generated; must either be |
... |
further arguments to |
If x
does not contain results of a selection approach, a warning is issued
and a histogram of the raw p-values is drawn.
An object of class histogram
.
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() # d-Holm with critical values; using test results object DHolm_crit <- DHolm(test_results, critical_values = TRUE) hist(DHolm_crit)
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() # d-Holm with critical values; using test results object DHolm_crit <- DHolm(test_results, critical_values = TRUE) hist(DHolm_crit)
DiscreteFWER
objectsPlots raw p-values of a DiscreteFWER
object and highlights rejected and
accepted p-values. If calculated, the critical values are plotted, too.
## S3 method for class 'DiscreteFWER' plot( x, col = c(2, 4, 1), pch = c(20, 20, 17), lwd = rep(par()$lwd, 3), cex = rep(par()$cex, 3), type_crit = "b", legend = NULL, ... )
## S3 method for class 'DiscreteFWER' plot( x, col = c(2, 4, 1), pch = c(20, 20, 17), lwd = rep(par()$lwd, 3), cex = rep(par()$cex, 3), type_crit = "b", legend = NULL, ... )
x |
object of class |
col |
numeric or character vector of length 3 indicating the colours of the
|
pch |
numeric or character vector of length 3 indicating the point characters of the
|
lwd |
numeric vector of length 3 indicating the thickness of the
points and lines; defaults to current |
cex |
numeric vector of length 3 indicating the size of point characters or lines of the
defaults to current |
type_crit |
1-character string giving the type of plot desired for the
critical values (e.g.: |
legend |
if |
... |
further arguments to |
A plot is created, but no value is returned.
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_fast <- DBonferroni(raw_pvalues, pCDFlist) DBonf_crit <- DBonferroni(test_results, critical_values = TRUE) DHolm_fast <- DHolm(test_results) DHolm_crit <- DHolm(raw_pvalues, pCDFlist, critical_values = TRUE) plot(DBonf_fast) plot(DBonf_crit, xlim = c(1, 5), ylim = c(0, 0.4)) plot(DHolm_fast, col = c(2, 4), pch = c(2, 3), lwd = c(2, 2), legend = "topleft", xlim = c(1, 5), ylim = c(0, 0.4)) plot(DHolm_crit, col = c(2, 4, 1), pch = c(1, 1, 4), lwd = c(1, 1, 2), type_crit = 'o', legend = c(1, 0.4), lty = 1, xlim = c(1, 5), ylim = c(0, 0.4))
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_fast <- DBonferroni(raw_pvalues, pCDFlist) DBonf_crit <- DBonferroni(test_results, critical_values = TRUE) DHolm_fast <- DHolm(test_results) DHolm_crit <- DHolm(raw_pvalues, pCDFlist, critical_values = TRUE) plot(DBonf_fast) plot(DBonf_crit, xlim = c(1, 5), ylim = c(0, 0.4)) plot(DHolm_fast, col = c(2, 4), pch = c(2, 3), lwd = c(2, 2), legend = "topleft", xlim = c(1, 5), ylim = c(0, 0.4)) plot(DHolm_crit, col = c(2, 4, 1), pch = c(1, 1, 4), lwd = c(1, 1, 2), type_crit = 'o', legend = c(1, 0.4), lty = 1, xlim = c(1, 5), ylim = c(0, 0.4))
Prints the results of discrete FWER analysis, stored in a DiscreteFWER
S3 class object.
## S3 method for class 'DiscreteFWER' print(x, ...)
## S3 method for class 'DiscreteFWER' print(x, ...)
x |
object of class |
... |
further arguments to be passed to or from other methods. They are ignored in this function. |
The respective input object is invisibly returned via invisible(x)
.
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() # d-Holm with critical values; using test results object DHolm_crit <- DHolm(test_results, critical.values = TRUE) # print results print(DHolm_crit)
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() # d-Holm with critical values; using test results object DHolm_crit <- DHolm(test_results, critical.values = TRUE) # print results print(DHolm_crit)
summary
method for class DiscreteFWER
.
## S3 method for class 'DiscreteFWER' summary(object, ...) ## S3 method for class 'summary.DiscreteFWER' print(x, max = NULL, ...)
## S3 method for class 'DiscreteFWER' summary(object, ...) ## S3 method for class 'summary.DiscreteFWER' print(x, max = NULL, ...)
object |
an object of class |
... |
further arguments passed to or from other methods. |
x |
an object of class |
max |
numeric or |
summary.DiscreteFWER
objects contain all data of an DiscreteFWER
object,
but also include an additional table which includes the raw p-values,
their indices, the respective critical values (if present), the adjusted
p-values (if present) and a logical column to indicate rejection. The table
is sorted in ascending order by the raw p-values.
print.summary.DiscreteFWER
simply prints the same output as
print.DiscreteFWER
, but also prints the p-value table.
summary.DiscreteFWER
computes and returns a list that includes all the
data of an input DiscreteFWER
object, plus
Table |
|
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() # d-Holm procedure without critical values; using test results object DFWER_dep_sd_fast <- discrete_FWER(test_results) summary(DFWER_dep_sd_fast) # d-Bonferroni procedure with critical values; using test results object DFWER_dep_crit <- discrete_FWER(test_results, single_step = TRUE, critical_values = TRUE) summary(DFWER_dep_crit)
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() # d-Holm procedure without critical values; using test results object DFWER_dep_sd_fast <- discrete_FWER(test_results) summary(DFWER_dep_sd_fast) # d-Bonferroni procedure with critical values; using test results object DFWER_dep_crit <- discrete_FWER(test_results, single_step = TRUE, critical_values = TRUE) summary(DFWER_dep_crit)