opw: Perform Optimal Pvalue Weighting

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/opw.R

Description

A function to perform weighted pvalue multiple hypothesis test. This function compute the probabilities of the ranks of the filter statistics given the effect sizes, and consequently the weights if neighter the weights nor the probabilities are given. Then provides the number of rejected null hypothesis and the list of the rejected pvalues as well as the corresponing filter statistics.

Usage

1
2
3
4
opw(pvalue, filter, weight = NULL, ranksProb = NULL,
  mean_filterEffect = NULL, mean_testEffect = NULL,
  effectType = c("continuous", "binary"), alpha = 0.05, nrep = 10000,
  tail = 1L, delInterval = 0.001, method = c("BH", "BON"), ...)

Arguments

pvalue

Numeric vector of pvalues of the test statistics

filter

Numeric vector of filter statistics

weight

An optional numeric weight vector not required

ranksProb

An optional numeric vector of the ranks probability of the filters given the mean effect

mean_filterEffect

Numeric, value of the mean filter effect of the true alternatives

mean_testEffect

Numeric, value of the mean test effect of the true alterantives

effectType

Character ("continuous" or "binary"), type of effect sizes

alpha

Numeric, significance level of the hypothesis test

nrep

Integer, number of replications for importance sampling, default value is 10,000, can be increased to obtain smoother probability curves

tail

Integer (1 or 2), right-tailed or two-tailed hypothesis test. default is right-tailed test.

delInterval

Numeric, interval between the delta values of a sequence. Note that, delta is a LaGrange multiplier, necessary to normalize the weight

method

Character ("BH" or "BON"), type of methods is used to obtain the results; Benjemini-Hochberg or Bonferroni

...

Arguments passed to internal functions

Details

If one wants to test

H_0: epsilon_i = 0 vs. H_a: epsilon_i > 0,

then the mean_testEffect and mean_filterEffect should be mean of the test and filter effect sizes, respectively. This is called hypothesis testing for the continuous effect sizes.

If one wants to test

H_0: epsilon_i = 0 vs. H_a: epsilon_i = epsilon,

then mean_testEffect and mean_filterEffect should be median or any discrete value of the test and filter effect sizes. This is called hypothesis testing for the Binary effect sizes, where epsilon refers to a fixed value.

The main goal of the function is to compute the probabilities of the ranks from the pvalues and the filter statistics, consequently the weights. Although weights ranksProb are optional, opw has the options so that one can compute the probabilities and the weights externally if necessary (see examples).

Internally, opw function compute the ranksProb and consequently the weights, then uses the pvalues to make conclusions about hypotheses. Therefore, if ranksProb is given then mean_filterEffect and are redundant, and should not be provided to the funciton. Although ranksProb is not required to the function, One can compute ranksProb by using the function prob_rank_givenEffect.

The function internally compute mean_filterEffect and mean_testEffect from a simple linear regression with box-cox transformation between the test and filter statistics, where the filters are regressed on the test statistics. Thus, filters need to be positive to apply boxcox from the R library MASS. Then the estimated mean_filterEffect and mean_testEffect are used to obtian the ranksProb and the weights. Thus, in order to apply the function properly, it is crucial to understand the uses mean_filterEffect and mean_testEffect. If mean_filterEffect and mean_testEffect are not provided then the test statistics computed from the pvalues will be used to compute the relationship between the filter statistics and the test statistics.

If one of the mean effects mean_filterEffect and mean_testEffect are not provided then the missing mean effect will be computed internally.

Value

totalTests Integer, total number of hypothesis tests evaluated

nullProp Numeric, estimated propotion of the true null hypothesis

ranksProb Numeric vector of ranks probability given the mean filter effect, p(rank | ey = mean_filterEffect)

weight Numeric vector of normalized weight

rejections Integer, total number of rejections

rejections_list data frame, list of rejected p-values and the corresponding filter statistics and the adjusted p-values if method = "BH" used.

Author(s)

Mohamad S. Hasan, shakilmohamad7@gmail.com

See Also

prob_rank_givenEffect weight_binary weight_continuous qvalue dnorm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# generate pvalues and filter statistics
m = 1000
set.seed(3)
filters = runif(m, min = 0, max = 2.5)          # filter statistics
H = rbinom(m, size = 1, prob = 0.1)             # hypothesis true or false
tests = rnorm(m, mean = H * filters)            # Z-score
pvals = 1 - pnorm(tests)                        # pvalue

# general use
results <- opw(pvalue = pvals, filter = filters, effectType = "continuous",
                                              method = "BH")

# supply the mean effects for both the filters and the tests externally
mod <- lm(log(filters) ~ tests)
et = mean(tests)
ey = mod$coef[[1]] + mod$coef[[2]]*et
results2 <- opw(pvalue = pvals, filter = filters,
               mean_filterEffect = ey, mean_testEffect = et, tail = 2,
               effectType = "continuous", method = "BH")

# supply the rank probabilities externally
library(qvalue)
ranks <- 1:m
nullProp = qvalue(p = pvals, pi0.method = "bootstrap")$pi0
m0 = ceiling(nullProp*m)
m1 = m - m0
probs <- sapply(ranks, prob_rank_givenEffect, et = ey, ey = ey,
                                        nrep = 10000, m0 = m0, m1 = m1)
results3 <- opw(pvalue = pvals, filter = filters, ranksProb = probs,
                 effectType = "continuous", tail = 2, method = "BH")

# supply weight externally
wgt <- weight_continuous(alpha = .05, et = et, m = m, ranksProb = probs)
results4 <- opw(pvalue = pvals, filter = filters, weight = wgt,
                        effectType = "continuous", alpha = .05, method = "BH")

OPWeight documentation built on Nov. 8, 2020, 11:06 p.m.