sample_FP_Power {sim2Dpredictr} | R Documentation |
Obtain Sample False Positive Rates and Power
Description
This function calculates sample FDR, FWER, and Power for large numbers of predictors, given a vector of "true" parameter values and a vector of associated rejections. In the case that more than 1 predictor has a "true" non-zero parameter, then Power is defined as the proportion/percentage of those "true" parameters identified.
Usage
sample_FP_Power(
rejections = NULL,
FP = NULL,
TP = NULL,
test.statistic = NULL,
reject.threshold = NULL,
B = NULL,
B.incl.B0 = TRUE,
full.summary = FALSE
)
Arguments
rejections |
A binary vector; |
FP , TP |
Binary vectors of false positive and true positive indicators,
respectively. |
test.statistic |
A vector of test statistics; e.g., t-statistics or p-values that are used to determine whether or not to reject the null hypothesis. |
reject.threshold |
A list whose first element is the rejection
criteria, e.g., the minimum t-statistic or maximum p-value for which to
reject the null hypothesis. The second element is one of
|
B |
A vector of "true" parameter values. For inference purposes, this can be a vector of actual parameter values, or a binary vector indicating non-zero status. |
B.incl.B0 |
If |
full.summary |
If |
Value
A data frame with columns for sample FDR, FWER, and Power.
Note
The default operating approach is that the null hypothesis is
B[i] = 0
for each parameter. If other hypotheses are being tested
then B
should be converted to a binary vector indicating whether
the null hypothesis should have been rejected.
Examples
## example 1
## rejection vector
rej.ex <- c(0, 1, 1, 0, 0, 1, 0)
## false positive vector
fp.ex <- c(0, 0, 1, 0, 0, 0, 0)
## true positive vector
tp.ex <- c(0, 1, 0, 0, 0, 1, 0)
## parameter vector
par.ex <- c(0, 4, 0, 0, 3, 9, 0)
sample_FP_Power(rej.ex, fp.ex, tp.ex, par.ex, B.incl.B0 = FALSE)
## Function can calculate TP and FP vectors
sample_FP_Power(rejections = rej.ex,
FP = NULL, TP = NULL,
B = par.ex, B.incl.B0 = FALSE)
## example 2: sum(FP, TP) must equal sum(rejections) or
## function stops execution
rej.ex2 <- c(0, 1, 0, 0, 0, 1, 0)
fp.ex2 <- c(0, 0, 1, 0, 0, 0, 0)
tp.ex2 <- c(0, 1, 0, 0, 0, 1, 0)
par.ex2 <- c(0, 4, 0, 0, 3, 9, 0)
## Not run: sample_FP_Power(rej.ex2,
fp.ex2, tp.ex2, par.ex2,
B.incl.B0 = FALSE)
## End(Not run)
## example 3: calculate rejections from vector of test statistics
zstat <- c(-0.5, 1.98, 2.01, 1.45, -1.99)
# 2-tailed
sample_FP_Power(test.statistic = zstat,
reject.threshold = list(1.96, "2-tailed"),
B = c(0, 0, 4, 1, -2), B.incl.B0 = FALSE)
# 1-tailed (upper)
sample_FP_Power(test.statistic = zstat,
reject.threshold = list(1.96, "greater"),
B = c(0, 0, 4, 1, -2), B.incl.B0 = FALSE)
## p-value
sample_FP_Power(test.statistic = c(0.44, 0.04, 0.01, 0.06, 0.02 ),
reject.threshold = list(0.05, "less"),
B = c(0, 0, 4, 1, -2), B.incl.B0 = FALSE)