roeder_wasserman_weight: Weight from the Roeder and Wasserman (2009) paper

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

View source: R/roeder_wasserman_weight.R

Description

Compute weights by splitting the test statistics raked by the covariate. This method is taken from Roeder and Waserman (2009).

Usage

1
2
roeder_wasserman_weight(pvalue, gamma = 0.05, alpha = 0.05, group = 5L,
  tail = 1L, c_interval = 0.01)

Arguments

pvalue

A numeric vector of ordered p-values sorted by the covariate

gamma

Numeric value of the smoothing parameter

alpha

Numeric value of the Significance level

group

Integer, number of groups

tail

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

c_interval

A nuumeric vector of a sequence of intervals between the c. Note that, c is a function of Langrangian multiplier, necessary to normalize the weight

Details

None

Value

weight A numeric vector of the normalized weights

Author(s)

Mohamad S. Hasan, shakilmohamad7@gmail.com

References

Roeder, Kathryn, and Larry Wasserman. "Genome-wide significance levels and weighted hypothesis testing." Statistical science: a review journal of the Institute of Mathematical Statistics 24.4 (2009): 398. www.stat.cmu.edu/~roeder/publications/statsci.pdf

See Also

weight_binary weight_continuous

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#generate pvalues and covariate
m = 10000
set.seed(123)
covariates = runif(m, min = 0, max = 2.5)       # covariate
H = rbinom(m, size = 1, prob = 0.1)             # hypothesis true or false
tests = rnorm(m, mean = H * covariates)         # Z-score
pvals = 1 - pnorm(tests)                        # pvalue

# Compute wiehgt
library(tibble)
Data <- tibble(tests, pvals, covariates)
OD <- Data[order(Data$covariates, decreasing = TRUE), ]

weight = roeder_wasserman_weight(pvalue = OD$pvals)

# plot the weight
plot(weight)

# compute number of rejections
alpha = .05
rwd <- sum(OD$pvals <= alpha*weight/m)
bon <- sum(pvals <= alpha/m)

mshasan/OPWpaper1 documentation built on Feb. 22, 2021, 10:22 a.m.