Package 'PracticalEquiDesign'

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

Help Index


Plot Sample Size Curve

Description

Plot the probability of selecting the superior treatment as a function of the sample size n.

Usage

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
)

Arguments

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?

Value

ggplot object.

Examples

# 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
)

Sample Size Estimation

Description

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.

Usage

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
)

Arguments

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.

Value

Integer sample size.

Examples

# 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
)

Superiority Probability

Description

Probability of selecting the more effective treatment as pr(median2 - median1 >= margin) + 0.5 * pr(abs(median2 - median1) < margin).

Usage

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
)

Arguments

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.

Value

Numeric equivalence probability.

Examples

# 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
)

Weibull Average Information

Description

Estimate the expected information as the average value of the observed information across 'reps' realizations of the data.

Usage

WeiAvgInfo(cens_prop, n, shape, rate, reps = 10)

Arguments

cens_prop

Censoring proportion.

n

Sample size.

shape

Shape parameter 'alpha'.

rate

Rate parameter 'lambda'.

reps

Replicates to average.

Value

Numeric information matrix for shape and rate.


Weibull Specification

Description

Calculate shape and rate of a Weibull distribution from the value of the survival curve at 2 time points.

Usage

WeibullSpec(t1, p1, t2, p2)

Arguments

t1

First time point.

p1

Probability at the first time point.

t2

Second time point.

p2

Probability at the second time point.

Value

Numeric vector containing the shape and rate.

Examples

# 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)

Weibull Median

Description

Calculate the median of a Weibull distribution from the shape and rate.

Usage

WeiMed(shape, rate)

Arguments

shape

Shape parameter, 'alpha'.

rate

Rate parameter, 'lambda'.

Value

Numeric median.

Examples

# 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)