Skip to content

Commit

Permalink
update to v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
allenzhuaz authored Nov 23, 2017
1 parent a03ef28 commit 4498dc1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
8 changes: 8 additions & 0 deletions R/FWERSD.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
#' @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.
#' @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))
#' 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){
Expand Down
19 changes: 19 additions & 0 deletions R/FWERSS.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions R/FWERSU.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion R/MHTdiscrete.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down
10 changes: 7 additions & 3 deletions R/Pval.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'")
}
Expand All @@ -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()
Expand Down

0 comments on commit 4498dc1

Please sign in to comment.