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; rejection[i] = 1 means the null hypothesis is rejected for parameter B[i], whereas rejection[i] = 0 means that the null hypothesis was not rejected for parameter B[i].

FP, TP

Binary vectors of false positive and true positive indicators, respectively. FP[i] = 1 means the null hypothesis was incorrectly rejected, and TP[i] = 1 means the null hypothesis was correctly rejected. If either argument is NULL, then these vectors are computed; this is the default setting.

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 c("greater", "less", "2-tailed"), which tell the function to reject when the values in test.statistic are greater than or less than the threshold, the test is a 2-tailed, respectively. In the latter case the function internally calculates the upper or lower threshold needed for the 2-tailed test.

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 B.incl.B0 = TRUE then the first entry should be the intercept, B0. B.incl.B0 = FALSE indicates that the first entry of B is not an intercept.

full.summary

If full.summary = TRUE then the total numbers of rejections, false positives, true positives, and non-zero parameters are output along with FDR, FWER, and Power; otherwise, only FDR, FWER, and Power are output.

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)

[Package sim2Dpredictr version 0.1.1 Index]