TFisher/0000755000177700017770000000000013254445215013155 5ustar herbrandtherbrandtTFisher/NAMESPACE0000644000177700017770000000126513254341463014400 0ustar herbrandtherbrandt# Generated by roxygen2: do not edit by hand export(p.soft) export(p.soft.omni) export(p.tfisher) export(p.tfisher.omni) export(p.tpm) export(p.tpm.omni) export(power.soft) export(power.tfisher) export(power.tpm) export(q.soft) export(q.tfisher) export(q.tpm) export(stat.soft) export(stat.soft.omni) export(stat.tfisher) export(stat.tfisher.omni) export(stat.tpm) export(stat.tpm.omni) importFrom(Matrix,nearPD) importFrom(mvtnorm,pmvnorm) importFrom(sn,psn) importFrom(stats,dbinom) importFrom(stats,dnorm) importFrom(stats,integrate) importFrom(stats,pchisq) importFrom(stats,pgamma) importFrom(stats,pnorm) importFrom(stats,qnorm) importFrom(stats,uniroot) TFisher/R/0000755000177700017770000000000013200003750013337 5ustar herbrandtherbrandtTFisher/R/p.tpm.omni.R0000644000177700017770000000177213254343065015507 0ustar herbrandtherbrandt#' CDF of omnibus truncated product method statistic under the null hypothesis. #' @param q - quantile, could be a vector. #' @param n - dimension parameter, i.e. the number of p-values to be combined. #' @param TAU1 - a vector of truncation parameters. Must be in non-descending order. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence #' @return The left-tail probability of the null distribution of omnibus truncated product method statistic. #' @seealso \code{\link{stat.tpm.omni}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' q = 0.05 #' n = 20 #' TAU1 = c(0.01, 0.05, 0.5, 1) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' p.tpm.omni(q=q, n=n, TAU1=TAU1, M=M) #' @export #' @importFrom mvtnorm pmvnorm #' p.tpm.omni <- function(q, n, TAU1, M=NULL){ p.tfisher.omni(q, n, TAU1, rep(1,length(TAU1)), M=M) } TFisher/R/p.soft.omni.R0000644000177700017770000000206313254343012015644 0ustar herbrandtherbrandt#' CDF of omnibus soft-thresholding Fisher's p-value combination statistic under the null hypothesis. #' @param q - quantile, could be a vector. #' @param n - dimension parameter, i.e. the number of p-values to be combined. #' @param TAU1 - a vector of truncation parameters (=normalization parameters). Must be in non-descending order. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return The left-tail probability of the null distribution of omnibus soft-thresholding Fisher's p-value combination statistic. #' @seealso \code{\link{stat.soft.omni}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' q = 0.01 #' n = 20 #' TAU1 = c(0.01, 0.05, 0.5, 1) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' p.soft.omni(q=q, n=n, TAU1=TAU1, M=M) #' @export #' @importFrom mvtnorm pmvnorm p.soft.omni <- function(q, n, TAU1, M=NULL){ p.tfisher.omni(q, n, TAU1, TAU1, M) } TFisher/R/p.tfisher.R0000644000177700017770000000406413254343055015406 0ustar herbrandtherbrandt#' CDF of thresholding Fisher's p-value combination statistic under the null hypothesis. #' @param q - quantile, could be a vector. #' @param n - dimension parameter, i.e. the number of p-values to be combined. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. #' @param tau2 - normalization parameter. tau2 >= tau1. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @param mu - the mean of TFisher statistics. Default = NULL. #' @param sigma2 - the variance of TFisher statistics. Default = NULL. #' @param p0 - the point masse of TFisher statistics. Default = NULL. #' @return The left-tail probability of the null distribution of thresholding Fisher's p-value combination statistic at the given quantile. #' @seealso \code{\link{stat.tfisher}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' pval <- runif(20) #' tfstat <- stat.tfisher(p=pval, tau1=0.25, tau2=0.75) #' p.tfisher(q=tfstat, n=20, tau1=0.25, tau2=0.75) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' p.tfisher(q=tfstat, n=20, tau1=0.25, tau2=0.75, M=M) #' @export #' @importFrom stats dbinom pchisq pgamma #' @importFrom mvtnorm pmvnorm p.tfisher <- function(q,n,tau1,tau2,M=NULL,mu=NULL,sigma2=NULL, p0=NULL){ if(is.null(M)){ return((sum(pchisq(q+2*(1:n)*log(tau1/tau2),2*(1:n))*dbinom(1:n, n, tau1)) + (0= tau1. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return Quantile of thresholding Fisher's p-value combination statistic. #' @seealso \code{\link{stat.tfisher}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' ## The 0.05 critical value of TFisher statistic when n = 10: #' q.tfisher(p=.95, n=20, tau1=0.05, tau2=0.25) #' ## when corrrelated #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' q.tfisher(p=.95, n=20, tau1=0.05, tau2=0.25, M=M) #' @export #' @importFrom mvtnorm pmvnorm #' q.tfisher <- function(p, n, tau1, tau2, M=NULL){ if(is.null(M)){ if(p 0 && numIter < maxnumIter) { if(p_cal_lower > p) { lower = lower * 1.1 p_cal_lower = p.tfisher(lower, n, tau1, tau2) } if(p_cal_upper < p) { upper = upper * 1.1 p_cal_upper = p.tfisher(upper, n, tau1, tau2) } numIter = numIter + 1 } q = mean(c(lower, upper)) p_cal = p.tfisher(q, n, tau1, tau2) error = (p_cal - p)/p numIter = 1 while (abs(error) > 1e-08 && numIter < maxnumIter) { if(error > 0) { upper = q q = mean(c(lower, upper)) p_cal = p.tfisher(q, n, tau1, tau2) error = (p_cal - p)/p }else{ lower = q q = mean(c(lower, upper)) p_cal = p.tfisher(q, n, tau1, tau2) error = (p_cal - p)/p } numIter = numIter + 1 } if(numIter < maxnumIter) { return(q) }else{ return(paste0("The quantile is larger than ", upper)) } } }else{ n = length(M[1,]) #truncation parameter bound = qnorm(1-tau1/2) p0 = pmvnorm(lower=-rep(bound,n),upper=rep(bound,n),sigma=M)[1] if(p 0 && numIter < maxnumIter) { if(p_cal_lower > p) { lower = lower * 1.1 p_cal_lower = Fw(lower) } if(p_cal_upper < p) { upper = upper * 1.1 p_cal_upper = Fw(upper) } numIter = numIter + 1 } q = mean(c(lower, upper)) p_cal = Fw(q) error = (p_cal - p)/p numIter = 1 while (abs(error) > 1e-08 && numIter < maxnumIter) { if(error > 0) { upper = q q = mean(c(lower, upper)) p_cal = Fw(q) error = (p_cal - p)/p }else{ lower = q q = mean(c(lower, upper)) p_cal = Fw(q) error = (p_cal - p)/p } numIter = numIter + 1 } if(numIter < maxnumIter) { return(q) }else{ return(paste0("The quantile is larger than ", upper)) } } } } TFisher/R/q.soft.R0000644000177700017770000000202013254343170014702 0ustar herbrandtherbrandt#' Quantile of soft-thresholding Fisher's p-value combination statistic under the null hypothesis. #' @param p - a scalar left probability that defines the quantile. #' @param n - dimension parameter, i.e. the number of input p-values. #' @param tau1 - truncation parameter=normalization parameter. tau1 > 0. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return Quantile of soft-thresholding Fisher's p-value combination statistic. #' @seealso \code{\link{stat.soft}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' ## The 0.05 critical value of soft-thresholding statistic when n = 10: #' q.soft(p=.99, n=20, tau1 = 0.05) #' M = matrix(0.9,20,20) + diag(1-0.9,20) #' q.soft(p=.99, n=20, tau1 = 0.05, M=M) #' @export #' @importFrom mvtnorm pmvnorm #' q.soft <- function(p, n, tau1,M=NULL){ q.tfisher(p, n, tau1, tau1, M=M) } TFisher/R/p.soft.R0000644000177700017770000000215213254343031014703 0ustar herbrandtherbrandt#' CDF of soft-thresholding Fisher's p-value combination statistic under the null hypothesis. #' @param q - quantile, could be a vector. #' @param n - dimension parameter, i.e. the number of p-values to be combined. #' @param tau1 - truncation parameter=normalization parameter. tau1 > 0. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return The left-tail probability of the null distribution of soft-thresholding Fisher's p-value combination statistic at the given quantile. #' @seealso \code{\link{stat.soft}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' pval <- runif(100) #' softstat <- stat.soft(p=pval, tau1=0.05) #' p.soft(q=softstat, n=100, tau1=0.05) #' M = matrix(0.3,100,100) + diag(1-0.3,100) #' p.soft(q=softstat, n=100, tau1=0.05, M=M) #' @export #' @importFrom stats dbinom pchisq pgamma #' @importFrom mvtnorm pmvnorm p.soft <- function(q,n,tau1,M=NULL){ return(p.tfisher(q,n,tau1,tau1,M=M)) } TFisher/R/p.tfisher.omni.R0000644000177700017770000000542713254343044016351 0ustar herbrandtherbrandt#' CDF of omnibus thresholding Fisher's p-value combination statistic under the null hypothesis. #' @param q - quantile, could be a vector. #' @param n - dimension parameter, i.e. the number of p-values to be combined. #' @param TAU1 - a vector of truncation parameters. Must be in non-descending order. #' @param TAU2 - a vector of normalization parameters. Must be in non-descending order. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @param P0 - a vector of point masses of TFisher statistics. Default = NULL. #' @return The left-tail probability of the null distribution of omnibus thresholding Fisher's p-value combination statistic. #' @seealso \code{\link{stat.tfisher.omni}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' q = 0.05 #' n = 20 #' TAU1 = c(0.01, 0.05, 0.5, 1) #' TAU2 = c(0.1, 0.2, 0.5, 1) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' p.tfisher.omni(q=q, n=n, TAU1=TAU1, TAU2=TAU2, M=M) #' @export #' @importFrom mvtnorm pmvnorm #' @importFrom Matrix nearPD #' p.tfisher.omni <- function(q, n, TAU1, TAU2, M=NULL,P0=NULL){ if(is.null(M)){ E = 2*n*TAU1*(1+log(TAU2/TAU1)) nn = length(TAU1) minTAU = pmin(matrix(TAU1,nn,nn), t(matrix(TAU1,nn,nn))) part1 = 4*n*minTAU part2 = part1*(1+log(matrix(TAU2,nn,nn)/minTAU))*(1+log(t(matrix(TAU2,nn,nn))/minTAU)) part3 = 4*n*matrix(TAU1,nn,nn)*t(matrix(TAU1,nn,nn))*(1+log(matrix(TAU2,nn,nn)/matrix(TAU1,nn,nn)))*(1+log(t(matrix(TAU2,nn,nn))/t(matrix(TAU1,nn,nn)))) COV = part1 + part2 - part3 COV[lower.tri(COV)] = t(COV)[lower.tri(COV)] result = rep(NA, length(q)) for(i in 1:length(q)){ Q = mapply(function(x,y)q.tfisher(1-q, n, x,y),TAU1,TAU2) result[i] = 1-pmvnorm(lower=-Inf,upper=Q,mean=E,sigma=COV,abseps=1e-6)[1] } return(result) }else{ p = length(TAU1) if(is.null(P0)){ #truncation parameter bound = qnorm(1-TAU1/2) P0 = sapply(1:p,function(x)pmvnorm(lower=-rep(bound[x],n),upper=rep(bound[x],n),sigma=M)[1]) } if(1-min(P0)0)){ TAU1 = TAU1[-id]; TAU2 = TAU2[-id] } E = 2*n*TAU1*(1+log(TAU2/TAU1)) COV = getTFisherCovM(M, TAU1, TAU2) if(any(eigen(COV)$value<0)){ COV = as.matrix(nearPD(COV)$mat) } #Q = mapply(function(x,y)q.tfisher(1-q, n, x,y, M),TAU1,TAU2) Q = mapply(function(x,y)q.tfisher_N(1-q, n, x,y, M),TAU1,TAU2) result = 1-pmvnorm(lower=-Inf,upper=Q,mean=E,sigma=COV,abseps=1e-6)[1] return(result) } } } TFisher/R/q.tpm.R0000644000177700017770000000217113254343160014535 0ustar herbrandtherbrandt#' Quantile of truncated product method statistic under the null hypothesis. #' @param p - a scalar left probability that defines the quantile. #' @param n - dimension parameter, i.e. the number of input p-values. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return Quantile of truncated product method statistic. #' @seealso \code{\link{stat.tpm}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' 2. Zaykin, D.V., Zhivotovsky, L. A., Westfall, P.H. and Weir, B.S. (2002), Truncated product method for combining P-values. Genet. Epidemiol., 22: 170–185. doi:10.1002/gepi.0042 #' #' @examples #' ## The 0.05 critical value of TPM statistic when n = 10: #' q.tpm(p=.95, n=20, tau1 = 0.05) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' q.tpm(p=.95, n=20, tau1 = 0.05, M=M) #' @export #' @importFrom mvtnorm pmvnorm #' q.tpm <- function(p, n, tau1, M=NULL){ q.tfisher(p, n, tau1, 1, M=M) } TFisher/R/functions.R0000644000177700017770000001730613254341127015515 0ustar herbrandtherbrandt#' @importFrom stats pnorm qnorm dnorm uniroot pgamma #' @importFrom mvtnorm pmvnorm ######################## #Skew Normal Estimation# ######################## findsnalpha = function(skewness){ skewness = sign(skewness)*min(0.9952717,abs(skewness)) delta = sqrt(pi/2*(skewness^2)^(1/3)/((skewness^2)^(1/3)+(2-pi/2)^(2/3))) return(sign(skewness)*delta/sqrt(1-delta^2)) } findsnomega = function(variance, alpha){ delta2 = alpha^2/(1+alpha^2) return(sqrt(variance/(1-2*delta2/pi))) } findsnxi = function(m, alpha, omega){ delta = alpha/sqrt(1+alpha^2) return(m-omega*delta*sqrt(2/pi)) } ################## #Gaussian mixture# ################## F0 = function(q){ return(pnorm(q,0,1)) } F1 = function(q,eps,mu){ return(eps*pnorm(q,mu,1)+(1-eps)*pnorm(q,0,1)) } F0_1 = function(p){ return(qnorm(p,0,1)) } F1_1 = function(p,eps,mu,br=c(-1000,1000)){ G = function(q) F1(q,eps,mu) - p return(uniroot(G,br)$root) } vecF1_1 = Vectorize(F1_1, vectorize.args = "p") D = function(q, eps, mu){ return(1-F1(F0_1(1-q), eps, mu)) } D_1 = function(q, eps, mu){ return(1-F0(vecF1_1(1-q, eps, mu))) } ############################### #Variance-Covariance Estimation ############################### getTFisherMean = function(n, tau1, tau2){ 2*n*tau1*(1-log(tau1/tau2)) } getTFisherCovM = function(M, TAU1, TAU2){ K = length(TAU1) #outer(1:K,1:K,function(r,c)getTFisherCov_v1(M, TAU1[r], TAU2[r], TAU1[c], TAU2[c])) COV = matrix(NA, K, K) for(i in 1:K){ for(j in i:K){ COV[i,j] = getTFisherCov_v1(M, TAU1[i], TAU2[i], TAU1[j], TAU2[j]) } } COV[lower.tri(COV)] = t(COV)[lower.tri(COV)] return(COV) } getTFisherCov_v1 = function(M, tau11, tau21, tau12, tau22){ #calculate cov(Ui, Uj), where Ui=Xi^2I(Xi^2>b), Uj=Xj^2I(Xj^2>b) #where cor(Xi,Xj)=rho_ij, b=qnorm(1-tau1/2) #variance = sum_{ij}cov(Ui, Uj) n = length(M[1,]) #Define Constants for W1 b_1 = qnorm(1-tau11/2) b2_1 = b_1^2 phib_1 = dnorm(b_1) bphib_1 = b_1*phib_1 m0_1 = 1-tau11 m2_1 = m0_1 - 2*bphib_1 m4_1 = 3*m2_1 - 2*b2_1*bphib_1 varU_1 = 3-m4_1 - (1-m2_1)^2 #VAR=var(Ui)=var(Uj) varY_1 = 4*tau11*(1+(1-tau11)*(1-log(tau11/tau21))^2) #Define Constants for W2 b_2 = qnorm(1-tau12/2) b2_2 = b_2^2 phib_2 = dnorm(b_2) bphib_2 = b_2*phib_2 m0_2 = 1-tau12 m2_2 = m0_2 - 2*bphib_2 m4_2 = 3*m2_2 - 2*b2_2*bphib_2 varU_2 = 3-m4_2 - (1-m2_2)^2 #VAR=var(Ui)=var(Uj) varY_2 = 4*tau12*(1+(1-tau12)*(1-log(tau12/tau22))^2) varRatio = sqrt(varY_1/varU_1*varY_2/varU_2) # Integration Domain x = seq(-8,8,length.out=1000) dx = x[2] - x[1] x2 = x^2; x1trunc = x2*(x2>b2_1) #x2trunc = x2*(x2>b2_2)# phix = dnorm(x) # Extract duplicate rho tbl = table(M[col(M)!=row(M)]) # off-diagonals RHO = as.numeric(names(tbl)) FREQ = as.numeric(tbl) tau1min = min(tau11,tau12) COV = 4*n*tau1min*(1+(1+log(tau21/tau1min))*(1+log(tau22/tau1min))-tau11*tau12/tau1min*(1+log(tau21/tau11))*(1+log(tau22/tau12))) if(n==1){ return(COV) }else{ for(i in 1:length(RHO)){ ################################# rho = RHO[i] # rho2 = rho^2 # sqrho2 = sqrt(1-rho2) # xx = -rho*x # A = xx/sqrho2; B = b_2/sqrho2 # fx = A+B; fx2 = fx^2; fx3 = fx^3# gx = A-B; gx3 = gx^3 # #first part above 20% time####### ################################# phigx = dnorm(gx) # phifx = dnorm(fx) # Phigx = pnorm(gx) # Phifx = pnorm(fx) # #second part above 75% time###### ################################# m0x = Phifx - Phigx # m1x = phigx - phifx # m2x = m0x + m1x*fx - 2*B*phigx # m2x = m0x + gx*phigx - fx*phifx # #third part above 5% time######## hx = phix*(rho2*x2*m0x + (1-rho2)*m2x + 2*rho*sqrho2*x*m1x) covU = 2*rho2*b2_1*bphib_1 + (1+2*rho2-(tau12+2*bphib_2))*(tau11+2*bphib_1) - sum(x1trunc*hx*dx) covY = covU*varRatio COV = COV + FREQ[i]*covY } return(COV) } } getTFisherVar_v1 = function(M, tau1, tau2){ #calculate cov(Ui, Uj), where Ui=Xi^2I(Xi^2>b), Uj=Xj^2I(Xj^2>b) #where cor(Xi,Xj)=rho_ij, b=qnorm(1-tau1/2) #variance = sum_{ij}cov(Ui, Uj) n = length(M[1,]) #Define Constants b = qnorm(1-tau1/2) b2 = b^2 phib = dnorm(b) bphib = b*phib m0 = 1-tau1 m2 = m0 - 2*bphib m4 = 3*m2 - 2*b2*bphib varU = 3-m4 - (1-m2)^2 #VAR=var(Ui)=var(Uj) varY = 4*tau1*(1+(1-tau1)*(1-log(tau1/tau2))^2) varRatio = varY/varU # Integration Domain x = seq(-8,8,length.out=1000) dx = x[2] - x[1] x2 = x^2; x2trunc = x2*(x2>b2) phix = dnorm(x) # Extract duplicate rho tbl = table(M[col(M)!=row(M)]) # off-diagonals RHO = as.numeric(names(tbl)) FREQ = as.numeric(tbl) if(n==1){ return(varY) }else{ VAR = n*varY # the variance under independence for(i in 1:length(RHO)){ ################################# rho = RHO[i] # rho2 = rho^2 # sqrho2 = sqrt(1-rho2) # xx = -rho*x # A = xx/sqrho2; B = b/sqrho2 # fx = A+B; fx2 = fx^2; fx3 = fx^3# gx = A-B; gx3 = gx^3 # #first part above 20% time####### ################################# phigx = dnorm(gx) # phifx = dnorm(fx) # Phigx = pnorm(gx) # Phifx = pnorm(fx) # #second part above 75% time###### ################################# m0x = Phifx - Phigx # m1x = phigx - phifx # m2x = m0x + m1x*fx - 2*B*phigx # m2x = m0x + gx*phigx - fx*phifx # #third part above 5% time######## hx = phix*(rho2*x2*m0x + (1-rho2)*m2x + 2*rho*sqrho2*x*m1x) covU = 2*rho2*b2*bphib + (1+2*rho2-(tau1+2*bphib))*(tau1+2*bphib) - sum(x2trunc*hx*dx) covY = covU*varRatio VAR = VAR + FREQ[i]*covY } return(VAR) } } q.tfisher_N <- function(p, n, tau1, tau2, M){ n = length(M[1,]) #truncation parameter bound = qnorm(1-tau1/2) p0 = pmvnorm(lower=-rep(bound,n),upper=rep(bound,n),sigma=M)[1] if(p 0 && numIter < maxnumIter) { if(p_cal_lower > p) { lower = lower * 1.1 p_cal_lower = Fw(lower) } if(p_cal_upper < p) { upper = upper * 1.1 p_cal_upper = Fw(upper) } numIter = numIter + 1 } if(p_cal_lower>p){ return(lower) }else{ q = mean(c(lower, upper)) p_cal = Fw(q) error = (p_cal - p)/p numIter = 1 while (abs(error) > 1e-08 && numIter < maxnumIter) { if(error > 0) { upper = q q = mean(c(lower, upper)) p_cal = Fw(q) error = (p_cal - p)/p }else{ lower = q q = mean(c(lower, upper)) p_cal = Fw(q) error = (p_cal - p)/p } numIter = numIter + 1 } if(numIter < maxnumIter) { return(q) }else{ return(paste0("The quantile is larger than ", upper)) } } } } TFisher/R/power.soft.R0000644000177700017770000000244313254343140015604 0ustar herbrandtherbrandt#' Statistical power of soft-thresholding Fisher's p-value combination test under Gaussian mixture model. #' @param alpha - type-I error rate. #' @param n - dimension parameter, i.e. the number of input p-values. #' @param tau1 - truncation parameter=normalization parameter. tau1 > 0. #' @param eps - mixing parameter of the Gaussian mixture. #' @param mu - mean of non standard Gaussian model. #' @return Power of the soft-thresholding Fisher's p-value combination test. #' @details We consider the following hypothesis test, #' \deqn{H_0: X_i\sim F_0, H_a: X_i\sim (1-\epsilon)F_0+\epsilon F_1} #' , where \eqn{\epsilon} is the mixing parameter, #' \eqn{F_0} is the standard normal CDF and \eqn{F = F_1} is the CDF of normal distribution with \eqn{\mu} defined by mu and \eqn{\sigma = 1}. #' #' @seealso \code{\link{stat.soft}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' alpha = 0.05 #' #If the alternative hypothesis Gaussian mixture with eps = 0.1 and mu = 1.2:# #' power.soft(alpha, 100, 0.05, eps = 0.1, mu = 1.2) #' @export #' @importFrom sn psn #' power.soft <- function(alpha,n,tau1,eps=0,mu=0){ power.tfisher(alpha,n,tau1,tau1,eps,mu) } TFisher/R/p.tpm.R0000644000177700017770000000233413254343106014535 0ustar herbrandtherbrandt#' CDF of truncated product method statistic under the null hypothesis. #' @param q - quantile, could be a vector. #' @param n - dimension parameter, i.e. the number of p-values to be combined. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return The left-tail probability of the null distribution of truncated product method statistic at the given quantile. #' @seealso \code{\link{stat.tpm}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' 2. Zaykin, D.V., Zhivotovsky, L. A., Westfall, P.H. and Weir, B.S. (2002), Truncated product method for combining P-values. Genet. Epidemiol., 22: 170–185. doi:10.1002/gepi.0042 #' #' @examples #' pval <- runif(100) #' tpmstat <- stat.tpm(p=pval, tau1=0.05) #' p.tpm(q=tpmstat, n=100, tau1=0.05) #' M = matrix(0.3,100,100) + diag(1-0.3,100) #' p.tpm(q=tpmstat, n=100, tau1=0.05, M=M) #' @export #' @importFrom stats dbinom pchisq pgamma #' @importFrom mvtnorm pmvnorm p.tpm <- function(q,n,tau1,M=NULL){ return(p.tfisher(q,n,tau1,1,M=M)) } TFisher/R/stat.tpm.omni.R0000644000177700017770000000253213254343207016214 0ustar herbrandtherbrandt#' Construct omnibus truncated product method statistic. #' @param p - input p-values. #' @param TAU1 - a vector of truncation parameters. Must be in non-descending order. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return omni - omnibus truncated product method statistic. #' @return pval - p-values of each truncated product method tests. #' @details Let \eqn{x_{i}}, \eqn{i = 1,...,n} be a sequence of individual statistics with #' correlation matrix M, \eqn{p_{i}} be the corresponding two-sided p-values, then the truncated product method statistics #' \deqn{TPM_j = \sum_{i=1}^n -2\log(p_i)I(p_i\leq\tau_{1j})}, \eqn{j = 1,...,d}. #' The omnibus test statistic is the minimum p-value of these truncated product method tests, #' \deqn{W_o = min_j G_j(TPM_j)}, where \eqn{G_j} is the survival function of \eqn{TPM_j}. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' pval = runif(20) #' TAU1 = c(0.01, 0.05, 0.5, 1) #' stat.tpm.omni(p=pval, TAU1=TAU1) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' stat.tpm.omni(p=pval, TAU1=TAU1, M=M) #' @export #' @importFrom mvtnorm pmvnorm stat.tpm.omni <- function(p, TAU1, M=NULL){ m = length(TAU1) stat.tfisher.omni(p,TAU1,rep(1,m),M) } TFisher/R/stat.tfisher.omni.R0000644000177700017770000000415713254343226017066 0ustar herbrandtherbrandt#' Construct omnibus thresholding Fisher's (TFisher) p-value combination statistic. #' @param p - input p-values from potentially correlated input sstatistics. #' @param TAU1 - a vector of truncation parameters. Must be in non-descending order. #' @param TAU2 - a vector of normalization parameters. Must be in non-descending order. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence #' @param MU - a vector of means of TFisher statistics. Default = NULL. #' @param SIGMA2 - a vector of variances of TFisher statistics. Default = NULL. #' @param P0 - a vector of point masses of TFisher statistics. Default = NULL. #' @return omni - omnibus TFisher statistic. #' @return pval - p-values of each TFisher tests. #' @details Let \eqn{x_{i}}, \eqn{i = 1,...,n} be a sequence of individual statistics with #' correlation matrix M, \eqn{p_{i}} be the corresponding two-sided p-values, then the TFisher statistics #' \deqn{TFisher_j = \sum_{i=1}^n -2\log(p_i/\tau_{2j})I(p_i\leq\tau_{1j})}, \eqn{j = 1,...,d}. #' The omnibus test statistic is the minimum p-value of these thresholding tests, #' \deqn{W_o = min_j G_j(Soft_j)}, where \eqn{G_j} is the survival function of \eqn{Soft_j}. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' pval = runif(20) #' TAU1 = c(0.01, 0.05, 0.5, 1) #' TAU2 = c(0.1, 0.2, 0.5, 1) #' stat.tfisher.omni(p=pval, TAU1=TAU1, TAU2=TAU2) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' stat.tfisher.omni(p=pval, TAU1=TAU1, TAU2=TAU2, M=M) #' @export #' @importFrom mvtnorm pmvnorm stat.tfisher.omni <- function(p, TAU1, TAU2, M=NULL,MU=NULL,SIGMA2=NULL,P0=NULL){ n = length(p) tfisherstat = mapply(function(x,y) stat.tfisher(p,x,y), TAU1, TAU2) if(!is.null(MU)&!is.null(SIGMA2)&!is.null(P0)){ pvals = mapply(function(x,y,z,a,b,c) 1-p.tfisher(x, n, y, z, M,a,b,c), tfisherstat, TAU1, TAU2,MU,SIGMA2,P0) }else{ pvals = mapply(function(x,y,z) 1-p.tfisher(x, n, y, z, M), tfisherstat, TAU1, TAU2) } return(list(omni=min(pvals),pvals=pvals)) } TFisher/R/stat.tpm.R0000644000177700017770000000153413254343202015247 0ustar herbrandtherbrandt#' Construct truncated product method statistic. #' @param p - input p-values. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. #' @return Truncated product method statistic. #' @details Let \eqn{p_{i}}, \eqn{i = 1,...,n} be a sequence of p-values, the TPM statistic #' \deqn{TPM = \sum_{i=1}^n -2\log(p_i)I(p_i\leq\tau_2)}. TPM is the special case of TFisher when tau2=1. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' 2. Zaykin, D.V., Zhivotovsky, L. A., Westfall, P.H. and Weir, B.S. (2002), Truncated product method for combining P-values. Genet. Epidemiol., 22: 170–185. doi:10.1002/gepi.0042 #' #' @examples #' pval <- runif(100) #' stat.tpm(p=pval, tau1=0.05) #' @export stat.tpm <- function(p,tau1){ return(stat.tfisher(p,tau1,1)) } TFisher/R/stat.soft.R0000644000177700017770000000141313254343233015422 0ustar herbrandtherbrandt#' Construct soft-thresholding Fisher's p-value combination statistic. #' @param p - input p-values. #' @param tau1 - truncation parameter=normalization parameter. tau1 > 0. #' @return Soft-thresholding Fisher's p-value combination statistic. #' @details Let \eqn{p_{i}}, \eqn{i = 1,...,n} be a sequence of p-values, the soft-thresholding statistic #' \deqn{Soft = \sum_{i=1}^n -2\log(p_i/\tau_1)I(p_i\leq\tau_1)}. Soft-thresholding is the special case of TFisher when tau1=tau2. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' pval <- runif(100) #' stat.soft(p=pval, tau1=0.05) #' @export stat.soft <- function(p,tau1){ return(stat.tfisher(p,tau1,tau1)) } TFisher/R/stat.soft.omni.R0000644000177700017770000000255013254343236016371 0ustar herbrandtherbrandt#' Construct omnibus soft-thresholding Fisher's p-value combination statistic. #' @param p - input p-values. #' @param TAU1 - a vector of truncation parameters (=normalization parameters). Must be in non-descending order. #' @param M - correlation matrix of the input statistics. Default = NULL assumes independence. #' @return omni - omnibus soft-thresholding statistic. #' @return pval - p-values of each soft-thresholding tests. #' @details Let \eqn{x_{i}}, \eqn{i = 1,...,n} be a sequence of individual statistics with #' correlation matrix M, \eqn{p_{i}} be the corresponding two-sided p-values, then the soft-thresholding statistics #' \deqn{Soft_j = \sum_{i=1}^n -2\log(p_i/\tau_{1j})I(p_i\leq\tau_{1j})}, \eqn{j = 1,...,d}. #' The omnibus test statistic is the minimum p-value of these soft-thresholding tests, #' \deqn{W_o = min_j G_j(Soft_j)}, where \eqn{G_j} is the survival function of \eqn{Soft_j}. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' #' @examples #' pval = runif(20) #' TAU1 = c(0.01, 0.05, 0.5, 1) #' stat.soft.omni(p=pval, TAU1=TAU1) #' M = matrix(0.3,20,20) + diag(1-0.3,20) #' stat.soft.omni(p=pval, TAU1=TAU1, M=M) #' @export #' @importFrom mvtnorm pmvnorm stat.soft.omni <- function(p, TAU1, M=NULL){ stat.tfisher.omni(p,TAU1,TAU1,M) } TFisher/R/stat.tfisher.R0000644000177700017770000000142713254343221016115 0ustar herbrandtherbrandt#' Construct thresholding Fisher's p-value combination statistic. #' @param p - input p-values. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. #' @param tau2 - normalization parameter. tau2 >= tau1. #' @return Thresholding Fisher's p-value combination statistic. #' @details Let \eqn{p_{i}}, \eqn{i = 1,...,n} be a sequence of p-values, the thresholding Fisher's p-value combination statistic #' \deqn{TFisher = \sum_{i=1}^n -2\log(p_i/\tau_2)I(p_i\leq\tau_2)} #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' pval <- runif(100) #' stat.tfisher(p=pval, tau1=0.05, tau2=0.25) #' @export stat.tfisher <- function(p,tau1,tau2){ return(sum(-2*log(p[p<=tau1]/tau2))) } TFisher/R/power.tpm.R0000644000177700017770000000234513254343143015435 0ustar herbrandtherbrandt#' Statistical power of truncated product method test under Gaussian mixture model. #' @param alpha - type-I error rate. #' @param n - dimension parameter, i.e. the number of input p-values. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. tau1 > 0. #' @param eps - mixing parameter of the Gaussian mixture. #' @param mu - mean of non standard Gaussian model. #' @return Power of the truncated product method test. #' @details We consider the following hypothesis test, #' \deqn{H_0: X_i\sim F_0, H_a: X_i\sim (1-\epsilon)F_0+\epsilon F_1} #' , where \eqn{\epsilon} is the mixing parameter, #' \eqn{F_0} is the standard normal CDF and \eqn{F = F_1} is the CDF of normal distribution with \eqn{\mu} defined by mu and \eqn{\sigma = 1}. #' #' @seealso \code{\link{stat.soft}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' alpha = 0.05 #' #If the alternative hypothesis Gaussian mixture with eps = 0.1 and mu = 1.2:# #' power.tpm(alpha, 100, 0.05, eps = 0.1, mu = 1.2) #' @export #' @importFrom sn psn power.tpm <- function(alpha,n,tau1,eps=0,mu=0){ power.tfisher(alpha,n,tau1,1,eps,mu) } TFisher/R/power.tfisher.R0000644000177700017770000000412113254343141016271 0ustar herbrandtherbrandt#' Statistical power of thresholding Fisher's p-value combination test under Gaussian mixture model. #' @param alpha - type-I error rate. #' @param n - dimension parameter, i.e. the number of input p-values. #' @param tau1 - truncation parameter. 0 < tau1 <= 1. #' @param tau2 - normalization parameter. tau2 >= tau1. #' @param eps - mixing parameter of the Gaussian mixture. #' @param mu - mean of non standard Gaussian model. #' @return Power of the thresholding Fisher's p-value combination test. #' @details We consider the following hypothesis test, #' \deqn{H_0: X_i\sim F_0, H_a: X_i\sim (1-\epsilon)F_0+\epsilon F_1} #' , where \eqn{\epsilon} is the mixing parameter, #' \eqn{F_0} is the standard normal CDF and \eqn{F = F_1} is the CDF of normal distribution with \eqn{\mu} defined by mu and \eqn{\sigma = 1}. #' #' @seealso \code{\link{stat.tfisher}} for the definition of the statistic. #' @references 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. #' @examples #' alpha = 0.05 #' #If the alternative hypothesis Gaussian mixture with eps = 0.1 and mu = 1.2:# #' power.tfisher(alpha, 100, 0.05, 0.25, eps = 0.1, mu = 1.2) #' @export #' @importFrom sn psn #' @importFrom stats pchisq integrate dbinom #' power.tfisher <- function(alpha,n,tau1,tau2,eps=0,mu=0){ q = q.tfisher(p=1-alpha, n, tau1, tau2) if(eps==0|mu==0){ return(1-(sum(pchisq(q+2*(1:n)*log(tau1/tau2),2*(1:n))*dbinom(1:n, n, tau1)) + (0 Description: We provide the cumulative distribution function (CDF), quantile, and statistical power calculator for a collection of thresholding Fisher's p-value combination methods, including Fisher's p-value combination method, truncated product method and, in particular, soft-thresholding Fisher's p-value combination method which is proven to be optimal in some context of signal detection. The p-value calculator for the omnibus version of these tests are also included. For reference, please see Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. License: GPL-2 Imports: stats, sn, mvtnorm, Matrix Encoding: UTF-8 LazyData: true RoxygenNote: 6.0.1 NeedsCompilation: no Packaged: 2018-03-21 02:51:25 UTC; Hong Repository: CRAN Date/Publication: 2018-03-21 12:05:33 UTC TFisher/man/0000755000177700017770000000000013200004157013713 5ustar herbrandtherbrandtTFisher/man/stat.tfisher.Rd0000644000177700017770000000171013254343270016632 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stat.tfisher.R \name{stat.tfisher} \alias{stat.tfisher} \title{Construct thresholding Fisher's p-value combination statistic.} \usage{ stat.tfisher(p, tau1, tau2) } \arguments{ \item{p}{- input p-values.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} \item{tau2}{- normalization parameter. tau2 >= tau1.} } \value{ Thresholding Fisher's p-value combination statistic. } \description{ Construct thresholding Fisher's p-value combination statistic. } \details{ Let \eqn{p_{i}}, \eqn{i = 1,...,n} be a sequence of p-values, the thresholding Fisher's p-value combination statistic \deqn{TFisher = \sum_{i=1}^n -2\log(p_i/\tau_2)I(p_i\leq\tau_2)} } \examples{ pval <- runif(100) stat.tfisher(p=pval, tau1=0.05, tau2=0.25) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } TFisher/man/p.tpm.Rd0000644000177700017770000000245513254343270015261 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/p.tpm.R \name{p.tpm} \alias{p.tpm} \title{CDF of truncated product method statistic under the null hypothesis.} \usage{ p.tpm(q, n, tau1, M = NULL) } \arguments{ \item{q}{- quantile, could be a vector.} \item{n}{- dimension parameter, i.e. the number of p-values to be combined.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ The left-tail probability of the null distribution of truncated product method statistic at the given quantile. } \description{ CDF of truncated product method statistic under the null hypothesis. } \examples{ pval <- runif(100) tpmstat <- stat.tpm(p=pval, tau1=0.05) p.tpm(q=tpmstat, n=100, tau1=0.05) M = matrix(0.3,100,100) + diag(1-0.3,100) p.tpm(q=tpmstat, n=100, tau1=0.05, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. 2. Zaykin, D.V., Zhivotovsky, L. A., Westfall, P.H. and Weir, B.S. (2002), Truncated product method for combining P-values. Genet. Epidemiol., 22: 170–185. doi:10.1002/gepi.0042 } \seealso{ \code{\link{stat.tpm}} for the definition of the statistic. } TFisher/man/power.soft.Rd0000644000177700017770000000273013254343270016325 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/power.soft.R \name{power.soft} \alias{power.soft} \title{Statistical power of soft-thresholding Fisher's p-value combination test under Gaussian mixture model.} \usage{ power.soft(alpha, n, tau1, eps = 0, mu = 0) } \arguments{ \item{alpha}{- type-I error rate.} \item{n}{- dimension parameter, i.e. the number of input p-values.} \item{tau1}{- truncation parameter=normalization parameter. tau1 > 0.} \item{eps}{- mixing parameter of the Gaussian mixture.} \item{mu}{- mean of non standard Gaussian model.} } \value{ Power of the soft-thresholding Fisher's p-value combination test. } \description{ Statistical power of soft-thresholding Fisher's p-value combination test under Gaussian mixture model. } \details{ We consider the following hypothesis test, \deqn{H_0: X_i\sim F_0, H_a: X_i\sim (1-\epsilon)F_0+\epsilon F_1} , where \eqn{\epsilon} is the mixing parameter, \eqn{F_0} is the standard normal CDF and \eqn{F = F_1} is the CDF of normal distribution with \eqn{\mu} defined by mu and \eqn{\sigma = 1}. } \examples{ alpha = 0.05 #If the alternative hypothesis Gaussian mixture with eps = 0.1 and mu = 1.2:# power.soft(alpha, 100, 0.05, eps = 0.1, mu = 1.2) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.soft}} for the definition of the statistic. } TFisher/man/p.tpm.omni.Rd0000644000177700017770000000217113254343270016215 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/p.tpm.omni.R \name{p.tpm.omni} \alias{p.tpm.omni} \title{CDF of omnibus truncated product method statistic under the null hypothesis.} \usage{ p.tpm.omni(q, n, TAU1, M = NULL) } \arguments{ \item{q}{- quantile, could be a vector.} \item{n}{- dimension parameter, i.e. the number of p-values to be combined.} \item{TAU1}{- a vector of truncation parameters. Must be in non-descending order.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence} } \value{ The left-tail probability of the null distribution of omnibus truncated product method statistic. } \description{ CDF of omnibus truncated product method statistic under the null hypothesis. } \examples{ q = 0.05 n = 20 TAU1 = c(0.01, 0.05, 0.5, 1) M = matrix(0.3,20,20) + diag(1-0.3,20) p.tpm.omni(q=q, n=n, TAU1=TAU1, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.tpm.omni}} for the definition of the statistic. } TFisher/man/stat.soft.Rd0000644000177700017770000000167013254343270016146 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stat.soft.R \name{stat.soft} \alias{stat.soft} \title{Construct soft-thresholding Fisher's p-value combination statistic.} \usage{ stat.soft(p, tau1) } \arguments{ \item{p}{- input p-values.} \item{tau1}{- truncation parameter=normalization parameter. tau1 > 0.} } \value{ Soft-thresholding Fisher's p-value combination statistic. } \description{ Construct soft-thresholding Fisher's p-value combination statistic. } \details{ Let \eqn{p_{i}}, \eqn{i = 1,...,n} be a sequence of p-values, the soft-thresholding statistic \deqn{Soft = \sum_{i=1}^n -2\log(p_i/\tau_1)I(p_i\leq\tau_1)}. Soft-thresholding is the special case of TFisher when tau1=tau2. } \examples{ pval <- runif(100) stat.soft(p=pval, tau1=0.05) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } TFisher/man/p.soft.Rd0000644000177700017770000000232613254343270015431 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/p.soft.R \name{p.soft} \alias{p.soft} \title{CDF of soft-thresholding Fisher's p-value combination statistic under the null hypothesis.} \usage{ p.soft(q, n, tau1, M = NULL) } \arguments{ \item{q}{- quantile, could be a vector.} \item{n}{- dimension parameter, i.e. the number of p-values to be combined.} \item{tau1}{- truncation parameter=normalization parameter. tau1 > 0.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ The left-tail probability of the null distribution of soft-thresholding Fisher's p-value combination statistic at the given quantile. } \description{ CDF of soft-thresholding Fisher's p-value combination statistic under the null hypothesis. } \examples{ pval <- runif(100) softstat <- stat.soft(p=pval, tau1=0.05) p.soft(q=softstat, n=100, tau1=0.05) M = matrix(0.3,100,100) + diag(1-0.3,100) p.soft(q=softstat, n=100, tau1=0.05, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.soft}} for the definition of the statistic. } TFisher/man/stat.soft.omni.Rd0000644000177700017770000000276213254343270017112 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stat.soft.omni.R \name{stat.soft.omni} \alias{stat.soft.omni} \title{Construct omnibus soft-thresholding Fisher's p-value combination statistic.} \usage{ stat.soft.omni(p, TAU1, M = NULL) } \arguments{ \item{p}{- input p-values.} \item{TAU1}{- a vector of truncation parameters (=normalization parameters). Must be in non-descending order.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ omni - omnibus soft-thresholding statistic. pval - p-values of each soft-thresholding tests. } \description{ Construct omnibus soft-thresholding Fisher's p-value combination statistic. } \details{ Let \eqn{x_{i}}, \eqn{i = 1,...,n} be a sequence of individual statistics with correlation matrix M, \eqn{p_{i}} be the corresponding two-sided p-values, then the soft-thresholding statistics \deqn{Soft_j = \sum_{i=1}^n -2\log(p_i/\tau_{1j})I(p_i\leq\tau_{1j})}, \eqn{j = 1,...,d}. The omnibus test statistic is the minimum p-value of these soft-thresholding tests, \deqn{W_o = min_j G_j(Soft_j)}, where \eqn{G_j} is the survival function of \eqn{Soft_j}. } \examples{ pval = runif(20) TAU1 = c(0.01, 0.05, 0.5, 1) stat.soft.omni(p=pval, TAU1=TAU1) M = matrix(0.3,20,20) + diag(1-0.3,20) stat.soft.omni(p=pval, TAU1=TAU1, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } TFisher/man/q.tpm.Rd0000644000177700017770000000237413254343270015262 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/q.tpm.R \name{q.tpm} \alias{q.tpm} \title{Quantile of truncated product method statistic under the null hypothesis.} \usage{ q.tpm(p, n, tau1, M = NULL) } \arguments{ \item{p}{- a scalar left probability that defines the quantile.} \item{n}{- dimension parameter, i.e. the number of input p-values.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ Quantile of truncated product method statistic. } \description{ Quantile of truncated product method statistic under the null hypothesis. } \examples{ ## The 0.05 critical value of TPM statistic when n = 10: q.tpm(p=.95, n=20, tau1 = 0.05) M = matrix(0.3,20,20) + diag(1-0.3,20) q.tpm(p=.95, n=20, tau1 = 0.05, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. 2. Zaykin, D.V., Zhivotovsky, L. A., Westfall, P.H. and Weir, B.S. (2002), Truncated product method for combining P-values. Genet. Epidemiol., 22: 170–185. doi:10.1002/gepi.0042 } \seealso{ \code{\link{stat.tpm}} for the definition of the statistic. } TFisher/man/power.tpm.Rd0000644000177700017770000000261013254343270016147 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/power.tpm.R \name{power.tpm} \alias{power.tpm} \title{Statistical power of truncated product method test under Gaussian mixture model.} \usage{ power.tpm(alpha, n, tau1, eps = 0, mu = 0) } \arguments{ \item{alpha}{- type-I error rate.} \item{n}{- dimension parameter, i.e. the number of input p-values.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1. tau1 > 0.} \item{eps}{- mixing parameter of the Gaussian mixture.} \item{mu}{- mean of non standard Gaussian model.} } \value{ Power of the truncated product method test. } \description{ Statistical power of truncated product method test under Gaussian mixture model. } \details{ We consider the following hypothesis test, \deqn{H_0: X_i\sim F_0, H_a: X_i\sim (1-\epsilon)F_0+\epsilon F_1} , where \eqn{\epsilon} is the mixing parameter, \eqn{F_0} is the standard normal CDF and \eqn{F = F_1} is the CDF of normal distribution with \eqn{\mu} defined by mu and \eqn{\sigma = 1}. } \examples{ alpha = 0.05 #If the alternative hypothesis Gaussian mixture with eps = 0.1 and mu = 1.2:# power.tpm(alpha, 100, 0.05, eps = 0.1, mu = 1.2) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.soft}} for the definition of the statistic. } TFisher/man/q.tfisher.Rd0000644000177700017770000000237613254343270016130 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/q.tfisher.R \name{q.tfisher} \alias{q.tfisher} \title{Quantile of thresholding Fisher's p-value combination statistic under the null hypothesis.} \usage{ q.tfisher(p, n, tau1, tau2, M = NULL) } \arguments{ \item{p}{- a scalar left probability that defines the quantile.} \item{n}{- dimension parameter, i.e. the number of input p-values.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} \item{tau2}{- normalization parameter. tau2 >= tau1.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ Quantile of thresholding Fisher's p-value combination statistic. } \description{ Quantile of thresholding Fisher's p-value combination statistic under the null hypothesis. } \examples{ ## The 0.05 critical value of TFisher statistic when n = 10: q.tfisher(p=.95, n=20, tau1=0.05, tau2=0.25) ## when corrrelated M = matrix(0.3,20,20) + diag(1-0.3,20) q.tfisher(p=.95, n=20, tau1=0.05, tau2=0.25, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.tfisher}} for the definition of the statistic. } TFisher/man/stat.tpm.Rd0000644000177700017770000000175613254343270016000 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stat.tpm.R \name{stat.tpm} \alias{stat.tpm} \title{Construct truncated product method statistic.} \usage{ stat.tpm(p, tau1) } \arguments{ \item{p}{- input p-values.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} } \value{ Truncated product method statistic. } \description{ Construct truncated product method statistic. } \details{ Let \eqn{p_{i}}, \eqn{i = 1,...,n} be a sequence of p-values, the TPM statistic \deqn{TPM = \sum_{i=1}^n -2\log(p_i)I(p_i\leq\tau_2)}. TPM is the special case of TFisher when tau2=1. } \examples{ pval <- runif(100) stat.tpm(p=pval, tau1=0.05) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. 2. Zaykin, D.V., Zhivotovsky, L. A., Westfall, P.H. and Weir, B.S. (2002), Truncated product method for combining P-values. Genet. Epidemiol., 22: 170–185. doi:10.1002/gepi.0042 } TFisher/man/p.tfisher.omni.Rd0000644000177700017770000000264613254343270017070 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/p.tfisher.omni.R \name{p.tfisher.omni} \alias{p.tfisher.omni} \title{CDF of omnibus thresholding Fisher's p-value combination statistic under the null hypothesis.} \usage{ p.tfisher.omni(q, n, TAU1, TAU2, M = NULL, P0 = NULL) } \arguments{ \item{q}{- quantile, could be a vector.} \item{n}{- dimension parameter, i.e. the number of p-values to be combined.} \item{TAU1}{- a vector of truncation parameters. Must be in non-descending order.} \item{TAU2}{- a vector of normalization parameters. Must be in non-descending order.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} \item{P0}{- a vector of point masses of TFisher statistics. Default = NULL.} } \value{ The left-tail probability of the null distribution of omnibus thresholding Fisher's p-value combination statistic. } \description{ CDF of omnibus thresholding Fisher's p-value combination statistic under the null hypothesis. } \examples{ q = 0.05 n = 20 TAU1 = c(0.01, 0.05, 0.5, 1) TAU2 = c(0.1, 0.2, 0.5, 1) M = matrix(0.3,20,20) + diag(1-0.3,20) p.tfisher.omni(q=q, n=n, TAU1=TAU1, TAU2=TAU2, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.tfisher.omni}} for the definition of the statistic. } TFisher/man/p.tfisher.Rd0000644000177700017770000000302713254343270016121 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/p.tfisher.R \name{p.tfisher} \alias{p.tfisher} \title{CDF of thresholding Fisher's p-value combination statistic under the null hypothesis.} \usage{ p.tfisher(q, n, tau1, tau2, M = NULL, mu = NULL, sigma2 = NULL, p0 = NULL) } \arguments{ \item{q}{- quantile, could be a vector.} \item{n}{- dimension parameter, i.e. the number of p-values to be combined.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} \item{tau2}{- normalization parameter. tau2 >= tau1.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} \item{mu}{- the mean of TFisher statistics. Default = NULL.} \item{sigma2}{- the variance of TFisher statistics. Default = NULL.} \item{p0}{- the point masse of TFisher statistics. Default = NULL.} } \value{ The left-tail probability of the null distribution of thresholding Fisher's p-value combination statistic at the given quantile. } \description{ CDF of thresholding Fisher's p-value combination statistic under the null hypothesis. } \examples{ pval <- runif(20) tfstat <- stat.tfisher(p=pval, tau1=0.25, tau2=0.75) p.tfisher(q=tfstat, n=20, tau1=0.25, tau2=0.75) M = matrix(0.3,20,20) + diag(1-0.3,20) p.tfisher(q=tfstat, n=20, tau1=0.25, tau2=0.75, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.tfisher}} for the definition of the statistic. } TFisher/man/stat.tpm.omni.Rd0000644000177700017770000000266313254343270016737 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stat.tpm.omni.R \name{stat.tpm.omni} \alias{stat.tpm.omni} \title{Construct omnibus truncated product method statistic.} \usage{ stat.tpm.omni(p, TAU1, M = NULL) } \arguments{ \item{p}{- input p-values.} \item{TAU1}{- a vector of truncation parameters. Must be in non-descending order.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ omni - omnibus truncated product method statistic. pval - p-values of each truncated product method tests. } \description{ Construct omnibus truncated product method statistic. } \details{ Let \eqn{x_{i}}, \eqn{i = 1,...,n} be a sequence of individual statistics with correlation matrix M, \eqn{p_{i}} be the corresponding two-sided p-values, then the truncated product method statistics \deqn{TPM_j = \sum_{i=1}^n -2\log(p_i)I(p_i\leq\tau_{1j})}, \eqn{j = 1,...,d}. The omnibus test statistic is the minimum p-value of these truncated product method tests, \deqn{W_o = min_j G_j(TPM_j)}, where \eqn{G_j} is the survival function of \eqn{TPM_j}. } \examples{ pval = runif(20) TAU1 = c(0.01, 0.05, 0.5, 1) stat.tpm.omni(p=pval, TAU1=TAU1) M = matrix(0.3,20,20) + diag(1-0.3,20) stat.tpm.omni(p=pval, TAU1=TAU1, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } TFisher/man/q.soft.Rd0000644000177700017770000000225713254343270015435 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/q.soft.R \name{q.soft} \alias{q.soft} \title{Quantile of soft-thresholding Fisher's p-value combination statistic under the null hypothesis.} \usage{ q.soft(p, n, tau1, M = NULL) } \arguments{ \item{p}{- a scalar left probability that defines the quantile.} \item{n}{- dimension parameter, i.e. the number of input p-values.} \item{tau1}{- truncation parameter=normalization parameter. tau1 > 0.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ Quantile of soft-thresholding Fisher's p-value combination statistic. } \description{ Quantile of soft-thresholding Fisher's p-value combination statistic under the null hypothesis. } \examples{ ## The 0.05 critical value of soft-thresholding statistic when n = 10: q.soft(p=.99, n=20, tau1 = 0.05) M = matrix(0.9,20,20) + diag(1-0.9,20) q.soft(p=.99, n=20, tau1 = 0.05, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.soft}} for the definition of the statistic. } TFisher/man/stat.tfisher.omni.Rd0000644000177700017770000000364213254343270017601 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/stat.tfisher.omni.R \name{stat.tfisher.omni} \alias{stat.tfisher.omni} \title{Construct omnibus thresholding Fisher's (TFisher) p-value combination statistic.} \usage{ stat.tfisher.omni(p, TAU1, TAU2, M = NULL, MU = NULL, SIGMA2 = NULL, P0 = NULL) } \arguments{ \item{p}{- input p-values from potentially correlated input sstatistics.} \item{TAU1}{- a vector of truncation parameters. Must be in non-descending order.} \item{TAU2}{- a vector of normalization parameters. Must be in non-descending order.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence} \item{MU}{- a vector of means of TFisher statistics. Default = NULL.} \item{SIGMA2}{- a vector of variances of TFisher statistics. Default = NULL.} \item{P0}{- a vector of point masses of TFisher statistics. Default = NULL.} } \value{ omni - omnibus TFisher statistic. pval - p-values of each TFisher tests. } \description{ Construct omnibus thresholding Fisher's (TFisher) p-value combination statistic. } \details{ Let \eqn{x_{i}}, \eqn{i = 1,...,n} be a sequence of individual statistics with correlation matrix M, \eqn{p_{i}} be the corresponding two-sided p-values, then the TFisher statistics \deqn{TFisher_j = \sum_{i=1}^n -2\log(p_i/\tau_{2j})I(p_i\leq\tau_{1j})}, \eqn{j = 1,...,d}. The omnibus test statistic is the minimum p-value of these thresholding tests, \deqn{W_o = min_j G_j(Soft_j)}, where \eqn{G_j} is the survival function of \eqn{Soft_j}. } \examples{ pval = runif(20) TAU1 = c(0.01, 0.05, 0.5, 1) TAU2 = c(0.1, 0.2, 0.5, 1) stat.tfisher.omni(p=pval, TAU1=TAU1, TAU2=TAU2) M = matrix(0.3,20,20) + diag(1-0.3,20) stat.tfisher.omni(p=pval, TAU1=TAU1, TAU2=TAU2, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } TFisher/man/p.soft.omni.Rd0000644000177700017770000000233613254343270016373 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/p.soft.omni.R \name{p.soft.omni} \alias{p.soft.omni} \title{CDF of omnibus soft-thresholding Fisher's p-value combination statistic under the null hypothesis.} \usage{ p.soft.omni(q, n, TAU1, M = NULL) } \arguments{ \item{q}{- quantile, could be a vector.} \item{n}{- dimension parameter, i.e. the number of p-values to be combined.} \item{TAU1}{- a vector of truncation parameters (=normalization parameters). Must be in non-descending order.} \item{M}{- correlation matrix of the input statistics. Default = NULL assumes independence.} } \value{ The left-tail probability of the null distribution of omnibus soft-thresholding Fisher's p-value combination statistic. } \description{ CDF of omnibus soft-thresholding Fisher's p-value combination statistic under the null hypothesis. } \examples{ q = 0.01 n = 20 TAU1 = c(0.01, 0.05, 0.5, 1) M = matrix(0.3,20,20) + diag(1-0.3,20) p.soft.omni(q=q, n=n, TAU1=TAU1, M=M) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.soft.omni}} for the definition of the statistic. } TFisher/man/power.tfisher.Rd0000644000177700017770000000301513254343270017013 0ustar herbrandtherbrandt% Generated by roxygen2: do not edit by hand % Please edit documentation in R/power.tfisher.R \name{power.tfisher} \alias{power.tfisher} \title{Statistical power of thresholding Fisher's p-value combination test under Gaussian mixture model.} \usage{ power.tfisher(alpha, n, tau1, tau2, eps = 0, mu = 0) } \arguments{ \item{alpha}{- type-I error rate.} \item{n}{- dimension parameter, i.e. the number of input p-values.} \item{tau1}{- truncation parameter. 0 < tau1 <= 1.} \item{tau2}{- normalization parameter. tau2 >= tau1.} \item{eps}{- mixing parameter of the Gaussian mixture.} \item{mu}{- mean of non standard Gaussian model.} } \value{ Power of the thresholding Fisher's p-value combination test. } \description{ Statistical power of thresholding Fisher's p-value combination test under Gaussian mixture model. } \details{ We consider the following hypothesis test, \deqn{H_0: X_i\sim F_0, H_a: X_i\sim (1-\epsilon)F_0+\epsilon F_1} , where \eqn{\epsilon} is the mixing parameter, \eqn{F_0} is the standard normal CDF and \eqn{F = F_1} is the CDF of normal distribution with \eqn{\mu} defined by mu and \eqn{\sigma = 1}. } \examples{ alpha = 0.05 #If the alternative hypothesis Gaussian mixture with eps = 0.1 and mu = 1.2:# power.tfisher(alpha, 100, 0.05, 0.25, eps = 0.1, mu = 1.2) } \references{ 1. Hong Zhang and Zheyang Wu. "TFisher Tests: Optimal and Adaptive Thresholding for Combining p-Values", submitted. } \seealso{ \code{\link{stat.tfisher}} for the definition of the statistic. }