## 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)
if (FALSE) sample_FP_Power(rej.ex2,
fp.ex2, tp.ex2, par.ex2,
B.incl.B0 = FALSE)
## 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)
Run the code above in your browser using DataLab