The CoRpower
package performs power calculations for correlates of risk, as described in [Gilbert, Janes, and Huang (2016). Power/Sample Size Calculations for Assessing Correlates of Risk in Clinical Efficacy Trials] The power calculations accomodate three types of biomarkers:
as well as two types of sampling design:
The vignette aims to illustrate distinct features of the functions in the package (with some mathematical background) by walking through a number of power calculation scenarios for different biomarker types, sampling designs, and input parameters.
The functions included in this package are:
computeN()
computePower()
plotPowerTri()
plotPowerCont()
plotRRgradVE()
plotVElatCont()
\(n^S_{cases}\) (\(n^S_{controls}\)) \(=\) number of observed cases (controls) between \(\tau\) and \(\tau_{\mathrm{max}}\) with measured \(S\) (or \(S^{\ast}\))
If calculations done at design stage, then \(N\), \(n_{cases}\), \(n_{controls}\), \(n^S_{cases}\), and \(n^S_{controls}\) projected numbers
Using \(\theta_0\) and \(\theta_2\) from Step i., define \[ \begin{align} Spec(\phi_0) &= P(S^{\ast} \leq \phi_0 \mid X^{\ast} \leq \theta_0)\\ FN^1(\phi_0) &= P(S^{\ast} \leq \phi_0 \mid X^{\ast} \in (\theta_0,\theta_2])\\ FN^2(\phi_0) &= P(S^{\ast} \leq \phi_0 \mid X^{\ast} > \theta_2)\\ Sens(\phi_2) &= P(S^{\ast} > \phi_2 \mid X^{\ast} > \theta_2)\\ FP^1(\phi_2) &= P(S^{\ast} > \phi_2 \mid X^{\ast} \in (\theta_0,\theta_2])\\ FP^0(\phi_2) &= P(S^{\ast} > \phi_2 \mid X^{\ast} \leq \theta_0) \end{align} \]
Estimate \(Spec(\phi_0)\) by \[\widehat{Spec}(\phi_0) = \frac{\#\{S^{\ast}_b \leq \phi_0, X^{\ast}_b \leq \theta_0\}}{\#\{X^{\ast}_b \leq \theta_0\}}\,\] etc.For \(\rho < 1\), \(RR_t\) closer to 1 than \(RR^{lat}_2\big/ RR^{lat}_0\)
tps
in R package osDesign
)
computeN()
\[ \begin{align} N &= N_{rand}\, P(T>\tau, C>\tau \mid Z=1)\\ &= N_{rand}\, P(T>\tau \mid Z=1)\, P(C>\tau \mid Z=1)\\ &= N_{rand}\, \{1 - RR_{0-\tau}\, P(T \leq \tau \mid Z=0)\}\, P(C>\tau \mid Z=1)\\ &\approx 4,023 \end{align} \]
\[ \begin{align} n_{cases} &= N\, P(T\leq \tau_{\mathrm{max}}, T\leq C \mid T>\tau, C>\tau, Z=1)\\ &= N\, P(T\leq \min(C,\tau_{\mathrm{max}}) \mid T>\tau, C>\tau, Z=1)\\ &= N\, \frac{\int_{\tau}^{\infty}P(\tau < T \leq \min(c,\tau_{\mathrm{max}})\mid Z=1)f_C(c)\mathop{\mathrm{d}}\!c}{P(T>\tau, C>\tau \mid Z=1)}\\ &= N\, \frac{\bigg\{\int_{\tau}^{\tau_{\mathrm{max}}}P(\tau < T \leq c\mid Z=1)f_C(c)\mathop{\mathrm{d}}\!c + P(\tau < T \leq \tau_{\mathrm{max}}\mid Z=1) P(C>\tau_{\mathrm{max}})\bigg\}}{P(T>\tau, C>\tau \mid Z=1)}\\ &\approx 32 \end{align} \]
\[ \begin{align} n_{controls} &= N \, P(T > \tau_{\mathrm{max}}, C > \tau_{\mathrm{max}} \mid T>\tau, C>\tau, Z=1)\\ &\approx 3,654 \end{align} \]
\[ \begin{align} n^S_{cases} &= n_{cases}\\ n^S_{controls} &= K n^S_{cases} \end{align} \]
computeN()
library(CoRpower)
computeN(Nrand = 4100, # participants randomized to vaccine arm
tau = 3.5, # biomarker sampling timepoint
taumax = 24, # end of follow-up
VEtauToTaumax = 0.75, # VE between 'tau' and 'taumax'
VE0toTau = 0.75/2, # VE between 0 and 'tau'
risk0 = 0.034, # placebo-group endpoint risk between 'tau' and 'taumax'
dropoutRisk = 0.1, # dropout risk between 0 and 'taumax'
propCasesWithS = 1) # proportion of observed cases with measured S
## $N
## [1] 4023
##
## $nCases
## [1] 32
##
## $nControls
## [1] 3654
##
## $nCasesWithS
## [1] 32
CoRpower
for trichotomous \(\, S\) | Without replacement samplingApproach 1 \((Sens, Spec, FP^0, FN^2\) specified\()\)
Approach 2 \((\sigma^2_{obs}\) and \(\rho\) specified\()\)
computePower()
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # scalar, i.e., separate calls for 5, 3, 1
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.2, # prevalence of lower protected
Plat2 = 0.6, # prevalence of higher protected
P0 = 0.2, # probability of low biomarker response
P2 = 0.6, # probability of high biomarker response
sens = 0.8, spec = 0.8, FP0 = 0, FN2 = 0,
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri()
Basic plotting functions are included in the package to aid with visualizing results. plotPowerTri
plots the power curve against the CoR relative risk, \(RR_t\), for trichotomous or binary biomarkers.
Output from computePower()
can be saved as an object and assigned to the outComputePower
input parameter. In this scenario, since computePower()
was run multiple times to vary the controls:cases ratio, these multiple output objects can be read into the function as a list.
plotPowerTri(outComputePower = list(pwr5to1, pwr3to1, pwr1to1), # 'computePower' output lists
legendText = paste0("Control:Case = ", c("5:1", "3:1", "1:1")))
Alternatively, output from computePower()
can be saved in an RData file. In this case, the outComputePower
input parameter should be the name(s) of the output file(s), and the outDir
input parameter should be the name(s) of the file location(s). For more information, visit the plotPowerTri()
help page.
computePower(..., saveDir = "myDir", saveFile = "myFile.RData")
plotPowerTri(outComputePower = c("myFile1", "myFile2", "myFile3"), # 'computePower' output files
outDir = rep("~/myDir", 3), # path to each myFilex.RData
legendText = paste0("Control:Case = ", c("5:1", "3:1", "1:1")))
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.2, # prevalence of lower protected
Plat2 = 0.6, # prevalence of higher protected
P0 = 0.2, # probability of low biomarker response
P2 = 0.6, # probability of high biomarker response
sens = c(1, 0.9, 0.8, 0.7), spec = c(1, 0.9, 0.8, 0.7),
FP0 = 0, FN2 = 0,
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri(outComputePower = pwr,
legendText = paste0("Sens = Spec = ", c(1, 0.9, 0.8, 0.7)))
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.05, # scalar; separate calls for 0.05, 0.1, 0.15, 0.2
Plat2 = 0.15, # scalar; separate calls for 0.15, 0.3, 0.45, 0.6
P0 = 0.05, # scalar; separate calls for 0.05, 0.1, 0.15, 0.2
P2 = 0.15, # scalar; separate calls for 0.15, 0.3, 0.45, 0.6
sens = 0.8, spec = 0.8, FP0 = 0, FN2 = 0,
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri(outComputePower = list(pwr1, pwr2, pwr3, pwr4),
legendText = c("Plat0=0.05, Plat2=0.15",
"Plat0=0.1, Plat2=0.3",
"Plat0=0.15, Plat2=0.45",
"Plat0=0.2, Plat2=0.6"))
computePower()
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.2, # prevalence of lower protected
Plat2 = 0.6, # prevalence of higher protected
P0 = 0.2, # probability of low biomarker response
P2 = 0.6, # probability of high biomarker response
sigma2obs = 1, # variance of observed biomarker S
rho = c(1, 0.9, 0.7, 0.5), # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri()
plotPowerTri(outComputePower = pwr,
legendText = paste0("rho = ", c(1, 0.9, 0.7, 0.5)))
plotRRgradVE()
plotRRgradVE()
plots the ratio of relative risks for the higher and lower latent subgroups \(RR_2^{lat}/RR_0^{lat}\) against the CoR relative risk effect size \(RR_t = risk_1(2)/risk_1(0)\).
Output from computePower()
can be saved as an object and assigned to the outComputePower
input parameter.
plotRRgradVE(outComputePower = pwr, # 'computePower' output list
legendText = paste0("rho = ", c(1, 0.9, 0.7, 0.5)))
Alternatively, output from computePower()
can be saved in an RData file. In this case, the outComputePower
input parameter should be the name(s) of the output file(s), and the outDir
input parameter should be the name(s) of the file location(s). For more information, visit the plotRRgradVE()
help page.
computePower(..., saveDir = "myDir", saveFile = "myFile.RData")
plotRRgradVE(outComputePower = "myFile", # file with 'computePower' output
outDir = "~/myDir", # path to myFile.RData
legendText = paste0("rho = ", c(1, 0.9, 0.7, 0.5)))
plotROCcurveTri()
plotROCcurveTri()
plots the receiver operating characteristic (ROC) curve displaying sensitivity and specificity for a range of values for P2
, P0
, Plat2
, and rho
. For more information, visit the plotROCcurveTri()
help page.
plotROCcurveTri(Plat0 = 0.2,
Plat2 = c(0.2, 0.3, 0.4, 0.5),
P0 = seq(0.90, 0.10, len=25),
P2 = seq(0.10, 0.90, len=25),
rho = c(`, 0.9, 0.7, 0.5))
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.05, # scalar; separate calls for 0.05, 0.1, 0.15, 0.2
Plat2 = 0.15, # scalar; separate calls for 0.15, 0.3, 0.45, 0.6
P0 = 0.05, # scalar; separate calls for 0.05, 0.1, 0.15, 0.2
P2 = 0.15, # scalar; separate calls for 0.15, 0.3, 0.45, 0.6
sigma2obs = 1, # variance of observed biomarker S
rho = 0.9, # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri(outComputePower = list(pwr1, pwr2, pwr3, pwr4),
legendText = c("Plat0=0.05, Plat2=0.15",
"Plat0=0.1, Plat2=0.3",
"Plat0=0.15, Plat2=0.45",
"Plat0=0.2, Plat2=0.6"))
pwr <- computePower(nCases = c(25, 32, 35, 40),
nControls = c(3661, 3654, 3651, 3646),
nCasesWithS = c(25, 32, 35, 40),
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk fom tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.2, # prevalence of lower protected
Plat2 = 0.6, # prevalence of higher protected
P0 = 0.2, # probability of low biomarker response
P2 = 0.6, # probability of high biomarker response
sigma2obs = 1, # variance of observed biomarker S
rho = 0.9, # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri(outComputePower = pwr,
legendText = paste0("nCases = ", c(25, 32, 35, 40)))
CoRpower
for binary \(\, S\) | Without replacement samplingAchieved by selecting \(P_0^{lat}\), \(P_2^{lat}\), \(P_0\), \(P_2\) such that \[ \begin{align} P_0^{lat} + P_2^{lat} &= 1\\ P_0 + P_2 &= 1 \end{align} \]
Approach 2 \((\sigma^2_{obs}\) and \(\rho\) specified\()\)
computePower()
pwr <- computePower(nCases = c(25, 32, 35, 40),
nControls = c(3661, 3654, 3651, 3646),
nCasesWithS = c(25, 32, 35, 40),
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.2, # prevalence of lower protected
Plat2 = 0.8, # prevalence of higher protected
P0 = 0.2, # probability of low biomarker response
P2 = 0.8, # probability of high biomarker response
sigma2obs = 1, # variance of observed biomarker S
rho = 0.9, # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "binary") # "continuous" by default
plotPowerTri()
plotPowerTri(outComputePower = pwr,
legendText = paste0("nCases = ", c(25, 32, 35, 40)))
sample(
\(\widetilde{x}^{\ast}\), prob=
\(f_{X^{\ast}}(\widetilde{x}^{\ast}|Y=\cdot,Y^{\tau}=0,Z=1)\), replace=TRUE)
tps
in R package osDesign
)
CoRpower
for continuous \(\, S^{\ast}\) | Without replacement samplingcomputePower()
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
PlatVElowest = 0.2, # prevalence of VE_lowest
VElowest = seq(0, VEoverall, len=100), # lowest VE for true biomarker X*<=nu
sigma2obs = 1, # variance of observed biomarker S
rho = c(1, 0.9, 0.7, 0.5) # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "continuous") # "continuous" by default
plotPowerCont()
plotPowerCont()
plots the power curve against the CoR relative risk, \(RR_c\), for continuous biomarkers.
Output from computePower()
can be saved as an object and assigned to the outComputePower
input parameter. In this scenario, since computePower()
was run multiple times to vary the controls:cases ratio, these multiple output objects can be read into the function as a list.
plotPowerCont(outComputePower = pwr, # output list from 'computePower'
legendText = paste0("rho = ", c(1, 0.9, 0.7, 0.5)))
Alternatively, output from computePower()
can be saved in an RData file. In this case, the outComputePower
input parameter should be the name(s) of the output file(s), and the outDir
input parameter should be the name(s) of the file location(s). For more information, visit the plotPowerCont()
help page.
computePower(..., saveDir = "myDir", saveFile = "myFile.RData")
plotPowerCont(outComputePower = "myFile", # file with 'computePower' output
outDir = "~/myDir", # path to myFile.RData
legendText = paste0("rho = ", c(1, 0.9, 0.7, 0.5)))
plotVElatCont()
plotVElatCont()
plots the vaccine efficacy (VE) curve for the true biomarker X=x for eight different values of the true CoR relative risk, , in vaccine recipients and the lowest vaccine efficacy level for the true biomarker, .
outComputePower
contains output from a single run of computePower()
. This output can be in the form of an assigned object, which is a list, or a character string specifying the file containing the output. Unlike plotPowerTri()
and plotPowerCont()
, which can take in output from multiple runs of computePower()
in the form of a list of lists or a character vector, this function can only take a single list or character string. For more information, visit the plotVElatCont()
help page.
Using the function when computePower()
output is saved as list object pwr
:
plotVElatCont(outComputePower = pwr)
Using the function when computePower()
output is saved in a file with name “myFile” and location “~/myDir”:
computePower(..., saveDir = "myDir", saveFile = "myFile.RData")
plotVElatCont(outComputePower = "myFile",
outDir = "~/myDir")
computePower()
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
controlCaseRatio = 5, # n^S_controls : n^S_cases ratio
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
PlatVElowest = 0.05, # scalar; separate calls for 0.05, 0.1, 0.15, 0.2
VElowest = seq(0, VEoverall, len=100), # lowest VE for true biomarker X*<=nu
sigma2obs = 1, # variance of observed biomarker S
rho = 0.9 # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "continuous") # "continuous" by default
plotPowerCont()
plotPowerCont(outComputePower = list(pwr1, pwr2, pwr3, pwr4), # output list from 'computePower'
legendText = paste0("PlatVElowest = ", c(0.05, 0.1, 0.15, 0.2)))
CoRpower
for trichotomous \(\, S\) and continuous \(\, S^{\ast}\) | Bernoulli samplingTrichotomous \(S\) (Approach 1)
Continuous \(S^{\ast}\)
computePower()
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
cohort = TRUE, # FALSE by default
p = 0.01, # scalar; separate calls for 0.01, 0.02, 0.03, 0.05
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
VElat0 = seq(0, VEoverall, len=100), # grid of VE (V/P) among lower protected
VElat1 = rep(VEoverall, 100), # grid of VE (V/P) among medium protected
Plat0 = 0.2, # prevalence of lower protected
Plat2 = 0.6, # prevalence of higher protected
P0 = 0.2, # probability of low biomarker response
P2 = 0.6, # probability of high biomarker response
sens = 0.8, spec = 0.8, FP0 = 0, FN2 = 0,
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "trichotomous") # "continuous" by default
plotPowerTri()
plotPowerTri(outComputePower = list(pwr1, pwr2, pwr3, pwr4), # 'computePower' outputs
legendText = paste0("Cohort p = ", c(0.01, 0.02, 0.03, 0.05)))
computePower()
pwr <- computePower(nCases = 32,
nControls = 3654,
nCasesWithS = 32,
cohort = TRUE, # FALSE by default
p = 0.01, # scalar; separate calls for 0.01, 0.02, 0.03, 0.05
VEoverall = 0.75, # overall VE
risk0 = 0.034, # placebo-group endpoint risk from tau - taumax
PlatVElowest = 0.2, # prevalence of VE_lowest
VElowest = seq(0, VEoverall, len=100), # lowest VE for true biomarker X*<=nu
sigma2obs = 1, # variance of observed biomarker S
rho = 0.9 # protection-relevant fraction of variance of S
M = 1000, # number of simulated clinical trials
alpha = 0.05, # two-sided Wald test Type 1 error rate
biomType = "continuous") # "continuous" by default
plotPowerCont()
plotPowerCont(outComputePower = list(pwr1, pwr2, pwr3, pwr4), # 'computePower' outputs
legendText = paste0("Cohort p = ", c(0.01, 0.02, 0.03, 0.05)))