Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/roeder_wasserman_weight.R
Compute weights by splitting the test statistics raked by the covariate. This method is taken from Roeder and Waserman (2009).
1 2 | roeder_wasserman_weight(pvalue, gamma = 0.05, alpha = 0.05, group = 5L,
tail = 1L, c_interval = 0.01)
|
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
|
None
weight
A numeric vector of the normalized weights
Mohamad S. Hasan, shakilmohamad7@gmail.com
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
weight_binary
weight_continuous
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.