diff --git a/R/FWERSD.R b/R/FWERSD.R index 98ec106..062c2f0 100644 --- a/R/FWERSD.R +++ b/R/FWERSD.R @@ -13,6 +13,10 @@ #' @seealso \code{\link{TH.p.adjust}}, \code{\link[stats]{p.adjust}}. #' @author Yalin Zhu #' @references +#' Zhu, Y., & Guo, W. (2017). +#' Familywise error rate controlling procedures for discrete data +#' \emph{arXiv preprint} arXiv:1711.08147. +#' #' Holm, S. (1979). #' A simple sequentially rejective multiple test procedure. #' \emph{Scandinavian Journal of Statistics}, \strong{6}: 65-70. @@ -20,6 +24,10 @@ #' p <- c(pbinom(1,8,0.5),pbinom(1,5,0.75),pbinom(1,6,0.6)) #' p.set <-list(pbinom(0:8,8,0.5),pbinom(0:5,5,0.75),pbinom(0:6,6,0.6)) #' MHolm.p.adjust(p,p.set) +#' ## Compare with the traditional Holm adjustment +#' p.adjust(p,method = "holm") +#' ## Compare with the Tarone-Holm adjustment +#' TH.p.adjust(p,p.set) #' @export MHolm.p.adjust <- function(p,p.set, alpha = 0.05, make.decision = FALSE){ diff --git a/R/FWERSS.R b/R/FWERSS.R index c8b5060..5df977a 100644 --- a/R/FWERSS.R +++ b/R/FWERSS.R @@ -40,10 +40,18 @@ Sidak.p.adjust <- function(p, alpha = 0.05, make.decision = FALSE){ #' A numeric vector of the adjusted p-values (of the same length as \code{p}) if \code{make.decision = FALSE}, or a list including original p-values, adjusted p-values and decision rules if \code{make.decision = TRUE}. #' @seealso \code{\link{Tarone.p.adjust}}, \code{\link{MixBonf.p.adjust}}, \code{\link[stats]{p.adjust}}. #' @author Yalin Zhu +#' @references +#' Zhu, Y., & Guo, W. (2017). +#' Familywise error rate controlling procedures for discrete data +#' \emph{arXiv preprint} arXiv:1711.08147. #' @examples #' p <- c(pbinom(1,8,0.5),pbinom(1,5,0.75),pbinom(1,6,0.6)) #' p.set <-list(pbinom(0:8,8,0.5),pbinom(0:5,5,0.75),pbinom(0:6,6,0.6)) #' MBonf.p.adjust(p,p.set) +#' ## Compare with the traditional Bonferroni adjustment +#' p.adjust(p,method = "bonferroni") +#' ## Compare with the Tarone adjustment +#' Tarone.p.adjust(p,p.set) #' @export MBonf.p.adjust <- function(p, p.set, alpha = 0.05, make.decision = FALSE){ @@ -78,6 +86,17 @@ MBonf.p.adjust <- function(p, p.set, alpha = 0.05, make.decision = FALSE){ #' @seealso \code{\link{Tarone.p.adjust}}, \code{\link{MBonf.p.adjust}}, \code{\link[stats]{p.adjust}}. #' @note The arguments include three parts, the available p-values need to be reorganized in advance. Gather all available p-values for continuous data as \code{pc}, and all available p-values for discrete data as \code{pd}. The attainable p-value refers to the element of domain set of p-value for the corresponding hypothesis for discrete test statistics, the p-value can only take finite values bewtween 0 and 1, that is, the attainable p-values for discrete case are finite and countable, so we can assign them in a finite list \code{pd.set}. The function returns the adjusted p-values with the first part for continuous data of the same length as \code{pc}, and second part for discrete data of the same length as \code{pd} #' @author Yalin Zhu +#' @references +#' Zhu, Y., & Guo, W. (2017). +#' Familywise error rate controlling procedures for discrete data +#' \emph{arXiv preprint} arXiv:1711.08147. +#' +#' @examples +#' pd <- c(pbinom(1,8,0.5),pbinom(1,5,0.75)); pc <- c(0.04, 0.1) +#' pd.set <-list(pbinom(0:8,8,0.5),pbinom(0:5,5,0.75)) +#' MixBonf.p.adjust(pc,pd,pd.set) +#' ## Compare with the traditional Bonferroni adjustment +#' p.adjust(c(pc,pd),method = "bonferroni") #' @export MixBonf.p.adjust <- function(pc, pd, pd.set, alpha = 0.05, make.decision = FALSE){ mc <- length(pc); md <- length(pd); m <- mc+md diff --git a/R/FWERSU.R b/R/FWERSU.R index 58f1faa..78cb94f 100644 --- a/R/FWERSU.R +++ b/R/FWERSU.R @@ -13,14 +13,21 @@ #' @seealso \code{\link{Roth.p.adjust}}, \code{\link[stats]{p.adjust}}. #' @author Yalin Zhu #' @references +#' Zhu, Y., & Guo, W. (2017). +#' Familywise error rate controlling procedures for discrete data +#' \emph{arXiv preprint} arXiv:1711.08147. +#' #' Hochberg, Y. (1988). #' A sharper Bonferroni procedure for multiple tests of significance. #' \emph{ Biometrika}, \strong{75}: 800-803. -#' #' @examples #' p <- c(pbinom(1,8,0.5),pbinom(1,5,0.75),pbinom(1,6,0.6)) #' p.set <-list(pbinom(0:8,8,0.5),pbinom(0:5,5,0.75),pbinom(0:6,6,0.6)) #' MHoch.p.adjust(p,p.set) +#' ## Compare with the traditional Hochberg adjustment +#' p.adjust(p,method = "hochberg") +#' ## Compare with the Roth adjustment +#' Roth.p.adjust(p,p.set) #' @export MHoch.p.adjust <- function(p,p.set, alpha = 0.05, make.decision = FALSE){ @@ -61,7 +68,6 @@ MHoch.p.adjust <- function(p,p.set, alpha = 0.05, make.decision = FALSE){ #' Hochberg, Y. (1988). #' A sharper Bonferroni procedure for multiple tests of significance. #' \emph{ Biometrika}, \strong{75}: 800-803. -#' #' @examples #' p <- c(pbinom(1,8,0.5),pbinom(1,5,0.75),pbinom(1,6,0.6)) #' p.set <-list(pbinom(0:8,8,0.5),pbinom(0:5,5,0.75),pbinom(0:6,6,0.6)) diff --git a/R/MHTdiscrete.R b/R/MHTdiscrete.R index ad00757..f92ad37 100644 --- a/R/MHTdiscrete.R +++ b/R/MHTdiscrete.R @@ -2,7 +2,7 @@ #' #' The MHTdiscrete package provides two categories of important functions for discrete data mutliple hypothese testing: #' @section FWER controlling procedures: -#' Single-step: MBonf.p.adjust, Tarone.p.adjust. +#' Single-step: MBonf.p.adjust, MixBonf.p.adjust, Tarone.p.adjust. #' #' Step-down: MHolm.p.adjust, TH.p.adjust. #' diff --git a/R/Pval.R b/R/Pval.R index 31cc903..40eadd4 100644 --- a/R/Pval.R +++ b/R/Pval.R @@ -5,12 +5,16 @@ #' @usage #' getPval(raw.data, test.type, alternative) #' @param raw.data original data set with count number for treatment group and study group. The data set type could be \code{\link[base]{matrix}} or \code{\link[base]{data.frame}}. -#' @param test.type there are two discrete test available now, must be one of \code{"FET"} for Fisher's Exact Test and \code{"EBT"} for Exact Binomial Test. +#' @param test.type there are two discrete test available now, must be one of \code{"FET"} for Fisher's Exact Test and \code{"BET"} for Binomial Exact Test. #' @param alternative indicates the alternative hypothesis and must be one of \code{"two.sided"}, \code{"greater"} or \code{"less"}. #' @return #' A numeric vector of the adjusted p-values (of the same length as \eqn{p}). #' @author Yalin Zhu #' @references +#' Zhu, Y., & Guo, W. (2017). +#' Familywise error rate controlling procedures for discrete data +#' \emph{arXiv preprint} arXiv:1711.08147. +#' #' Clopper, C. J. & Pearson, E. S. (1934). #' The use of confidence or fiducial limits illustrated in the case of the binomial. #' \emph{Biometrika}, \strong{26}: 404-413. @@ -32,7 +36,7 @@ #' p.set <- getPval(raw.data=df, test.type = "FET",alternative = "two.sided")[[2]]; p.set #' @export -getPval <- function(raw.data, test.type = c("FET", "EBT"), alternative = c("two.sided","greater","less")){ +getPval <- function(raw.data, test.type = c("FET", "BET"), alternative = c("two.sided","greater","less")){ if (class(raw.data)!="data.frame" & class(raw.data)!="matrix"){ stop("The raw data type has to be 'data.frame' or 'matrix'") } @@ -50,7 +54,7 @@ getPval <- function(raw.data, test.type = c("FET", "EBT"), alternative = c("two. p.set[[i]] <- sort(s) } } - if (test.type=="EBT"){ + if (test.type=="BET"){ for (i in 1:nrow(raw.data)){ p[i] <- stats::binom.test(c(raw.data[i,1],raw.data[i,2]), p = 0.5, alternative = alternative)[[3]] s<-c()