Title: | Design of Practical Equivalence Trials |
---|---|
Description: | Sample size calculations for practical equivalence trial design with a time to event endpoint. |
Authors: | Zachary McCaw [aut, cre] |
Maintainer: | Zachary McCaw <[email protected]> |
License: | GPL-3 |
Version: | 0.0.3 |
Built: | 2025-01-27 03:09:41 UTC |
Source: | https://github.com/cran/PracticalEquiDesign |
Plot the probability of selecting the superior treatment as a function of the sample size n.
ProbCurve( cens_prop = 0, med1 = NULL, shape1 = NULL, rate1 = NULL, med2 = NULL, shape2 = NULL, rate2 = NULL, info_reps = 50, delta = 1, min_n = 10, max_n = 100, margin = 0, target_prob = 0.8, use_exp_calc = TRUE )
ProbCurve( cens_prop = 0, med1 = NULL, shape1 = NULL, rate1 = NULL, med2 = NULL, shape2 = NULL, rate2 = NULL, info_reps = 50, delta = 1, min_n = 10, max_n = 100, margin = 0, target_prob = 0.8, use_exp_calc = TRUE )
cens_prop |
Expected censoring proportion. |
med1 |
Median for treatment arm 1, assuming shape1 is 1. Overwrites shape and rate if supplied. |
shape1 |
Shape parameter for treatment arm 1. |
rate1 |
Rate parameter for treatment arm 1. |
med2 |
Median for treatment arm 2, assuming shape2 is 1. Overwrites shape and rate if supplied. |
shape2 |
Shape parameter for treatment arm 2. |
rate2 |
Rate parameter for treatment arm 2. |
info_reps |
Replicates used for estimating the observed information matrix. |
delta |
Increment between consecutive sample sizes to evaluate. |
min_n |
Minimum allowable sample size. |
max_n |
Maximum allowable sample size. |
margin |
Margin of practical equivalence. |
target_prob |
Probability of selecting the more effective treatment. |
use_exp_calc |
If both shape parameters are 1, should the calculations be performed assuming an exponential distribution for the time to event in each arm? |
ggplot object.
# Plot the selection probability curve for the case of two exponentials # with medians of 9 and 12 (e.g.) months, and a 2 month margin of # practical equivalence. q <- ProbCurve( cens_prop = 0.15, med1 = 9, med2 = 12, margin = 2.0 )
# Plot the selection probability curve for the case of two exponentials # with medians of 9 and 12 (e.g.) months, and a 2 month margin of # practical equivalence. q <- ProbCurve( cens_prop = 0.15, med1 = 9, med2 = 12, margin = 2.0 )
Estimate the sample size for a practical equivalence trial with a time to
event endpoint. The sample size is determined by specifying the time to event
distribution of each treatment arm, the margin of practical equivalence, and
the desired probability of selecting the superior treatment. The distribution
in each treatment arm may be specified either by providing the median, in
which case the time to event is assumed to be exponential, or by specifying
the shape and rate of a Weibull distribution. For guidance on how to set the
shape and rate parameters when using a Weibull calculation, see
WeibullSpec
.
SampleSize( cens_prop = 0, med1 = NULL, shape1 = NULL, rate1 = NULL, med2 = NULL, shape2 = NULL, rate2 = NULL, info_reps = 50, min_n = 10, max_n = 100, margin = 0, target_prob = 0.8, use_exp_calc = TRUE )
SampleSize( cens_prop = 0, med1 = NULL, shape1 = NULL, rate1 = NULL, med2 = NULL, shape2 = NULL, rate2 = NULL, info_reps = 50, min_n = 10, max_n = 100, margin = 0, target_prob = 0.8, use_exp_calc = TRUE )
cens_prop |
Expected censoring proportion. |
med1 |
Median for treatment arm 1, assuming shape1 is 1. Overwrites shape and rate if supplied. |
shape1 |
Shape parameter for treatment arm 1. |
rate1 |
Rate parameter for treatment arm 1. |
med2 |
Median for treatment arm 2, assuming shape2 is 1. Overwrites shape and rate if supplied. |
shape2 |
Shape parameter for treatment arm 2. |
rate2 |
Rate parameter for treatment arm 2. |
info_reps |
Replicates used for estimating the observed information matrix. |
min_n |
Minimum allowable sample size. |
max_n |
Maximum allowable sample size. |
margin |
Margin of practical equivalence. |
target_prob |
Probability of selecting the more effective treatment. |
use_exp_calc |
If both shape parameters are 1, should the calculations be performed assuming an exponential distribution for the time to event in each arm? Default is TRUE. |
Integer sample size.
# Sample size calculation based on exponentials. n <- SampleSize( cens_prop = 0.15, med1 = 9, med2 = 12 ) # Sample size calculation based on exponentials with a 2 month margin. # Note that the required sample size is expected to increase. n <- SampleSize( cens_prop = 0.15, med1 = 9, med2 = 12, margin = 2 ) # Sample size calculation based on Weibulls. n <- SampleSize( cens_prop = 0.15, shape1 = 2.8, rate1 = 0.10, shape2 = 4.0, rate2 = 0.08 )
# Sample size calculation based on exponentials. n <- SampleSize( cens_prop = 0.15, med1 = 9, med2 = 12 ) # Sample size calculation based on exponentials with a 2 month margin. # Note that the required sample size is expected to increase. n <- SampleSize( cens_prop = 0.15, med1 = 9, med2 = 12, margin = 2 ) # Sample size calculation based on Weibulls. n <- SampleSize( cens_prop = 0.15, shape1 = 2.8, rate1 = 0.10, shape2 = 4.0, rate2 = 0.08 )
Probability of selecting the more effective treatment as pr(median2 - median1 >= margin) + 0.5 * pr(abs(median2 - median1) < margin).
SupProb( cens_prop, n, med1 = NULL, shape1 = NULL, rate1 = NULL, med2 = NULL, shape2 = NULL, rate2 = NULL, info_reps = 50, margin = 0, use_exp_calc = TRUE )
SupProb( cens_prop, n, med1 = NULL, shape1 = NULL, rate1 = NULL, med2 = NULL, shape2 = NULL, rate2 = NULL, info_reps = 50, margin = 0, use_exp_calc = TRUE )
cens_prop |
Expected censoring proportion. |
n |
Sample size. |
med1 |
Median for treatment arm 1, assuming shape1 = 1. Overwrites shape and rate if supplied. |
shape1 |
Shape parameter for arm 1. |
rate1 |
Rate parameter for arm 1. |
med2 |
Median for treatment arm 2, assuming shape2 = 1. Overwrites shape and rate if supplied. |
shape2 |
Shape parameter for arm 2. |
rate2 |
Rate parameter for arm 2. |
info_reps |
Replicates used for estimating the observed information matrix. |
margin |
Margin of practical equivalence. |
use_exp_calc |
If both shape parameters are 1, should the calculations be performed assuming an exponential distribution for the time to event in each arm? Default is TRUE. |
Numeric equivalence probability.
# Calculation in the case of exponentials with no margin. prob <- SupProb( cens_prop = 0.15, n = 100, med1 = 9, med2 = 12, ) # Calculation in the case of exponentials with a 2 month margin. # The probability should be lower than in the absence of a margin. prob <- SupProb( cens_prop = 0.15, n = 100, med1 = 9, med2 = 12, margin = 2 ) # Calculation in the case of Weibulls with a 2 month margin. prob <- SupProb( cens_prop = 0.15, n = 100, shape1 = 2.8, rate1 = 0.10, shape2 = 4.0, rate2 = 0.08, margin = 2 )
# Calculation in the case of exponentials with no margin. prob <- SupProb( cens_prop = 0.15, n = 100, med1 = 9, med2 = 12, ) # Calculation in the case of exponentials with a 2 month margin. # The probability should be lower than in the absence of a margin. prob <- SupProb( cens_prop = 0.15, n = 100, med1 = 9, med2 = 12, margin = 2 ) # Calculation in the case of Weibulls with a 2 month margin. prob <- SupProb( cens_prop = 0.15, n = 100, shape1 = 2.8, rate1 = 0.10, shape2 = 4.0, rate2 = 0.08, margin = 2 )
Estimate the expected information as the average value of the observed information across 'reps' realizations of the data.
WeiAvgInfo(cens_prop, n, shape, rate, reps = 10)
WeiAvgInfo(cens_prop, n, shape, rate, reps = 10)
cens_prop |
Censoring proportion. |
n |
Sample size. |
shape |
Shape parameter 'alpha'. |
rate |
Rate parameter 'lambda'. |
reps |
Replicates to average. |
Numeric information matrix for shape and rate.
Calculate shape and rate of a Weibull distribution from the value of the survival curve at 2 time points.
WeibullSpec(t1, p1, t2, p2)
WeibullSpec(t1, p1, t2, p2)
t1 |
First time point. |
p1 |
Probability at the first time point. |
t2 |
Second time point. |
p2 |
Probability at the second time point. |
Numeric vector containing the shape and rate.
# Determine the shape and rate parameter of a Weibull distribution # where survival at 6 (e.g.) months is 80%, and survival at 12 # months is 50%. theta <- WeibullSpec(t1 = 6, p1 = 0.8, t2 = 12, p2 = 0.5)
# Determine the shape and rate parameter of a Weibull distribution # where survival at 6 (e.g.) months is 80%, and survival at 12 # months is 50%. theta <- WeibullSpec(t1 = 6, p1 = 0.8, t2 = 12, p2 = 0.5)
Calculate the median of a Weibull distribution from the shape and rate.
WeiMed(shape, rate)
WeiMed(shape, rate)
shape |
Shape parameter, 'alpha'. |
rate |
Rate parameter, 'lambda'. |
Numeric median.
# In the case of shape = 1 and rate = 1, the distribution # is exponential, and the median is log(2). med <- WeiMed(shape = 1, rate = 1)
# In the case of shape = 1 and rate = 1, the distribution # is exponential, and the median is log(2). med <- WeiMed(shape = 1, rate = 1)