Package 'lrstat'

Title: Power and Sample Size Calculation for Non-Proportional Hazards and Beyond
Description: Performs power and sample size calculation for non-proportional hazards model using the Fleming-Harrington family of weighted log-rank tests. The sequentially calculated log-rank test score statistics are assumed to have independent increments as characterized in Anastasios A. Tsiatis (1982) <doi:10.1080/01621459.1982.10477898>. The mean and variance of log-rank test score statistics are calculated based on Kaifeng Lu (2021) <doi:10.1002/pst.2069>. The boundary crossing probabilities are calculated using the recursive integration algorithm described in Christopher Jennison and Bruce W. Turnbull (2000, ISBN:0849303168). The package can also be used for continuous, binary, and count data. For continuous data, it can handle missing data through mixed-model for repeated measures (MMRM). In crossover designs, it can estimate direct treatment effects while accounting for carryover effects. For binary data, it can design Simon's 2-stage, modified toxicity probability-2 (mTPI-2), and Bayesian optimal interval (BOIN) trials. For count data, it can design group sequential trials for negative binomial endpoints with censoring. Additionally, it facilitates group sequential equivalence trials for all supported data types. Moreover, it can design adaptive group sequential trials for changes in sample size, error spending function, number and spacing or future looks. Finally, it offers various options for adjusted p-values, including graphical and gatekeeping procedures.
Authors: Kaifeng Lu [aut, cre]
Maintainer: Kaifeng Lu <[email protected]>
License: GPL (>= 2)
Version: 0.2.9
Built: 2024-09-23 06:31:44 UTC
Source: CRAN

Help Index


Number of enrolled subjects

Description

Obtains the number of subjects enrolled by given calendar times.

Usage

accrual(
  time = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  accrualDuration = NA_real_
)

Arguments

time

A vector of calendar times at which to calculate the number of enrolled subjects.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

accrualDuration

Duration of the enrollment period.

Value

A vector of total number of subjects enrolled by the specified calendar times.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: Uniform enrollment with 20 patients per month for 12 months.

accrual(time = 3, accrualTime = 0, accrualIntensity = 20,
        accrualDuration = 12)


# Example 2: Piecewise accrual, 10 patients per month for the first
# 3 months, and 20 patients per month thereafter. Patient recruitment
# ends at 12 months for the study.

accrual(time = c(2, 9), accrualTime = c(0, 3),
        accrualIntensity = c(10, 20), accrualDuration = 12)

Adaptive design at an interim look

Description

Obtains the conditional power for specified incremental information given the interim results, parameter value, and data-dependent changes in the error spending function, and the number and spacing of interim looks. Conversely, obtains the incremental information needed to attain a specified conditional power given the interim results, parameter value, and data-dependent changes in the error spending function, and the number and spacing of interim looks.

Usage

adaptDesign(
  betaNew = NA_real_,
  INew = NA_real_,
  L = NA_integer_,
  zL = NA_real_,
  theta = NA_real_,
  IMax = NA_real_,
  kMax = NA_integer_,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  spendingTime = NA_real_,
  MullerSchafer = 0L,
  kNew = NA_integer_,
  informationRatesNew = NA_real_,
  efficacyStoppingNew = NA_integer_,
  futilityStoppingNew = NA_integer_,
  typeAlphaSpendingNew = "sfOF",
  parameterAlphaSpendingNew = NA_real_,
  typeBetaSpendingNew = "none",
  parameterBetaSpendingNew = NA_real_,
  userBetaSpendingNew = NA_real_,
  spendingTimeNew = NA_real_,
  varianceRatio = 1
)

Arguments

betaNew

The type II error for the secondary trial.

INew

The maximum information of the secondary trial. Either betaNew or INew should be provided while the other one should be missing.

L

The interim adaptation look of the primary trial.

zL

The z-test statistic at the interim adaptation look of the primary trial.

theta

The parameter value.

IMax

The maximum information of the primary trial. Must be provided if futilityBounds is missing and typeBetaSpending is not equal to "none", or if conditional power calculation is desired.

kMax

The maximum number of stages of the primary trial.

informationRates

The information rates of the primary trial.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage of the primary trial. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage of the primary trial. Defaults to true if left unspecified.

criticalValues

The upper boundaries on the z-test statistic scale for efficacy stopping for the primary trial.

alpha

The significance level of the primary trial. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending for the primary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value of alpha spending for the primary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending for the primary trial. Cumulative alpha spent up to each stage.

futilityBounds

The lower boundaries on the z-test statistic scale for futility stopping for the primary trial. Defaults to rep(-6, kMax-1) if left unspecified.

typeBetaSpending

The type of beta spending for the primary trial. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value of beta spending for the primary trial. Corresponds to rho for "sfKD", and gamma for "sfHSD".

spendingTime

The error spending time of the primary trial. Defaults to missing, in which case, it is the same as informationRates.

MullerSchafer

Whether to use the Muller and Schafer (2001) method for trial adaptation.

kNew

The number of looks of the secondary trial.

informationRatesNew

The spacing of looks of the secondary trial.

efficacyStoppingNew

The indicators of whether efficacy stopping is allowed at each look of the secondary trial. Defaults to true if left unspecified.

futilityStoppingNew

The indicators of whether futility stopping is allowed at each look of the secondary trial. Defaults to true if left unspecified.

typeAlphaSpendingNew

The type of alpha spending for the secondary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpendingNew

The parameter value of alpha spending for the secondary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

typeBetaSpendingNew

The type of beta spending for the secondary trial. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpendingNew

The parameter value of beta spending for the secondary trial. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpendingNew

The user defined cumulative beta spending. Cumulative beta spent up to each stage of the secondary trial.

spendingTimeNew

The error spending time of the secondary trial. Defaults to missing, in which case, it is the same as informationRatesNew.

varianceRatio

The ratio of the variance under H0 to the variance under H1.

Value

An adaptDesign object with two list components:

  • primaryTrial: A list of selected information for the primary trial, including L, zL, theta, kMax, informationRates, efficacyBounds, futilityBounds, and MullerSchafer.

  • secondaryTrial: A design object for the secondary trial.

Author(s)

Kaifeng Lu, [email protected]

References

Lu Chi, H. M. James Hung, and Sue-Jane Wang. Modification of sample size in group sequential clinical trials. Biometrics 1999;55:853-857.

Hans-Helge Muller and Helmut Schafer. Adaptive group sequential designs for clinical trials: Combining the advantages of adaptive and of classical group sequential approaches. Biometrics 2001;57:886-891.

See Also

getDesign

Examples

# original group sequential design with 90% power to detect delta = 6
delta = 6
sigma = 17
n = 282
(des1 = getDesign(IMax = n/(4*sigma^2), theta = delta, kMax = 3,
                  alpha = 0.05, typeAlphaSpending = "sfHSD",
                  parameterAlphaSpending = -4))

# interim look results
L = 1
n1 = n/3
delta1 = 4.5
sigma1 = 20
zL = delta1/sqrt(4/n1*sigma1^2)

t = des1$byStageResults$informationRates

# conditional power with sample size increase
(des2 = adaptDesign(
  betaNew = NA, INew = 420/(4*sigma1^2),
  L, zL, theta = delta1,
  IMax = n/(4*sigma1^2), kMax = 3, informationRates = t,
  alpha = 0.05, typeAlphaSpending = "sfHSD",
  parameterAlphaSpending = -4))

# Muller & Schafer (2001) method to design the secondary trial:
# 3-look gamma(-2) spending with 84% power at delta = 4.5 and sigma = 20
(des2 = adaptDesign(
  betaNew = 0.16, INew = NA,
  L, zL, theta = delta1,
  IMax = n/(4*sigma1^2), kMax = 3, informationRates = t,
  alpha = 0.05, typeAlphaSpending = "sfHSD",
  parameterAlphaSpending = -4,
  MullerSchafer = TRUE,
  kNew = 3, typeAlphaSpendingNew = "sfHSD",
  parameterAlphaSpendingNew = -2))

# incremental sample size for sigma = 20
(nNew = 4*sigma1^2*des2$secondaryTrial$overallResults$information)

Acute myelogenous leukemia survival data from the survival package

Description

Survival in patients with acute myelogenous leukemia.

time

Survival or censoring time

status

censoring status

x

maintenance chemotherapy given or not

Usage

aml

Format

An object of class data.frame with 23 rows and 3 columns.


Simulation for a binary endpoint and a time-to-event endpoint

Description

Performs simulation for two-endpoint two-arm group sequential trials. The first endpoint is a binary endpoint and the Mantel-Haenszel test is used to test risk difference. The second endpoint is a time-to-event endpoint and the log-rank test is used to test the treatment difference. The analysis times of the first endpoint are determined by the specified calendar times, while the analysis times for the second endpoint is based on the planned number of events at each look. The binary endpoint is assessed at the first post-treatment follow-up visit.

Usage

binary_tte_sim(
  kMax1 = 1L,
  kMax2 = 1L,
  riskDiffH0 = 0,
  hazardRatioH0 = 1,
  allocation1 = 1L,
  allocation2 = 1L,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  globalOddsRatio = 1,
  pi1 = NA_real_,
  pi2 = NA_real_,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  delta1 = 0L,
  delta2 = 0L,
  upper1 = NA_real_,
  upper2 = NA_real_,
  accrualDuration = NA_real_,
  plannedTime = NA_real_,
  plannedEvents = NA_integer_,
  maxNumberOfIterations = 1000L,
  maxNumberOfRawDatasetsPerStage = 0L,
  seed = NA_integer_
)

Arguments

kMax1

Number of stages for the binary endpoint.

kMax2

Number of stages for the time-to-event endpoint.

riskDiffH0

Risk difference under the null hypothesis for the binary endpoint.

hazardRatioH0

Hazard ratio under the null hypothesis for the time-to-event endpoint.

allocation1

Number of subjects in the treatment group in a randomization block. Defaults to 1 for equal randomization.

allocation2

Number of subjects in the control group in a randomization block. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

globalOddsRatio

The global odds ratio of the Plackett copula.

pi1

Response probabilities by stratum for the treatment group for the binary endpoint.

pi2

Response probabilities by stratum for the control group for the binary endpoint.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the treatment group for the time-to-event endpoint.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group for the time-to-event endpoint.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

delta1

The hazard rate for exponential treatment discontinuation, a vector of hazard rates for piecewise exponential treatment discontinuation applicable for all strata, or a vector of hazard rates for treatment discontinuation in each analysis time interval by stratum for the treatment group for the binary endpoint.

delta2

The hazard rate for exponential treatment discontinuation, a vector of hazard rates for piecewise exponential treatment discontinuation applicable for all strata, or a vector of hazard rates for treatment discontinuation in each analysis time interval by stratum for the control group for the binary endpoint.

upper1

The protocol-specified treatment duration for the treatment group.

upper2

The protocol-specified treatment duration for the control group.

accrualDuration

Duration of the enrollment period.

plannedTime

The calendar times for the analyses of the binary endpoint.

plannedEvents

The planned cumulative total number of events for the time-to-event endpoint.

maxNumberOfIterations

The number of simulation iterations.

maxNumberOfRawDatasetsPerStage

The number of raw datasets per stage to extract.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified,

Details

We consider dual primary endpoints with endpoint 1 being a binary endpoint and endpoint 2 being a time-to-event endpoint. The analyses of endpoint 1 will be based on calendar times, while the analyses of endpoint 2 will be based on the number of events. Therefor the analyses of the two endpoints are not at the same time points. The correlation between the two endpoints is characterized by the global odds ratio of the Plackett copula. In addition, the time-to-event endpoint will render the binary endpoint as a non-responder, and so does the dropout. In addition, the treatment discontinuation will impact the number of available subjects for analysis. The administrative censoring will exclude subjects from the analysis of the binary endpoint.

Value

A list with 4 components:

  • sumdataBIN: A data frame of summary data by iteration and stage for the binary endpoint:

    • iterationNumber: The iteration number.

    • stageNumber: The stage number, covering all stages even if the trial stops at an interim look.

    • analysisTime: The time for the stage since trial start.

    • accruals1: The number of subjects enrolled at the stage for the treatment group.

    • accruals2: The number of subjects enrolled at the stage for the control group.

    • totalAccruals: The total number of subjects enrolled at the stage.

    • source1: The total number of subjects with response status determined by the underlying latent response variable.

    • source2: The total number of subjects with response status (non-responder) determined by experiencing the event for the time-to-event endpoint.

    • source3: The total number of subjects with response status (non-responder) determined by dropping out prior to the PTFU1 visit.

    • n1: The number of subjects included in the analysis of the binary endpoint for the treatment group.

    • n2: The number of subjects included in the analysis of the binary endpoint for the control group.

    • n: The total number of subjects included in the analysis of the binary endpoint at the stage.

    • y1: The number of responders for the binary endpoint in the treatment group.

    • y2: The number of responders for the binary endpoint in the control group.

    • y: The total number of responders for the binary endpoint at the stage.

    • riskDiff: The estimated risk difference for the binary endpoint.

    • seRiskDiff: The standard error for risk difference based on the Sato approximation.

    • mnStatistic: The Mantel-Haenszel test Z-statistic for the binary endpoint.

  • sumdataTTE: A data frame of summary data by iteration and stage for the time-to-event endpoint:

    • iterationNumber: The iteration number.

    • eventsNotAchieved: Whether the target number of events is not achieved for the iteration.

    • stageNumber: The stage number, covering all stages even if the trial stops at an interim look.

    • analysisTime: The time for the stage since trial start.

    • accruals1: The number of subjects enrolled at the stage for the treatment group.

    • accruals2: The number of subjects enrolled at the stage for the control group.

    • totalAccruals: The total number of subjects enrolled at the stage.

    • events1: The number of events at the stage for the treatment group.

    • events2: The number of events at the stage for the control group.

    • totalEvents: The total number of events at the stage.

    • dropouts1: The number of dropouts at the stage for the treatment group.

    • dropouts2: The number of dropouts at the stage for the control group.

    • totalDropouts: The total number of dropouts at the stage.

    • logRankStatistic: The log-rank test Z-statistic for the time-to-event endpoint.

  • rawdataBIN (exists if maxNumberOfRawDatasetsPerStage is a positive integer): A data frame for subject-level data for the binary endpoint for selected replications, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage under consideration.

    • analysisTime: The time for the stage since trial start.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • treatmentGroup: The treatment group (1 or 2) for the subject.

    • survivalTime: The underlying survival time for the time-to-event endpoint for the subject.

    • dropoutTime: The underlying dropout time for the time-to-event endpoint for the subject.

    • ptfu1Time:The underlying assessment time for the binary endpoint for the subject.

    • timeUnderObservation: The time under observation since randomization for the binary endpoint for the subject.

    • responder: Whether the subject is a responder for the binary endpoint.

    • source: The source of the determination of responder status for the binary endpoint: = 1 based on the underlying latent response variable, = 2 based on the occurrence of the time-to-event endpoint before the assessment time of the binary endpoint (imputed as a non-responder), = 3 based on the dropout before the assessment time of the binary endpoint (imputed as a non-responder), = 4 excluded from analysis due to administrative censoring.

  • rawdataTTE (exists if maxNumberOfRawDatasetsPerStage is a positive integer): A data frame for subject-level data for the time-to-event endpoint for selected replications, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage under consideration.

    • analysisTime: The time for the stage since trial start.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • treatmentGroup: The treatment group (1 or 2) for the subject.

    • survivalTime: The underlying survival time for the time-to-event endpoint for the subject.

    • dropoutTime: The underlying dropout time for the time-to-event endpoint for the subject.

    • timeUnderObservation: The time under observation since randomization for the time-to-event endpoint for the subject.

    • event: Whether the subject experienced the event for the time-to-event endpoint.

    • dropoutEvent: Whether the subject dropped out for the time-to-event endpoint.

Author(s)

Kaifeng Lu, [email protected]

Examples

tcut = c(0, 12, 36, 48)
surv = c(1, 0.95, 0.82, 0.74)
lambda2 = (log(surv[1:3]) - log(surv[2:4]))/(tcut[2:4] - tcut[1:3])

sim1 = binary_tte_sim(
  kMax1 = 1,
  kMax2 = 2,
  accrualTime = 0:8,
  accrualIntensity = c(((1:8) - 0.5)/8, 1)*40,
  piecewiseSurvivalTime = c(0,12,36),
  globalOddsRatio = 1,
  pi1 = 0.80,
  pi2 = 0.65,
  lambda1 = 0.65*lambda2,
  lambda2 = lambda2,
  gamma1 = -log(1-0.04)/12,
  gamma2 = -log(1-0.04)/12,
  delta1 = -log(1-0.02)/12,
  delta2 = -log(1-0.02)/12,
  upper1 = 15*28/30.4,
  upper2 = 12*28/30.4,
  accrualDuration = 20,
  plannedTime = 20 + 15*28/30.4,
  plannedEvents = c(130, 173),
  maxNumberOfIterations = 1000,
  maxNumberOfRawDatasetsPerStage = 1,
  seed = 314159)

BOIN decision table

Description

Obtains the decision table for the Bayesian optimal interval (BOIN) design.

Usage

BOINTable(
  nMax = NA_integer_,
  pT = 0.3,
  phi1 = 0.6 * pT,
  phi2 = 1.4 * pT,
  a = 1,
  b = 1,
  pExcessTox = 0.95
)

Arguments

nMax

The maximum number of subjects in a dose cohort.

pT

The target toxicity probability. Defaults to 0.3.

phi1

The lower equivalence limit for target toxicity probability.

phi2

The upper equivalence limit for target toxicity probability.

a

The prior toxicity parameter for the beta prior.

b

The prior non-toxicity parameter for the beta prior.

pExcessTox

The threshold for excessive toxicity, i.e., if Prob(p > pT | Data) > pExcessTox, then the current and all higher doses will be excluded and never be used again in the remainder of the trial to avoid any other subjects receiving treatment at those doses. Defaults to 0.95.

Value

An S3 class BOINTable object with the following components:

  • settings: The input settings data frame with the following variables:

    • nMax: The maximum number of subjects in a dose cohort.

    • pT: The target toxicity probability.

    • phi1: The lower equivalence limit for target toxicity probability.

    • phi2: The upper equivalence limit for target toxicity probability.

    • lambda1: The lower decision boundary for observed toxicity probability.

    • lambda2: The upper decision boundary for observed toxicity probability.

    • a: The prior toxicity parameter for the beta prior.

    • b: The prior non-toxicity parameter for the beta prior.

    • pExcessTox: The threshold for excessive toxicity.

  • decisionDataFrame: The decision data frame for the BOIN design. It includes the following variables:

    • n: The sample size.

    • y: The number of toxicities.

    • decision: The dosing decision.

  • decisionMatrix: The decision matrix corresponding to the decision data frame.

Author(s)

Kaifeng Lu, [email protected]

Examples

BOINTable(nMax = 18, pT = 0.3, phi = 0.6*0.3, phi2 = 1.4*0.3)

Calendar times for target number of events

Description

Obtains the calendar times needed to reach the target number of subjects experiencing an event.

Usage

caltime(
  nevents = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L
)

Arguments

nevents

A vector of target number of events.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

Value

A vector of calendar times expected to yield the target number of events.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survivals, and 5% dropout by
# the end of 1 year.

caltime(nevents = c(24, 80), allocationRatioPlanned = 1,
        accrualTime = seq(0, 8),
        accrualIntensity = 26/9*seq(1, 9),
        piecewiseSurvivalTime = c(0, 6),
        stratumFraction = c(0.2, 0.8),
        lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
        lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
        gamma1 = -log(1-0.05)/12,
        gamma2 = -log(1-0.05)/12,
        accrualDuration = 22,
        followupTime = 18, fixedFollowup = FALSE)

Clopper-Pearson confidence interval for one-sample proportion

Description

Obtains the Clopper-Pearson exact confidence interval for a one-sample proportion.

Usage

ClopperPearsonCI(n, y, cilevel = 0.95)

Arguments

n

The sample size.

y

The number of responses.

cilevel

The confidence interval level.

Value

A data frame with the following variables:

  • n: The sample size.

  • y: The number of responses.

  • phat: The observed proportion of responses.

  • lower: The lower limit of the confidence interval.

  • upper: The upper limit of the confidence interval.

  • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

ClopperPearsonCI(20, 3)

Covariance between restricted mean survival times

Description

Obtains the covariance between restricted mean survival times at two different time points.

Usage

covrmst(
  t2 = NA_real_,
  tau1 = NA_real_,
  tau2 = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  maxFollowupTime = NA_real_
)

Arguments

t2

The calendar time for analysis 2.

tau1

The milestone time for analysis 1.

tau2

The milestone time for analysis 2.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

lambda1

A vector of hazard rates for the event for the active treatment group. One for each analysis time interval.

lambda2

A vector of hazard rates for the event for the control group. One for each analysis time interval.

gamma1

The hazard rate for exponential dropout, or a vector of hazard rates for piecewise exponential dropout for the active treatment group.

gamma2

The hazard rate for exponential dropout, or a vector of hazard rates for piecewise exponential dropout for the control group.

accrualDuration

Duration of the enrollment period.

maxFollowupTime

Follow-up time for the first enrolled subject. For fixed followup, maxFollowupTime = minFollowupTime. For variable followup, maxFollowupTime = accrualDuration + minFollowupTime.

Value

The covariance between the restricted mean survival times for each treatment group.

Author(s)

Kaifeng Lu, [email protected]

Examples

covrmst(t2 = 25, tau1 = 16, tau2 = 18, allocationRatioPlanned = 1,
        accrualTime = c(0, 3), accrualIntensity = c(10, 20),
        piecewiseSurvivalTime = c(0, 6),
        lambda1 = c(0.0533, 0.0309), lambda2 = c(0.0533, 0.0533),
        gamma1 = -log(1-0.05)/12, gamma2 = -log(1-0.05)/12,
        accrualDuration = 12, maxFollowupTime = 30)

Error spending

Description

Obtains the error spent at given spending times for the specified error spending function.

Usage

errorSpent(t, error, sf = "sfOF", sfpar = NA)

Arguments

t

A vector of spending times, typically equal to information fractions.

error

The total error to spend.

sf

The spending function. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, and "sfHSD" for Hwang, Shi & DeCani spending function. Defaults to "sfOF".

sfpar

The parameter for the spending function. Corresponds to rho for "sfKD" and gamma for "sfHSD".

Value

A vector of errors spent up to the interim look.

Author(s)

Kaifeng Lu, [email protected]

Examples

errorSpent(t = 0.5, error = 0.025, sf = "sfOF")
errorSpent(t = c(0.5, 0.75, 1), error = 0.025, sf = "sfHSD", sfpar = -4)

Stagewise exit probabilities

Description

Obtains the stagewise exit probabilities for both efficacy and futility stopping.

Usage

exitprob(b, a = NA, theta = 0, I = NA)

Arguments

b

Upper boundaries on the z-test statistic scale.

a

Lower boundaries on the z-test statistic scale. Defaults to c(rep(-6.0, kMax-1), b[kMax]) if left unspecified, where kMax = length(b).

theta

Stagewise parameter of interest, e.g., -U/V for weighted log-rank test, where U is the mean and V is the variance of the weighted log-rank test score statistic at each stage. For proportional hazards and conventional log-rank test, use the scalar input, theta = -log(HR). Defaults to 0 corresponding to the null hypothesis.

I

Stagewise cumulative information, e.g., V, the variance of the weighted log-rank test score statistic at each stage. For conventional log-rank test, information can be approximated by phi*(1-phi)*D, where phi is the probability of being allocated to the active arm, and D is the total number of events at each stage. Defaults to seq(1, kMax) if left unspecified.

Value

A list of stagewise exit probabilities:

  • exitProbUpper: The vector of efficacy stopping probabilities

  • exitProbLower: The vector of futility stopping probabilities.

Author(s)

Kaifeng Lu, [email protected]

Examples

exitprob(b = c(3.471, 2.454, 2.004), theta = -log(0.6),
         I = c(50, 100, 150)/4)

exitprob(b = c(2.963, 2.359, 2.014),
         a = c(-0.264, 0.599, 2.014),
         theta = c(0.141, 0.204, 0.289),
         I = c(81, 121, 160))

Adjusted p-values for Bonferroni-based graphical approaches

Description

Obtains the adjusted p-values for graphical approaches using weighted Bonferroni tests.

Usage

fadjpbon(w, G, p)

Arguments

w

The vector of initial weights for elementary hypotheses.

G

The initial transition matrix.

p

The raw p-values for elementary hypotheses.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

References

Frank Bretz, Willi Maurer, Werner Brannath and Martin Posch. A graphical approach to sequentially rejective multiple test procedures. Statistics in Medicine. 2009; 28:586-604.

Examples

pvalues <- matrix(c(0.01,0.005,0.015,0.022, 0.02,0.015,0.010,0.023),
                  nrow=2, ncol=4, byrow=TRUE)
w <- c(0.5,0.5,0,0)
g <- matrix(c(0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0),
            nrow=4, ncol=4, byrow=TRUE)
fadjpbon(w, g, pvalues)

Adjusted p-values for Dunnett-based graphical approaches

Description

Obtains the adjusted p-values for graphical approaches using weighted Dunnett tests.

Usage

fadjpdun(wgtmat, p, family = NULL, corr = NULL)

Arguments

wgtmat

The weight matrix for intersection hypotheses.

p

The raw p-values for elementary hypotheses.

family

The matrix of family indicators for elementary hypotheses.

corr

The correlation matrix that should be used for the parametric test. Can contain NAs for unknown correlations between families.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

References

Frank Bretz, Martin Posch, Ekkehard Glimm, Florian Klinglmueller, Willi Maurer, and Kornelius Rohmeyer. Graphical approach for multiple comparison procedures using weighted Bonferroni, Simes, or parameter tests. Biometrical Journal. 2011; 53:894-913.

Examples

pvalues <- matrix(c(0.01,0.005,0.015,0.022, 0.02,0.015,0.010,0.023),
                  nrow=2, ncol=4, byrow=TRUE)
w <- c(0.5,0.5,0,0)
g <- matrix(c(0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0),
            nrow=4, ncol=4, byrow=TRUE)
wgtmat = fwgtmat(w,g)

family = matrix(c(1,1,0,0,0,0,1,1), nrow=2, ncol=4, byrow=TRUE)
corr = matrix(c(1,0.5,NA,NA, 0.5,1,NA,NA,
                NA,NA,1,0.5, NA,NA,0.5,1),
              nrow = 4, byrow = TRUE)
fadjpdun(wgtmat, pvalues, family, corr)

Adjusted p-values for Simes-based graphical approaches

Description

Obtains the adjusted p-values for graphical approaches using weighted Simes tests.

Usage

fadjpsim(wgtmat, p, family = NULL)

Arguments

wgtmat

The weight matrix for intersection hypotheses.

p

The raw p-values for elementary hypotheses.

family

The matrix of family indicators for elementary hypotheses.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

References

Frank Bretz, Martin Posch, Ekkehard Glimm, Florian Klinglmueller, Willi Maurer, and Kornelius Rohmeyer. Graphical approach for multiple comparison procedures using weighted Bonferroni, Simes, or parameter tests. Biometrical Journal. 2011; 53:894-913.

Kaifeng Lu. Graphical approaches using a Bonferroni mixture of weighted Simes tests. Statistics in Medicine. 2016; 35:4041-4055.

Examples

pvalues <- matrix(c(0.01,0.005,0.015,0.022, 0.02,0.015,0.010,0.023),
                  nrow=2, ncol=4, byrow=TRUE)
w <- c(0.5,0.5,0,0)
g <- matrix(c(0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0),
            nrow=4, ncol=4, byrow=TRUE)
wgtmat = fwgtmat(w,g)

family = matrix(c(1,1,0,0,0,0,1,1), nrow=2, ncol=4, byrow=TRUE)
fadjpsim(wgtmat, pvalues, family)

Adjusted p-values for modified mixture gatekeeping procedures

Description

Obtains the adjusted p-values for the modified gatekeeping procedures for multiplicity problems involving serial and parallel logical restrictions.

Usage

fmodmix(
  p,
  family = NULL,
  serial,
  parallel,
  gamma,
  test = "hommel",
  exhaust = 1
)

Arguments

p

The raw p-values for elementary hypotheses.

family

The matrix of family indicators for the hypotheses.

serial

The matrix of serial rejection set for the hypotheses.

parallel

The matrix of parallel rejection set for the hypotheses.

gamma

The truncation parameters for each family. The truncation parameter for the last family is automatically set to 1.

test

The component multiple testing procedure. Options include "holm", "hochberg", or "hommel". Defaults to "hommel".

exhaust

Whether to use alpha-exhausting component testing procedure for the last family with active hypotheses. It defaults to TRUE.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

References

Alex Dmitrienko, George Kordzakhia, and Thomas Brechenmacher. Mixture-based gatekeeping procedures for multiplicity problems with multiple sequences of hypotheses. Journal of Biopharmaceutical Statistics. 2016; 26(4):758–780.

George Kordzakhia, Thomas Brechenmacher, Eiji Ishida, Alex Dmitrienko, Winston Wenxiang Zheng, and David Fuyuan Li. An enhanced mixture method for constructing gatekeeping procedures in clinical trials. Journal of Biopharmaceutical Statistics. 2018; 28(1):113–128.

Examples

p = c(0.0194, 0.0068, 0.0271, 0.0088, 0.0370, 0.0018, 0.0814, 0.0066)
family = matrix(c(1, 1, 0, 0, 0, 0, 0, 0,
                  0, 0, 1, 1, 0, 0, 0, 0,
                  0, 0, 0, 0, 1, 1, 0, 0,
                  0, 0, 0, 0, 0, 0, 1, 1),
                nrow=4, byrow=TRUE)

serial = matrix(c(0, 0, 0, 0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0, 0, 0, 0,
                  1, 0, 0, 0, 0, 0, 0, 0,
                  0, 1, 0, 0, 0, 0, 0, 0,
                  0, 0, 1, 0, 0, 0, 0, 0,
                  0, 0, 0, 1, 0, 0, 0, 0,
                  0, 0, 0, 0, 1, 0, 0, 0,
                  0, 0, 0, 0, 0, 1, 0, 0),
                nrow=8, byrow=TRUE)

parallel = matrix(0, 8, 8)
gamma = c(0.6, 0.6, 0.6, 1)
fmodmix(p, family, serial, parallel, gamma, test = "hommel", exhaust = 1)

The quantiles of a survival distribution

Description

Obtains the quantiles of a survival distribution.

Usage

fquantile(S, probs, ...)

Arguments

S

The survival function of a univariate survival time.

probs

The numeric vector of probabilities.

...

Additional arguments to be passed to S.

Value

A vector of length(probs) for the quantiles.

Author(s)

Kaifeng Lu, [email protected]

Examples

fquantile(pweibull, probs = c(0.25, 0.5, 0.75), 
          shape = 1.37, scale = 1/0.818, lower.tail = FALSE)

Group sequential trials using Bonferroni-based graphical approaches

Description

Obtains the test results for group sequential trials using graphical approaches based on weighted Bonferroni tests.

Usage

fseqbon(
  w,
  G,
  alpha = 0.025,
  kMax,
  typeAlphaSpending = NULL,
  parameterAlphaSpending = NULL,
  incidenceMatrix = NULL,
  maxInformation = NULL,
  p,
  information,
  spendingTime = NULL
)

Arguments

w

The vector of initial weights for elementary hypotheses.

G

The initial transition matrix.

alpha

The significance level. Defaults to 0.025.

kMax

The maximum number of stages.

typeAlphaSpending

The vector of alpha spending functions. Each element is one of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF" if not provided.

parameterAlphaSpending

The vector of parameter values for the alpha spending functions. Each element corresponds to the value of Delta for "WT", rho for "sfKD", or gamma for "sfHSD". Defaults to missing if not provided.

incidenceMatrix

The incidence matrix indicating whether the specific hypothesis will be tested at the given look. The number of columns of incidenceMatrix must be equal to the maximum number of study looks (kMax). If not provided, defaults to testing each hypothesis at all study looks.

maxInformation

The vector of target maximum information for each hypothesis. Defaults to a vector of 1s if not provided.

p

The matrix of raw p-values for each hypothesis by study look.

information

The matrix of observed information for each hypothesis by study look.

spendingTime

The spending time for alpha spending by study look. If not provided, it is the same as informationRates calculated from information and maxInformation.

Value

A vector to indicate the first look the specific hypothesis is rejected (0 if the hypothesis is not rejected).

Author(s)

Kaifeng Lu, [email protected]

References

Willi Maurer and Frank Bretz. Multiple testing in group sequential trials using graphical approaches. Statistics in Biopharmaceutical Research. 2013; 5:311-320.

Examples

# Case study from Maurer & Bretz (2013)

fseqbon(
  w = c(0.5, 0.5, 0, 0),
  G = matrix(c(0, 0.5, 0.5, 0,  0.5, 0, 0, 0.5,
               0, 1, 0, 0,  1, 0, 0, 0),
             nrow=4, ncol=4, byrow=TRUE),
  alpha = 0.025,
  kMax = 3,
  typeAlphaSpending = rep("sfOF", 4),
  maxInformation = rep(1, 4),
  p = matrix(c(0.0062, 0.017, 0.009, 0.13,
               0.0002, 0.0035, 0.002, 0.06),
             nrow=4, ncol=2),
  information = matrix(c(rep(1/3, 4), rep(2/3, 4)),
                       nrow=4, ncol=2))

Adjusted p-values for standard mixture gatekeeping procedures

Description

Obtains the adjusted p-values for the standard gatekeeping procedures for multiplicity problems involving serial and parallel logical restrictions.

Usage

fstdmix(
  p,
  family = NULL,
  serial,
  parallel,
  gamma,
  test = "hommel",
  exhaust = 1
)

Arguments

p

The raw p-values for elementary hypotheses.

family

The matrix of family indicators for the hypotheses.

serial

The matrix of serial rejection set for the hypotheses.

parallel

The matrix of parallel rejection set for the hypotheses.

gamma

The truncation parameters for each family. The truncation parameter for the last family is automatically set to 1.

test

The component multiple testing procedure. Options include "holm", "hochberg", or "hommel". Defaults to "hommel".

exhaust

Whether to use alpha-exhausting component testing procedure for the last family with active hypotheses. It defaults to TRUE.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

References

Alex Dmitrienko and Ajit C Tamhane. Mixtures of multiple testing procedures for gatekeeping applications in clinical trials. Statistics in Medicine. 2011; 30(13):1473–1488.

Examples

p = c(0.0194, 0.0068, 0.0271, 0.0088, 0.0370, 0.0018, 0.0814, 0.0066)
family = matrix(c(1, 1, 0, 0, 0, 0, 0, 0,
                  0, 0, 1, 1, 0, 0, 0, 0,
                  0, 0, 0, 0, 1, 1, 0, 0,
                  0, 0, 0, 0, 0, 0, 1, 1),
                nrow=4, byrow=TRUE)

serial = matrix(c(0, 0, 0, 0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0, 0, 0, 0,
                  1, 0, 0, 0, 0, 0, 0, 0,
                  0, 1, 0, 0, 0, 0, 0, 0,
                  0, 0, 1, 0, 0, 0, 0, 0,
                  0, 0, 0, 1, 0, 0, 0, 0,
                  0, 0, 0, 0, 1, 0, 0, 0,
                  0, 0, 0, 0, 0, 1, 0, 0),
                nrow=8, byrow=TRUE)

parallel = matrix(0, 8, 8)
gamma = c(0.6, 0.6, 0.6, 1)
fstdmix(p, family, serial, parallel, gamma, test = "hommel", exhaust = 0)

Adjusted p-values for stepwise testing procedures for two sequences

Description

Obtains the adjusted p-values for the stepwise gatekeeping procedures for multiplicity problems involving two sequences of hypotheses.

Usage

fstp2seq(p, gamma, test = "hochberg", retest = TRUE)

Arguments

p

The raw p-values for elementary hypotheses.

gamma

The truncation parameters for each family. The truncation parameter for the last family is automatically set to 1.

test

The component multiple testing procedure. It is either "Holm" or "Hochberg", and it defaults to "Hochberg".

retest

Whether to allow retesting. It defaults to TRUE.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

Examples

p = c(0.0194, 0.0068, 0.0271, 0.0088, 0.0370, 0.0018, 0.0814, 0.0066)
gamma = c(0.6, 0.6, 0.6, 1)
fstp2seq(p, gamma, test="hochberg", retest=1)

Adjusted p-values for Holm, Hochberg, and Hommel procedures

Description

Obtains the adjusted p-values for possibly truncated Holm, Hochberg, and Hommel procedures.

Usage

ftrunc(p, test = "hommel", gamma = 1)

Arguments

p

The raw p-values for elementary hypotheses.

test

The test to use, e.g., "holm", "hochberg", or "hommel" (default).

gamma

The value of the truncation parameter. Defaults to 1 for the regular Holm, Hochberg, or Hommel procedure.

Value

A matrix of adjusted p-values.

Author(s)

Kaifeng Lu, [email protected]

References

Alex Dmitrienko, Ajit C. Tamhane, and Brian L. Wiens. General multistage gatekeeping procedures. Biometrical Journal. 2008; 5:667-677.

Examples

pvalues <- matrix(c(0.01,0.005,0.015,0.022, 0.02,0.015,0.010,0.023),
                  nrow=2, ncol=4, byrow=TRUE)
ftrunc(pvalues, "hochberg")

Weight matrix for all intersection hypotheses

Description

Obtains the weight matrix for all intersection hypotheses.

Usage

fwgtmat(w, G)

Arguments

w

The vector of weights for elementary hypotheses.

G

The transition matrix.

Value

The weight matrix starting with the global null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

Examples

w = c(0.5,0.5,0,0)
g = matrix(c(0,0,1,0, 0,0,0,1, 0,1,0,0, 1,0,0,0),
           nrow=4, ncol=4, byrow=TRUE)
(wgtmat = fwgtmat(w,g))

Accrual duration to enroll target number of subjects

Description

Obtains the accrual duration to enroll the target number of subjects.

Usage

getAccrualDurationFromN(
  nsubjects = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_
)

Arguments

nsubjects

The vector of target number of subjects.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

Value

A vector of accrual durations.

Author(s)

Kaifeng Lu, [email protected]

Examples

getAccrualDurationFromN(nsubjects = c(20, 150), accrualTime = c(0, 3),
                        accrualIntensity = c(10, 20))

Confidence interval after adaptation

Description

Obtains the p-value, median unbiased point estimate, and confidence interval after the end of an adaptive trial.

Usage

getADCI(
  L = NA_integer_,
  zL = NA_real_,
  IMax = NA_real_,
  kMax = NA_integer_,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.25,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  spendingTime = NA_real_,
  L2 = NA_integer_,
  zL2 = NA_real_,
  INew = NA_real_,
  MullerSchafer = 0L,
  informationRatesNew = NA_real_,
  efficacyStoppingNew = NA_integer_,
  typeAlphaSpendingNew = "sfOF",
  parameterAlphaSpendingNew = NA_real_,
  spendingTimeNew = NA_real_
)

Arguments

L

The interim adaptation look of the primary trial.

zL

The z-test statistic at the interim adaptation look of the primary trial.

IMax

The maximum information of the primary trial.

kMax

The maximum number of stages of the primary trial.

informationRates

The information rates of the primary trial.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage of the primary trial. Defaults to true if left unspecified.

criticalValues

The upper boundaries on the z-test statistic scale for efficacy stopping for the primary trial.

alpha

The significance level of the primary trial. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending for the primary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value of alpha spending for the primary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

spendingTime

The error spending time of the primary trial. Defaults to missing, in which case, it is the same as informationRates.

L2

The termination look of the secondary trial.

zL2

The z-test statistic at the termination look of the secondary trial.

INew

The maximum information of the secondary trial.

MullerSchafer

Whether to use the Muller and Schafer (2001) method for trial adaptation.

informationRatesNew

The spacing of looks of the secondary trial up to look L2.

efficacyStoppingNew

The indicators of whether efficacy stopping is allowed at each look of the secondary trial up to look L2. Defaults to true if left unspecified.

typeAlphaSpendingNew

The type of alpha spending for the secondary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpendingNew

The parameter value of alpha spending for the secondary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

spendingTimeNew

The error spending time of the secondary trial up to look L2. Defaults to missing, in which case, it is the same as informationRatesNew.

Value

A data frame with the following variables:

  • pvalue: p-value for rejecting the null hypothesis.

  • thetahat: Median unbiased point estimate of the parameter.

  • cilevel: Confidence interval level.

  • lower: Lower bound of confidence interval.

  • upper: Upper bound of confidence interval.

Author(s)

Kaifeng Lu, [email protected]

References

Ping Gao, Lingyun Liu and Cyrus Mehta. Exact inference for adaptive group sequential designs. Stat Med. 2013;32(23):3991-4005.

See Also

adaptDesign

Examples

# original group sequential design with 90% power to detect delta = 6
delta = 6
sigma = 17
n = 282
(des1 = getDesign(IMax = n/(4*sigma^2), theta = delta, kMax = 3,
                  alpha = 0.05, typeAlphaSpending = "sfHSD",
                  parameterAlphaSpending = -4))

# interim look results
L = 1
n1 = n/3
delta1 = 4.5
sigma1 = 20
zL = delta1/sqrt(4/n1*sigma1^2)

t = des1$byStageResults$informationRates

# Muller & Schafer (2001) method to design the secondary trial:
des2 = adaptDesign(
  betaNew = 0.2, L = L, zL = zL, theta = 5,
  kMax = 3, informationRates = t,
  alpha = 0.05, typeAlphaSpending = "sfHSD",
  parameterAlphaSpending = -4,
  MullerSchafer = TRUE,
  kNew = 3, typeAlphaSpendingNew = "sfHSD",
  parameterAlphaSpendingNew = -2)

n2 = ceiling(des2$secondaryTrial$overallResults$information*4*20^2)
ns = round(n2*(1:3)/3)
 (des2 = adaptDesign(
   INew = n2/(4*20^2), L = L, zL = zL, theta = 5,
   kMax = 3, informationRates = t,
   alpha = 0.05, typeAlphaSpending = "sfHSD",
   parameterAlphaSpending = -4,
   MullerSchafer = TRUE,
   kNew = 3, informationRatesNew = ns/n2,
   typeAlphaSpendingNew = "sfHSD",
   parameterAlphaSpendingNew = -2))

# termination at the second look of the secondary trial
L2 = 2
delta2 = 6.86
sigma2 = 21.77
zL2 = delta2/sqrt(4/197*sigma2^2)

t2 = des2$secondaryTrial$byStageResults$informationRates[1:L2]

# confidence interval
getADCI(L = L, zL = zL,
        IMax = n/(4*sigma1^2), kMax = 3,
        informationRates = t,
        alpha = 0.05, typeAlphaSpending = "sfHSD",
        parameterAlphaSpending = -4,
        L2 = L2, zL2 = zL2,
        INew = n2/(4*sigma2^2),
        MullerSchafer = TRUE,
        informationRatesNew = t2,
        typeAlphaSpendingNew = "sfHSD",
        parameterAlphaSpendingNew = -2)

Repeated confidence interval after adaptation

Description

Obtains the repeated p-value, conservative point estimate, and repeated confidence interval for an adaptive group sequential trial.

Usage

getADRCI(
  L = NA_integer_,
  zL = NA_real_,
  IMax = NA_real_,
  kMax = NA_integer_,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  spendingTime = NA_real_,
  L2 = NA_integer_,
  zL2 = NA_real_,
  INew = NA_real_,
  MullerSchafer = 0L,
  informationRatesNew = NA_real_,
  efficacyStoppingNew = NA_integer_,
  typeAlphaSpendingNew = "sfOF",
  parameterAlphaSpendingNew = NA_real_,
  spendingTimeNew = NA_real_
)

Arguments

L

The interim adaptation look of the primary trial.

zL

The z-test statistic at the interim adaptation look of the primary trial.

IMax

The maximum information of the primary trial.

kMax

The maximum number of stages of the primary trial.

informationRates

The information rates of the primary trial.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage of the primary trial. Defaults to true if left unspecified.

criticalValues

The upper boundaries on the z-test statistic scale for efficacy stopping for the primary trial.

alpha

The significance level of the primary trial. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending for the primary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value of alpha spending for the primary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

spendingTime

The error spending time of the primary trial. Defaults to missing, in which case, it is the same as informationRates.

L2

The look of interest in the secondary trial.

zL2

The z-test statistic at the look of the secondary trial.

INew

The maximum information of the secondary trial.

MullerSchafer

Whether to use the Muller and Schafer (2001) method for trial adaptation.

informationRatesNew

The spacing of looks of the secondary trial.

efficacyStoppingNew

The indicators of whether efficacy stopping is allowed at each look of the secondary trial up to look L2. Defaults to true if left unspecified.

typeAlphaSpendingNew

The type of alpha spending for the secondary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpendingNew

The parameter value of alpha spending for the secondary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

spendingTimeNew

The error spending time of the secondary trial. up to look L2. Defaults to missing, in which case, it is the same as informationRatesNew.

Value

A data frame with the following variables:

  • pvalue: Repeated p-value for rejecting the null hypothesis.

  • thetahat: Point estimate of the parameter.

  • cilevel: Confidence interval level.

  • lower: Lower bound of repeated confidence interval.

  • upper: Upper bound of repeated confidence interval.

Author(s)

Kaifeng Lu, [email protected]

References

Cyrus R. Mehta, Peter Bauer, Martin Posch and Werner Brannath. Repeated confidence intervals for adaptive group sequential trials. Stat Med. 2007;26:5422–5433.

See Also

adaptDesign

Examples

# original group sequential design with 90% power to detect delta = 6
delta = 6
sigma = 17
n = 282
(des1 = getDesign(IMax = n/(4*sigma^2), theta = delta, kMax = 3,
                  alpha = 0.05, typeAlphaSpending = "sfHSD",
                  parameterAlphaSpending = -4))

# interim look results
L = 1
n1 = n/3
delta1 = 4.5
sigma1 = 20
zL = delta1/sqrt(4/n1*sigma1^2)

t = des1$byStageResults$informationRates

# Muller & Schafer (2001) method to design the secondary trial:
des2 = adaptDesign(
  betaNew = 0.2, L = L, zL = zL, theta = 5,
  kMax = 3, informationRates = t,
  alpha = 0.05, typeAlphaSpending = "sfHSD",
  parameterAlphaSpending = -4,
  MullerSchafer = TRUE,
  kNew = 3, typeAlphaSpendingNew = "sfHSD",
  parameterAlphaSpendingNew = -2)

n2 = ceiling(des2$secondaryTrial$overallResults$information*4*20^2)
ns = round(n2*(1:3)/3)
(des2 = adaptDesign(
  INew = n2/(4*20^2), L = L, zL = zL, theta = 5,
  kMax = 3, informationRates = t,
  alpha = 0.05, typeAlphaSpending = "sfHSD",
  parameterAlphaSpending = -4,
  MullerSchafer = TRUE,
  kNew = 3, informationRatesNew = ns/n2,
  typeAlphaSpendingNew = "sfHSD",
  parameterAlphaSpendingNew = -2))

# termination at the second look of the secondary trial
L2 = 2
delta2 = 6.86
sigma2 = 21.77
zL2 = delta2/sqrt(4/197*sigma2^2)

t2 = des2$secondaryTrial$byStageResults$informationRates[1:L2]

# repeated confidence interval
getADRCI(L = L, zL = zL,
         IMax = n/(4*sigma1^2), kMax = 3,
         informationRates = t,
         alpha = 0.05, typeAlphaSpending = "sfHSD",
         parameterAlphaSpending = -4,
         L2 = L2, zL2 = zL2,
         INew = n2/(4*sigma2^2),
         MullerSchafer = TRUE,
         informationRatesNew = t2,
         typeAlphaSpendingNew = "sfHSD",
         parameterAlphaSpendingNew = -2)

Efficacy boundaries for group sequential design

Description

Obtains the efficacy stopping boundaries for a group sequential design.

Usage

getBound(
  k = NA,
  informationRates = NA,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA,
  userAlphaSpending = NA,
  spendingTime = NA,
  efficacyStopping = NA
)

Arguments

k

Look number for the current analysis.

informationRates

Information rates up to the current look. Must be increasing and less than or equal to 1.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length k for the error spending time at each analysis. Must be increasing and less than or equal to 1. Defaults to missing, in which case, it is the same as informationRates.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

Details

If typeAlphaSpending is "OF", "P", or "WT", then the boundaries will be based on equally spaced looks.

Value

A numeric vector of critical values up to the current look.

Author(s)

Kaifeng Lu, [email protected]

Examples

getBound(k = 2, informationRates = c(0.5,1),
         alpha = 0.025, typeAlphaSpending = "sfOF")

Confidence interval after trial termination

Description

Obtains the p-value, median unbiased point estimate, and confidence interval after the end of a group sequential trial.

Usage

getCI(
  L = NA_integer_,
  zL = NA_real_,
  IMax = NA_real_,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

L

The termination look.

zL

The z-test statistic at the termination look.

IMax

The maximum information of the trial.

informationRates

The information rates up to look L.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage up to look L. Defaults to true if left unspecified.

criticalValues

The upper boundaries on the z-test statistic scale for efficacy stopping up to look L.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value of alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

spendingTime

The error spending time up to look L. Defaults to missing, in which case, it is the same as informationRates.

Value

A data frame with the following components:

  • pvalue: p-value for rejecting the null hypothesis.

  • thetahat: Median unbiased point estimate of the parameter.

  • cilevel: Confidence interval level.

  • lower: Lower bound of confidence interval.

  • upper: Upper bound of confidence interval.

Author(s)

Kaifeng Lu, [email protected]

References

Anastasios A. Tsiatis, Gary L. Rosner and Cyrus R. Mehta. Exact confidence intervals following a group sequential test. Biometrics 1984;40:797-803.

Examples

# group sequential design with 90% power to detect delta = 6
delta = 6
sigma = 17
n = 282
(des1 = getDesign(IMax = n/(4*sigma^2), theta = delta, kMax = 3,
                  alpha = 0.05, typeAlphaSpending = "sfHSD",
                  parameterAlphaSpending = -4))

# crossed the boundary at the second look
L = 2
n1 = n*2/3
delta1 = 7
sigma1 = 20
zL = delta1/sqrt(4/n1*sigma1^2)

# confidence interval
getCI(L = L, zL = zL, IMax = n/(4*sigma1^2),
      informationRates = c(1/3, 2/3), alpha = 0.05,
      typeAlphaSpending = "sfHSD", parameterAlphaSpending = -4)

Conditional power allowing for varying parameter values

Description

Obtains the conditional power for specified incremental information given the interim results, parameter values, and data-dependent changes in the error spending function, as well as the number and spacing of interim looks.

Usage

getCP(
  INew = NA_real_,
  L = NA_integer_,
  zL = NA_real_,
  theta = NA_real_,
  IMax = NA_real_,
  kMax = NA_integer_,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  spendingTime = NA_real_,
  MullerSchafer = 0L,
  kNew = NA_integer_,
  informationRatesNew = NA_real_,
  efficacyStoppingNew = NA_integer_,
  futilityStoppingNew = NA_integer_,
  typeAlphaSpendingNew = "sfOF",
  parameterAlphaSpendingNew = NA_real_,
  typeBetaSpendingNew = "none",
  parameterBetaSpendingNew = NA_real_,
  spendingTimeNew = NA_real_,
  varianceRatio = 1
)

Arguments

INew

The maximum information of the secondary trial.

L

The interim adaptation look of the primary trial.

zL

The z-test statistic at the interim adaptation look of the primary trial.

theta

A scalar or a vector of parameter values of length kMax + kMax - L if MullerSchafer = FALSE or length kMax + kNew if MullerSchafer = TRUE.

IMax

The maximum information of the primary trial.

kMax

The maximum number of stages of the primary trial.

informationRates

The information rates of the primary trial.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage of the primary trial. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage of the primary trial. Defaults to true if left unspecified.

criticalValues

The upper boundaries on the z-test statistic scale for efficacy stopping for the primary trial.

alpha

The significance level of the primary trial. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending for the primary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value of alpha spending for the primary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending for the primary trial. Cumulative alpha spent up to each stage.

futilityBounds

The lower boundaries on the z-test statistic scale for futility stopping for the primary trial. Defaults to rep(-6, kMax-1) if left unspecified.

typeBetaSpending

The type of beta spending for the primary trial. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value of beta spending for the primary trial. Corresponds to rho for "sfKD", and gamma for "sfHSD".

spendingTime

The error spending time of the primary trial. Defaults to missing, in which case, it is the same as informationRates.

MullerSchafer

Whether to use the Muller and Schafer (2001) method for trial adaptation.

kNew

The number of looks of the secondary trial.

informationRatesNew

The spacing of looks of the secondary trial.

efficacyStoppingNew

The indicators of whether efficacy stopping is allowed at each look of the secondary trial. Defaults to true if left unspecified.

futilityStoppingNew

The indicators of whether futility stopping is allowed at each look of the secondary trial. Defaults to true if left unspecified.

typeAlphaSpendingNew

The type of alpha spending for the secondary trial. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpendingNew

The parameter value of alpha spending for the secondary trial. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

typeBetaSpendingNew

The type of beta spending for the secondary trial. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpendingNew

The parameter value of beta spending for the secondary trial. Corresponds to rho for "sfKD", and gamma for "sfHSD".

spendingTimeNew

The error spending time of the secondary trial. Defaults to missing, in which case, it is the same as informationRatesNew.

varianceRatio

The ratio of the variance under H0 to the variance under H1.

Value

The conditional power given the interim results, parameter values, and data-dependent design changes.

Author(s)

Kaifeng Lu, [email protected]

References

Cyrus R. Mehta and Stuart J. Pocock. Adaptive increase in sample size when interim results are promising: A practical guide with examples. Stat Med. 2011;30:3267–3284.

See Also

getDesign

Examples

# Conditional power calculation with delayed treatment effect

# Two interim analyses have occurred with 179 and 266 events,
# respectively. The observed hazard ratio at the second interim
# look is 0.81.

trialsdt = as.Date("2020-03-04")                       # trial start date
iadt = c(as.Date("2022-02-01"), as.Date("2022-11-01")) # interim dates
mo1 = as.numeric(iadt - trialsdt + 1)/30.4375          # interim months

# Assume a piecewise Poisson enrollment process with a 8-month ramp-up
# and 521 patients were enrolled after 17.94 months
N = 521                   # total number of patients
Ta = 17.94                # enrollment duration
Ta1 = 8                   # assumed end of enrollment ramp-up
enrate = N / (Ta - Ta1/2) # enrollment rate after ramp-up

# Assume a median survival of 16.7 months for the control group, a
# 5-month delay in treatment effect, and a hazard ratio of 0.7 after
# the delay
lam1 = log(2)/16.7  # control group hazard of exponential distribution
t1 = 5              # months of delay in treatment effect
hr = 0.7            # hazard ratio after delay
lam2 = hr*lam1      # treatment group hazard after delay

# Assume an annual dropout rate of 5%
gam = -log(1-0.05)/12  # hazard for dropout

# The original target number of events was 298 and the new target is 335
mo2 <- caltime(
  nevents = c(298, 335),
  allocationRatioPlanned = 1,
  accrualTime = seq(0, Ta1),
  accrualIntensity = enrate*seq(1, Ta1+1)/(Ta1+1),
  piecewiseSurvivalTime = c(0, t1),
  lambda1 = c(lam1, lam2),
  lambda2 = c(lam1, lam1),
  gamma1 = gam,
  gamma2 = gam,
  accrualDuration = Ta,
  followupTime = 1000)

# expected number of events and average hazard ratios
(lr1 <- lrstat(
  time = c(mo1, mo2),
  accrualTime = seq(0, Ta1),
  accrualIntensity = enrate*seq(1, Ta1+1)/(Ta1+1),
  piecewiseSurvivalTime = c(0, t1),
  lambda1 = c(lam1, lam2),
  lambda2 = c(lam1, lam1),
  gamma1 = gam,
  gamma2 = gam,
  accrualDuration = Ta,
  followupTime = 1000,
  predictTarget = 3))


hr2 = 0.81                    # observed hazard ratio at interim 2
z2 = (-log(hr2))*sqrt(266/4)  # corresponding z-test statistic value

# expected mean of -log(HR) at the original looks and the new final look
theta = -log(lr1$HR[c(1,2,3,4)])

# conditional power with sample size increase
getCP(INew = (335 - 266)/4,
      L = 2, zL = z2, theta = theta,
      IMax = 298/4, kMax = 3,
      informationRates = c(179, 266, 298)/298,
      alpha = 0.025, typeAlphaSpending = "sfOF")

Power and sample size for a generic group sequential design

Description

Obtains the maximum information and stopping boundaries for a generic group sequential design assuming a constant treatment effect, or obtains the power given the maximum information and stopping boundaries.

Usage

getDesign(
  beta = NA_real_,
  IMax = NA_real_,
  theta = NA_real_,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_,
  varianceRatio = 1
)

Arguments

beta

The type II error.

IMax

The maximum information. Either beta or IMax should be provided while the other one should be missing.

theta

The parameter value.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

varianceRatio

The ratio of the variance under H0 to the variance under H1.

Value

An S3 class design object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyTheta: The efficacy boundaries on the parameter scale.

    • futilityTheta: The futility boundaries on the parameter scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatio: The ratio of the variance under H0 to the variance under H1.

Author(s)

Kaifeng Lu, [email protected]

References

Christopher Jennison, Bruce W. Turnbull. Group Sequential Methods with Applications to Clinical Trials. Chapman & Hall/CRC: Boca Raton, 2000, ISBN:0849303168

Examples

# Example 1: obtain the maximum information given power
(design1 <- getDesign(
  beta = 0.2, theta = -log(0.7),
  kMax = 2, informationRates = c(0.5,1),
  alpha = 0.025, typeAlphaSpending = "sfOF",
  typeBetaSpending = "sfP"))

# Example 2: obtain power given the maximum information
(design2 <- getDesign(
  IMax = 72.5, theta = -log(0.7),
  kMax = 3, informationRates = c(0.5, 0.75, 1),
  alpha = 0.025, typeAlphaSpending = "sfOF",
  typeBetaSpending = "sfP"))

Power and sample size for Cohen's kappa

Description

Obtains the power given sample size or obtains the sample size given power for Cohen's kappa.

Usage

getDesignAgreement(
  beta = NA_real_,
  n = NA_real_,
  ncats = NA_integer_,
  kappaH0 = NA_real_,
  kappa = NA_real_,
  p1 = NA_real_,
  p2 = NA_real_,
  rounding = TRUE,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

ncats

The number of categories.

kappaH0

The kappa coefficient under the null hypothesis.

kappa

The kappa coefficient under the alternative hypothesis.

p1

The marginal probabilities for the first rater.

p2

The marginal probabilities for the second rater. Defaults to be equal to the marginal probabilities for the first rater if not provided.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The one-sided significance level. Defaults to 0.025.

Details

The kappa coefficient is defined as

κ=πoπe1πe,\kappa = \frac{\pi_o - \pi_e}{1 - \pi_e},

where πo=iπii\pi_o = \sum_i \pi_{ii} is the observed agreement, and πe=iπi.π.i\pi_e = \sum_i \pi_{i.} \pi_{.i} is the expected agreement by chance.

By Fleiss et al. (1969), the variance of κ^\hat{\kappa} is given by

Var(κ^)=v1n,Var(\hat{\kappa}) = \frac{v_1}{n},

where

v1=Q1+Q2Q3Q4(1πe)4,v_1 = \frac{Q_1 + Q_2 - Q3 - Q4}{(1-\pi_e)^4},

Q1=πo(1πe)2,Q_1 = \pi_o(1-\pi_e)^2,

Q2=(1πo)2ijπij(πi.+π.j)2,Q_2 = (1-\pi_o)^2 \sum_i \sum_j \pi_{ij}(\pi_{i.} + \pi_{.j})^2,

Q3=2(1πo)(1πe)iπii(πi.+π.i),Q_3 = 2(1-\pi_o)(1-\pi_e) \sum_i \pi_{ii}(\pi_{i.} + \pi_{.i}),

Q4=(πoπe2πe+πo)2.Q_4 = (\pi_o \pi_e - 2\pi_e + \pi_o)^2.

Given κ\kappa and marginals {(πi.,π.i):i=1,,k}\{(\pi_{i.}, \pi_{.i}): i=1,\ldots,k\}, we obtain πo\pi_o. The only unknowns are the double summation in Q2Q_2 and the single summation in Q3Q_3.

We find the optimal configuration of cell probabilities that yield the maximum variance of κ^\hat{\kappa} by treating the problem as a linear programming problem with constraints to match the given marginal probabilities and the observed agreement and ensure that the cell probabilities are nonnegative. This is an extension of Flack et al. (1988) by allowing unequal marginal probabilities of the two raters.

We perform the optimization under both the null and alternative hypotheses to obtain maxVar(κ^κ=κ0)\max Var(\hat{\kappa} | \kappa = \kappa_0) and maxVar(κ^κ=κ1)\max Var(\hat{\kappa} | \kappa = \kappa_1) for a single subject, and then calculate the sample size or power according to the following equation:

nκκ0=z1αmaxVar(κ^κ=κ0)+z1βmaxVar(κ^κ=κ1).\sqrt{n} |\kappa - \kappa_0| = z_{1-\alpha} \sqrt{\max Var(\hat{\kappa} | \kappa = \kappa_0)} + z_{1-\beta} \sqrt{\max Var(\hat{\kappa} | \kappa = \kappa_1)}.

Value

An S3 class designAgreement object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The one-sided significance level.

  • n: The total sample size.

  • ncats: The number of categories.

  • kappaH0: The kappa coefficient under the null hypothesis.

  • kappa: The kappa coefficient under the alternative hypothesis.

  • p1: The marginal probabilities for the first rater.

  • p2: The marginal probabilities for the second rater.

  • piH0: The cell probabilities that maximize the variance of estimated kappa under H0.

  • pi: The cell probabilities that maximize the variance of estimated kappa under H1.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

References

V. F. Flack, A. A. Afifi, and P. A. Lachenbruch. Sample size determinations for the two rater kappa statistic. Psychometrika 1988; 53:321-325.

Examples

(design1 <- getDesignAgreement(
  beta = 0.2, n = NA, ncats = 4, kappaH0 = 0.4, kappa = 0.6,
  p1 = c(0.1, 0.2, 0.3, 0.4), p2 = c(0.15, 0.2, 0.24, 0.41),
  rounding = TRUE, alpha = 0.05))

Power and sample size for one-way ANOVA

Description

Obtains the power and sample size for one-way analysis of variance.

Usage

getDesignANOVA(
  beta = NA_real_,
  n = NA_real_,
  ngroups = 2,
  means = NA_real_,
  stDev = 1,
  allocationRatioPlanned = NA_real_,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

means

The treatment group means.

stDev

The common standard deviation.

allocationRatioPlanned

Allocation ratio for the treatment groups. It has length ngroups - 1 or ngroups. If it is of length ngroups - 1, then the last treatment group will assume value 1 for allocation ratio.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Details

Let {μi:i=1,,k}\{\mu_i: i=1,\ldots,k\} denote the group means, and {ri:i=1,,k}\{r_i: i=1,\ldots,k\} denote the randomization probabilities to the kk treatment groups. Let σ\sigma denote the common standard deviation, and nn denote the total sample size. Then the FF-statistic

F=SSR/(k1)SSE/(nk)Fk1,nk,λ,F = \frac{SSR/(k-1)}{SSE/(n-k)} \sim F_{k-1, n-k, \lambda},

where

λ=ni=1kri(μiμˉ)2/σ2\lambda = n \sum_{i=1}^k r_i (\mu_i - \bar{\mu})^2/\sigma^2

is the noncentrality parameter, and μˉ=i=1kriμi\bar{\mu} = \sum_{i=1}^k r_i \mu_i.

Value

An S3 class designANOVA object with the following components:

  • power: The power to reject the null hypothesis that there is no difference among the treatment groups.

  • alpha: The two-sided significance level.

  • n: The number of subjects.

  • ngroups: The number of treatment groups.

  • means: The treatment group means.

  • stDev: The common standard deviation.

  • effectsize: The effect size.

  • allocationRatioPlanned: Allocation ratio for the treatment groups.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignANOVA(
  beta = 0.1, ngroups = 4, means = c(1.5, 2.5, 2, 0),
  stDev = 3.5, allocationRatioPlanned = c(2, 2, 2, 1),
  alpha = 0.05))

Power and sample size for one-way ANOVA contrast

Description

Obtains the power and sample size for a single contrast in one-way analysis of variance.

Usage

getDesignANOVAContrast(
  beta = NA_real_,
  n = NA_real_,
  ngroups = 2,
  means = NA_real_,
  stDev = 1,
  contrast = NA_real_,
  meanContrastH0 = 0,
  allocationRatioPlanned = NA_real_,
  rounding = TRUE,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

means

The treatment group means.

stDev

The common standard deviation.

contrast

The coefficients for the single contrast.

meanContrastH0

The mean of the contrast under the null hypothesis.

allocationRatioPlanned

Allocation ratio for the treatment groups. It has length ngroups - 1 or ngroups. If it is of length ngroups - 1, then the last treatment group will assume value 1 for allocation ratio.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The one-sided significance level. Defaults to 0.025.

Value

An S3 class designANOVAContrast object with the following components:

  • power: The power to reject the null hypothesis for the treatment contrast.

  • alpha: The one-sided significance level.

  • n: The number of subjects.

  • ngroups: The number of treatment groups.

  • means: The treatment group means.

  • stDev: The common standard deviation.

  • contrast: The coefficients for the single contrast.

  • meanContrastH0: The mean of the contrast under the null hypothesis.

  • meanContrast: The mean of the contrast under the alternative hypothesis.

  • effectsize: The effect size.

  • allocationRatioPlanned: Allocation ratio for the treatment groups.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignANOVAContrast(
  beta = 0.1, ngroups = 4, means = c(1.5, 2.5, 2, 0),
  stDev = 3.5, contrast = c(1, 1, 1, -3)/3,
  allocationRatioPlanned = c(2, 2, 2, 1),
  alpha = 0.025))

Power and sample size for a generic group sequential equivalence design

Description

Obtains the maximum information and stopping boundaries for a generic group sequential equivalence design assuming a constant treatment effect, or obtains the power given the maximum information and stopping boundaries.

Usage

getDesignEquiv(
  beta = NA_real_,
  IMax = NA_real_,
  thetaLower = NA_real_,
  thetaUpper = NA_real_,
  theta = 0,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_,
  varianceRatioH10 = 1,
  varianceRatioH20 = 1,
  varianceRatioH12 = 1,
  varianceRatioH21 = 1
)

Arguments

beta

The type II error.

IMax

The maximum information. Either beta or IMax should be provided while the other one should be missing.

thetaLower

The parameter value at the lower equivalence limit.

thetaUpper

The parameter value at the upper equivalence limit.

theta

The parameter value under the alternative hypothesis.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests, e.g., 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

varianceRatioH10

The ratio of the variance under H10 to the variance under H1.

varianceRatioH20

The ratio of the variance under H20 to the variance under H1.

varianceRatioH12

The ratio of the variance under H10 to the variance under H20.

varianceRatioH21

The ratio of the variance under H20 to the variance under H10.

Details

Consider the equivalence design with two one-sided hypotheses:

H10:θθ10,H_{10}: \theta \leq \theta_{10},

H20:θθ20.H_{20}: \theta \geq \theta_{20}.

We reject H10H_{10} at or before look kk if

Z1j=(θ^jθ10)njv10bjZ_{1j} = (\hat{\theta}_j - \theta_{10})\sqrt{\frac{n_j}{v_{10}}} \geq b_j

for some j=1,,kj=1,\ldots,k, where {bj:j=1,,K}\{b_j:j=1,\ldots,K\} are the critical values associated with the specified alpha-spending function, and v10v_{10} is the null variance of θ^\hat{\theta} based on the restricted maximum likelihood (reml) estimate of model parameters subject to the constraint imposed by H10H_{10} for one sampling unit drawn from H1H_1. For example, for estimating the risk difference θ=π1π2\theta = \pi_1 - \pi_2, the asymptotic limits of the reml estimates of π1\pi_1 and π2\pi_2 subject to the constraint imposed by H10H_{10} are given by

(π~1,π~2)=f(θ10,r,rπ1,1r,(1r)π2),(\tilde{\pi}_1, \tilde{\pi}_2) = f(\theta_{10}, r, r\pi_1, 1-r, (1-r)\pi_2),

where f(θ0,n1,y1,n2,y2)f(\theta_0, n_1, y_1, n_2, y_2) is the function to obtain the reml of π1\pi_1 and π2\pi_2 subject to the constraint that π1π2=θ0\pi_1-\pi_2 = \theta_0 with observed data (n1,y1,n2,y2)(n_1, y_1, n_2, y_2) for the number of subjects and number of responses in the active treatment and control groups, rr is the randomization probability for the active treatment group, and

v10=π~1(1π~1)r+π~2(1π~2)1r.v_{10} = \frac{\tilde{\pi}_1 (1-\tilde{\pi}_1)}{r} + \frac{\tilde{\pi}_2 (1-\tilde{\pi}_2)}{1-r}.

Let Ij=nj/v1I_j = n_j/v_1 denote the information for θ\theta at the jjth look, where

v1=π1(1π1)r+π2(1π2)1rv_{1} = \frac{\pi_1 (1-\pi_1)}{r} + \frac{\pi_2 (1-\pi_2)}{1-r}

denotes the variance of θ^\hat{\theta} under H1H_1 for one sampling unit. It follows that

(Z1jbj)=(Zjw10bj+(θ10θ)Ij),(Z_{1j} \geq b_j) = (Z_j \geq w_{10} b_j + (\theta_{10}-\theta)\sqrt{I_j}),

where Zj=(θ^jθ)IjZ_j = (\hat{\theta}_j - \theta)\sqrt{I_j}, and w10=v10/v1w_{10} = \sqrt{v_{10}/v_1}.

Similarly, we reject H20H_{20} at or before look kk if

Z2j=(θ^jθ20)njv20bjZ_{2j} = (\hat{\theta}_j - \theta_{20})\sqrt{\frac{n_j}{v_{20}}} \leq -b_j

for some j=1,,kj=1,\ldots,k, where v20v_{20} is the null variance of θ^\hat{\theta} based on the reml estimate of model parameters subject to the constraint imposed by H20H_{20} for one sampling unit drawn from H1H_1. We have

(Z2jbj)=(Zjw20bj+(θ20θ)Ij),(Z_{2j} \leq -b_j) = (Z_j \leq -w_{20} b_j + (\theta_{20}-\theta)\sqrt{I_j}),

where w20=v20/v1w_{20} = \sqrt{v_{20}/v_1}.

Let lj=w10bj+(θ10θ)Ijl_j = w_{10}b_j + (\theta_{10}-\theta)\sqrt{I_j}, and uj=w20bj+(θ20θ)Iju_j = -w_{20}b_j + (\theta_{20}-\theta)\sqrt{I_j}. The cumulative probability to reject H0=H10H20H_0 = H_{10} \cup H_{20} at or before look kk under the alternative hypothesis H1H_1 is given by

Pθ(j=1k(Z1jbj)j=1k(Z2jbj))=p1+p2+p12,P_\theta\left(\cup_{j=1}^{k} (Z_{1j} \geq b_j) \cap \cup_{j=1}^{k} (Z_{2j} \leq -b_j)\right) = p_1 + p_2 + p_{12},

where

p1=Pθ(j=1k(Z1jbj))=Pθ(j=1k(Zjlj)),p_1 = P_\theta\left(\cup_{j=1}^{k} (Z_{1j} \geq b_j)\right) = P_\theta\left(\cup_{j=1}^{k} (Z_j \geq l_j)\right),

p2=Pθ(j=1k(Z2jbj))=Pθ(j=1k(Zjuj)),p_2 = P_\theta\left(\cup_{j=1}^{k} (Z_{2j} \leq -b_j)\right) = P_\theta\left(\cup_{j=1}^{k} (Z_j \leq u_j)\right),

and

p12=Pθ(j=1k{(Zjlj)(Zjuj)}).p_{12} = P_\theta\left(\cup_{j=1}^{k} \{(Z_j \geq l_j) \cup (Z_j \leq u_j)\}\right).

Of note, both p1p_1 and p2p_2 can be evaluated using one-sided exit probabilities for group sequential designs. If there exists jkj\leq k such that ljujl_j \leq u_j, then p12=1p_{12} = 1. Otherwise, p12p_{12} can be evaluated using two-sided exit probabilities for group sequential designs.

To evaluate the type I error of the equivalence trial under H10H_{10}, we first match the information under H10H_{10} with the information under H1H_1. For example, for estimating the risk difference for two independent samples, the sample size n10n_{10} under H10H_{10} must satisfy

1n10((π2+θ10)(1π2θ10)r+π2(1π2)1r)=1n(π1(1π1)r+π2(1π2)1r).\frac{1}{n_{10}}\left(\frac{(\pi_2 + \theta_{10}) (1 - \pi_2 - \theta_{10})}{r} + \frac{\pi_2 (1-\pi_2)}{1-r}\right) = \frac{1}{n}\left(\frac{\pi_1(1-\pi_1)}{r} + \frac{\pi_2 (1-\pi_2)}{1-r}\right).

Then we obtain the reml estimates of π1\pi_1 and π2\pi_2 subject to the constraint imposed by H20H_{20} for one sampling unit drawn from H10H_{10},

(π~10,π~20)=f(θ20,r,r(π2+θ10),1r,(1r)π2).(\tilde{\pi}_{10}, \tilde{\pi}_{20}) = f(\theta_{20}, r, r(\pi_2 + \theta_{10}), 1-r, (1-r)\pi_2).

Let tjt_j denote the information fraction at look jj. Define

v~1=(π2+θ10)(1π2θ10)r+π2(1π2)1r,\tilde{v}_1 = \frac{(\pi_2 + \theta_{10}) (1-\pi_2 -\theta_{10})}{r} + \frac{\pi_2 (1-\pi_2)}{1-r},

and

v~20=π~10(1π~10)r+π~20(1π~20)1r.\tilde{v}_{20} = \frac{\tilde{\pi}_{10}(1-\tilde{\pi}_{10})}{r} + \frac{\tilde{\pi}_{20} (1-\tilde{\pi}_{20})}{1-r}.

The cumulative rejection probability under H10H_{10} at or before look kk is given by

Pθ10(j=1k{(θ^jθ10)n10tj/v~1bj}j=1k{(θ^jθ20)n10tj/v~20bj})=q1+q2+q12,P_{\theta_{10}}\left(\cup_{j=1}^{k} \{(\hat{\theta}_j - \theta_{10}) \sqrt{n_{10} t_j/\tilde{v}_1} \geq b_j\} \cap \cup_{j=1}^{k} \{(\hat{\theta}_j - \theta_{20}) \sqrt{n_{10} t_j/\tilde{v}_{20}} \leq -b_j\}\right) = q_1 + q_2 + q_{12},

where

q1=Pθ10(j=1k{(θ^jθ10)n10tj/v~1bj})=Pθ10(j=1k(Zjbj)),q_1 = P_{\theta_{10}}\left(\cup_{j=1}^{k} \{(\hat{\theta}_j - \theta_{10}) \sqrt{n_{10} t_j/\tilde{v}_1} \geq b_j\}\right) = P_{\theta_{10}}\left(\cup_{j=1}^{k} (Z_j \geq b_j)\right),

q2=Pθ10(j=1k{(θ^jθ20)n10tj/v~20bj})=Pθ10(j=1k(Zjbjw21+(θ20θ10)Ij)),q_2 = P_{\theta_{10}}\left(\cup_{j=1}^{k} \{(\hat{\theta}_j - \theta_{20}) \sqrt{n_{10} t_j/\tilde{v}_{20}} \leq -b_j\}\right) = P_{\theta_{10}}\left(\cup_{j=1}^{k} (Z_j \leq -b_j w_{21} + (\theta_{20} - \theta_{10})\sqrt{I_j})\right),

and

q12=Pθ10(j=1k{(Zjbj)(Zjw21bj+(θ20θ10)Ij)}).q_{12} = P_{\theta_{10}}\left(\cup_{j=1}^{k} \{(Z_j \geq b_j) \cup (Z_j \leq -w_{21} b_j + (\theta_{20} - \theta_{10})\sqrt{I_j})\}\right).

Here Zj=(θ^jθ10)IjZ_j = (\hat{\theta}_j - \theta_{10}) \sqrt{I_j}, and w21=v~20/v~1w_{21} = \sqrt{\tilde{v}_{20}/\tilde{v}_1}. Of note, q1q_1, q2q_2, and q12q_{12} can be evaluated using group sequential exit probabilities. Similarly, we can define v~2\tilde{v}_2, v~10\tilde{v}_{10}, and w12=v~10/v~2w_{12} = \sqrt{\tilde{v}_{10}/\tilde{v}_2}, and evaluate the type I error under H20H_{20}.

The variance ratios correspond to

varianceRatioH10=v10/v1,\text{varianceRatioH10} = v_{10}/v_1,

varianceRatioH20=v20/v1,\text{varianceRatioH20} = v_{20}/v_1,

varianceRatioH12=v~10/v~2,\text{varianceRatioH12} = \tilde{v}_{10}/\tilde{v}_2,

varianceRatioH21=v~20/v~1.\text{varianceRatioH21} = \tilde{v}_{20}/\tilde{v}_1.

If the alternative variance is used, then the variance ratios are all equal to 1.

Value

An S3 class designEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • kMax: The number of stages.

    • thetaLower: The parameter value at the lower equivalence limit.

    • thetaUpper: The parameter value at the upper equivalence limit.

    • theta: The parameter value under the alternative hypothesis.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH10: The expected information under H10.

    • expectedInformationH20: The expected information under H20.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative probability for efficacy stopping under H10.

    • cumulativeAttainedAlphaH20: The cumulative probability for efficacy stopping under H20.

    • efficacyThetaLower: The efficacy boundaries on the parameter scale for the one-sided null hypothesis at the lower equivalence limit.

    • efficacyThetaUpper: The efficacy boundaries on the parameter scale for the one-sided null hypothesis at the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

  • settings: A list containing the following components:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatioH10: The ratio of the variance under H10 to the variance under H1.

    • varianceRatioH20: The ratio of the variance under H20 to the variance under H1.

    • varianceRatioH12: The ratio of the variance under H10 to the variance under H20.

    • varianceRatioH21: The ratio of the variance under H20 to the variance under H10.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: obtain the maximum information given power
(design1 <- getDesignEquiv(
  beta = 0.2, thetaLower = log(0.8), thetaUpper = log(1.25),
  kMax = 2, informationRates = c(0.5, 1),
  alpha = 0.05, typeAlphaSpending = "sfOF"))


# Example 2: obtain power given the maximum information
(design2 <- getDesignEquiv(
  IMax = 72.5, thetaLower = log(0.7), thetaUpper = -log(0.7),
  kMax = 3, informationRates = c(0.5, 0.75, 1),
  alpha = 0.05, typeAlphaSpending = "sfOF"))

Power and sample size for Fisher's exact test for two proportions

Description

Obtains the power given sample size or obtains the sample size given power for Fisher's exact test for two proportions.

Usage

getDesignFisherExact(
  beta = NA_real_,
  n = NA_real_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

alpha

The two-sided significance level. Defaults to 0.05.

Value

A data frame with the following variables:

  • alpha: The two-sided significance level.

  • power: The power.

  • n: The sample size.

  • pi1: The assumed probability for the active treatment group.

  • pi2: The assumed probability for the control group.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignFisherExact(
  beta = 0.2, pi1 = 0.5, pi2 = 0.2, alpha = 0.05))

Power and sample size for logistic regression

Description

Obtains the power given sample size or obtains the sample size given power for logistic regression of a binary response given the covariate of interest and other covariates.

Usage

getDesignLogistic(
  beta = NA_real_,
  n = NA_real_,
  ncovariates = NA_integer_,
  nconfigs = NA_integer_,
  x = NA_real_,
  pconfigs = NA_real_,
  corr = 0,
  oddsratios = NA_real_,
  responseprob = NA_real_,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ncovariates

The number of covariates.

nconfigs

The number of configurations of discretized covariate values.

x

The matrix of covariate values.

pconfigs

The vector of probabilities for the configurations.

corr

The multiple correlation between the predictor and other covariates. Defaults to 0.

oddsratios

The odds ratios for one unit increase in the covariates.

responseprob

The response probability in the full model when all predictor variables are equal to their means.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Details

We consider the logistic regression of a binary response variable YY on a set of predictor variables x=(x1,,xK)Tx = (x_1,\ldots,x_K)^T with x1x_1 being the covariate of interest: logP(Yi=1)1P(Yi=1)=ψ0+xiTψ,\log \frac{P(Y_i=1)}{1 - P(Y_i = 1)} = \psi_0 + x_i^T \psi, where ψ=(ψ1,,ψK)T\psi = (\psi_1,\ldots,\psi_K)^T. Similar to Self et al (1992), we assume that all covariates are either inherently discrete or discretized from continuous distributions (e.g. using the quantiles). Let mm denote the total number of configurations of the covariate values. Let

πi=P(x=xi),i=1,,m\pi_i = P(x = x_i), i = 1,\ldots, m

denote the probabilities for the configurations of the covariates under independence. The likelihood ratio test statistic for testing H0:ψ1=0H_0: \psi_1 = 0 can be approximated by a noncentral chi-square distribution with one degree of freedom and noncentrality parameter

Δ=2i=1mπi[b(θi)(θiθi){b(θi)b(θi)}],\Delta = 2 \sum_{i=1}^m \pi_i [b'(\theta_i)(\theta_i - \theta_i^*) - \{b(\theta_i) - b(\theta_i^*)\}],

where

θi=ψ0+j=1kψjxij,\theta_i = \psi_0 + \sum_{j=1}^{k} \psi_j x_{ij},

θi=ψ0+j=2kψjxij,\theta_i^* = \psi_0^* + \sum_{j=2}^{k} \psi_j^* x_{ij},

for ψ0=ψ0+ψ1μ1\psi_0^* = \psi_0 + \psi_1 \mu_1, and ψj=ψj\psi_j^* = \psi_j for j=2,,Kj=2,\ldots,K. Here μ1\mu_1 is the mean of x1x_1, e.g., μ1=iπixi1.\mu_1 = \sum_i \pi_i x_{i1}. In addition, by formulating the logistic regression in the framework of generalized linear models,

b(θ)=log(1+exp(θ)),b(\theta) = \log(1 + \exp(\theta)),

and

b(θ)=exp(θ)1+exp(θ).b'(\theta) = \frac{\exp(\theta)}{1 + \exp(\theta)}.

The regression coefficients ψ\psi can be obtained by taking the log of the odds ratios for the covariates. The intercept ψ0\psi_0 can be derived as

ψ0=log(μˉ/(1μˉ))j=1Kψjμj,\psi_0 = \log(\bar{\mu}/(1- \bar{\mu})) - \sum_{j=1}^{K} \psi_j \mu_j,

where μˉ\bar{\mu} denotes the response probability when all predictor variables are equal to their means.

Finally, let ρ\rho denote the multiple correlation between the predictor and other covariates. The noncentrality parameter of the chi-square test is adjusted downward by multiplying by 1ρ21-\rho^2.

Value

An S3 class designLogistic object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The total sample size.

  • ncovariates: The number of covariates.

  • nconfigs: The number of configurations of discretized covariate values.

  • x: The matrix of covariate values.

  • pconfigs: The vector of probabilities for the configurations.

  • corr: The multiple correlation between the predictor and other covariates.

  • oddsratios: The odds ratios for one unit increase in the covariates.

  • responseprob: The response probability in the full model when all predictor variables are equal to their means.

  • effectsize: The effect size for the chi-square test.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

References

Steven G. Self, Robert H. Mauritsen and Jill Ohara. Power calculations for likelihood ratio tests in generalized linear models. Biometrics 1992; 48:31-39.

Examples

# two ordinal covariates
x1 = c(5, 10, 15, 20)
px1 = c(0.2, 0.3, 0.3, 0.2)

x2 = c(2, 4, 6)
px2 = c(0.4, 0.4, 0.2)

# discretizing a normal distribution with mean 4 and standard deviation 2
nbins = 10
x3 = qnorm(((1:nbins) - 0.5)/nbins)*2 + 4
px3 = rep(1/nbins, nbins)

# combination of covariate values
nconfigs = length(x1)*length(x2)*length(x3)
x = expand.grid(x3 = x3, x2 = x2, x1 = x1)
x = as.matrix(x[, ncol(x):1])

# probabilities for the covariate configurations under independence
pconfigs = as.numeric(px1 %x% px2 %x% px3)

# convert the odds ratio for the predictor variable in 5-unit change
# to the odds ratio in 1-unit change
(design1 <- getDesignLogistic(
  beta = 0.1, ncovariates = 3,
  nconfigs = nconfigs,
  x = x,
  pconfigs = pconfigs,
  oddsratios = c(1.2^(1/5), 1.4, 1.3),
  responseprob = 0.25,
  alpha = 0.1))

Group sequential design for two-sample mean difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample mean difference.

Usage

getDesignMeanDiff(
  beta = NA_real_,
  n = NA_real_,
  meanDiffH0 = 0,
  meanDiff = 0.5,
  stDev = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanDiffH0

The mean difference under the null hypothesis. Defaults to 0.

meanDiff

The mean difference under the alternative hypothesis.

stDev

The standard deviation.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanDiff object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanDiffH0: The mean difference under the null hypothesis.

    • meanDiff: The mean difference under the alternative hypothesis.

    • stDev: The standard deviation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyMeanDiff: The efficacy boundaries on the mean difference scale.

    • futilityMeanDiff: The futility boundaries on the mean difference scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignMeanDiff(
  beta = NA, n = 456, meanDiff = 9, stDev = 32,
  kMax = 5, alpha = 0.025, typeAlphaSpending = "sfOF",
  typeBetaSpending = "sfP"))

# Example 2: sample size calculation for two-sample t-test
(design2 <- getDesignMeanDiff(
  beta = 0.1, n = NA, meanDiff = 0.3, stDev = 1,
  normalApproximation = FALSE, alpha = 0.025))

Power and sample size for direct treatment effects in crossover trials accounting for carryover effects

Description

Obtains the power and sample size for direct treatment effects in crossover trials accounting for carryover effects.

Usage

getDesignMeanDiffCarryover(
  beta = NA_real_,
  n = NA_real_,
  meanDiffH0 = 0,
  meanDiff = 0.5,
  stDev = 1,
  corr = 0.5,
  design = NA_real_,
  cumdrop = NA_real_,
  allocationRatioPlanned = NA_real_,
  normalApproximation = FALSE,
  rounding = TRUE,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

meanDiffH0

The mean difference at the last time point under the null hypothesis. Defaults to 0.

meanDiff

The mean difference at the last time point under the alternative hypothesis.

stDev

The standard deviation for within-subject random error.

corr

The intra-subject correlation due to subject random effect.

design

The crossover design represented by a matrix with rows indexing the sequences, columns indexing the periods, and matrix entries indicating the treatments.

cumdrop

The cumulative dropout rate over periods.

allocationRatioPlanned

Allocation ratio for the sequences. Defaults to equal randomization if not provided.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The one-sided significance level. Defaults to 0.025.

Details

The linear mixed-effects model to assess the direct treatment effect in the presence of carryover treatment effect is given by

yijk=μ+αi+bij+γk+τd(i,k)+λc(i,k1)+eijk,y_{ijk} = \mu + \alpha_i + b_{ij} + \gamma_k + \tau_{d(i,k)} + \lambda_{c(i,k-1)} + e_{ijk},

i=1,,n;j=1,,ri;k=1,,p;d,c=1,,t,i=1,\ldots,n; j=1,\ldots,r_i; k = 1,\ldots,p; d,c = 1,\ldots,t,

where μ\mu is the general mean, αi\alpha_i is the effect of the iith treatment sequence, bijb_{ij} is the random effect with variance σb2\sigma_b^2 for the jjthe subject of the iith treatment sequence, γk\gamma_k is the period effect, and eijke_{ijk} is the random error with variance σ2\sigma^2 for the subject in period kk. The direct effect of the treatment administered in period kk of sequence ii is τd(i,k)\tau_{d(i,k)}, and λc(i,k1)\lambda_{c(i,k-1)} is the carryover effect of the treatment administered in period k1k-1 of sequence ii. The value of the carryover effect for the observed response in the first period is λc(i,0)=0\lambda_{c(i,0)} = 0 since there is no carryover effect in the first period. The intra-subject correlation due to the subject random effect is

ρ=σb2σb2+sigma2.\rho = \frac{\sigma_b^2}{\sigma_b^2 + sigma^2}.

By constructing the design matrix XX for the linear model with a compound symmetry covariance matrix for the response vector of a subject, we can obtain

Var(β^)=(XV1X)1.Var(\hat{\beta}) = (X'V^{-1}X)^{-1}.

The covariance matrix for the direct treatment effects and the carryover treatment effects can be extracted from the appropriate sub-matrices. The covariance matrix for the direct treatment effects without accounting for the carryover treatment effects can be obtained by omitting the carryover effect terms from the model.

The power and relative efficiency are for the direct treatment effect comparing the first treatment to the last treatment accounting for carryover effects.

The degrees of freedom for the t-test can be calculated as the total number of observations minus the number of subjects minus p1p-1 minus 2(t1)2(t-1) to account for the subject effect, period effect, and direct and carryover treatment effects.

Value

An S3 class designMeanDiffCarryover object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The one-sided significance level.

  • numberOfSubjects: The maximum number of subjects.

  • meanDiffH0: The mean difference under the null hypothesis.

  • meanDiff: The mean difference under the alternative hypothesis.

  • stDev: The standard deviation for within-subject random error.

  • corr: The intra-subject correlation due to subject random effect.

  • design: The crossover design represented by a matrix with rows indexing the sequences, columns indexing the periods, and matrix entries indicating the treatments.

  • nseq: The number of sequences.

  • nprd: The number of periods.

  • ntrt: The number of treatments.

  • cumdrop: The cumulative dropout rate over periods.

  • V_direct_only: The covariance matrix for direct treatment effects without accounting for carryover effects.

  • V_direct_carry: The covariance matrix for direct and carryover treatment effects.

  • v_direct_only: The variance of direct treatment effects without accounting for carryover effects.

  • v_direct: The variance of direct treatment effects accounting for carryover effects.

  • v_carry: The variance of carryover treatment effects.

  • releff_direct: The relative efficiency of the design for estimating direct treatment effects after accounting for carryover effects with respect to that without accounting for carryover effects. This is equal to v_direct_only/v_direct.

  • releff_carry: The relative efficiency of the design for estimating carryover effects. This is equal to v_direct_only/v_carry.

  • allocationRatioPlanned: Allocation ratio for the sequences.

  • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

References

Robert O. Kuehl. Design of Experiments: Statistical Principles of Research Design and Analysis. Brooks/Cole: Pacific Grove, CA. 2000.

Examples

# Williams design for 4 treatments

(design1 = getDesignMeanDiffCarryover(
  beta = 0.2, n = NA,
  meanDiff = 0.5, stDev = 1,
  design = matrix(c(1, 4, 2, 3,
                    2, 1, 3, 4,
                    3, 2, 4, 1,
                    4, 3, 1, 2),
                  4, 4, byrow = TRUE),
  alpha = 0.025))

Group sequential design for equivalence in two-sample mean difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in two-sample mean difference.

Usage

getDesignMeanDiffEquiv(
  beta = NA_real_,
  n = NA_real_,
  meanDiffLower = NA_real_,
  meanDiffUpper = NA_real_,
  meanDiff = 0,
  stDev = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanDiffLower

The lower equivalence limit of mean difference.

meanDiffUpper

The upper equivalence limit of mean difference.

meanDiff

The mean difference under the alternative hypothesis.

stDev

The standard deviation.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanDiffEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlpha: The attained significance level.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanDiffLower: The lower equivalence limit of mean difference.

    • meanDiffUpper: The upper equivalence limit of mean difference.

    • meanDiff: The mean difference under the alternative hypothesis.

    • stDev: The standard deviation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlpha: The cumulative probability for efficacy stopping under H0.

    • efficacyMeanDiffLower: The efficacy boundaries on the mean difference scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyMeanDiffUpper: The efficacy boundaries on the mean difference scale for the one-sided null hypothesis on the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignMeanDiffEquiv(
  beta = 0.1, n = NA, meanDiffLower = -1.3, meanDiffUpper = 1.3,
  meanDiff = 0, stDev = 2.2,
  kMax = 4, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for t-test
(design2 <- getDesignMeanDiffEquiv(
  beta = 0.1, n = NA, meanDiffLower = -1.3, meanDiffUpper = 1.3,
  meanDiff = 0, stDev = 2.2,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for two-sample mean difference from the MMRM model

Description

Obtains the power and sample size for two-sample mean difference at the last time point from the mixed-model for repeated measures (MMRM) model.

Usage

getDesignMeanDiffMMRM(
  beta = NA_real_,
  meanDiffH0 = 0,
  meanDiff = 0.5,
  k = 1,
  t = NA_real_,
  covar1 = diag(k),
  covar2 = NA_real_,
  accrualTime = 0,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0,
  gamma1 = 0,
  gamma2 = 0,
  accrualDuration = NA_real_,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

meanDiffH0

The mean difference at the last time point under the null hypothesis. Defaults to 0.

meanDiff

The mean difference at the last time point under the alternative hypothesis.

k

The number of postbaseline time points.

t

The postbaseline time points.

covar1

The covariance matrix for the repeated measures given baseline for the active treatment group.

covar2

The covariance matrix for the repeated measures given baseline for the control group. If missing, it will be set equal to the covariance matrix for the active treatment group.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

gamma1

The hazard rate for exponential dropout, or a vector of hazard rates for piecewise exponential dropout for the active treatment group.

gamma2

The hazard rate for exponential dropout, or a vector of hazard rates for piecewise exponential dropout for the control group.

accrualDuration

Duration of the enrollment period.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The degrees of freedom for the t-distribution is the total effective sample size minus 2. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanDiffMMRM object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • studyDuration: The maximum study duration.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • expectedStudyDurationH1: The expected study duration under H1.

    • expectedStudyDurationH0: The expected study duration under H0.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up time.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • meanDiffH0: The mean difference under H0.

    • meanDiff: The mean difference under H1.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyMeanDiff: The efficacy boundaries on the mean difference scale.

    • futilityMeanDiff: The futility boundaries on the mean difference scale.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: The allocation ratio for the active treatment versus control.

    • accrualTime: A vector that specifies the starting time of piecewise Poisson enrollment time intervals.

    • accrualIntensity: A vector of accrual intensities. One for each accrual time interval.

    • piecewiseSurvivalTime: A vector that specifies the starting time of piecewise exponential survival time intervals.

    • gamma1: The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout for the active treatment group.

    • gamma2: The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout for the control group.

    • k: The number of postbaseline time points.

    • t: The postbaseline time points.

    • covar1: The covariance matrix for the repeated measures given baseline for the active treatment group.

    • covar2: The covariance matrix for the repeated measures given baseline for the control group.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# function to generate the AR(1) correlation matrix
ar1_cor <- function(n, corr) {
  exponent <- abs(matrix((1:n) - 1, n, n, byrow = TRUE) - ((1:n) - 1))
  corr^exponent
}

(design1 = getDesignMeanDiffMMRM(
  beta = 0.2,
  meanDiffH0 = 0,
  meanDiff = 0.5,
  k = 4,
  t = c(1,2,3,4),
  covar1 = ar1_cor(4, 0.7),
  accrualIntensity = 10,
  gamma1 = 0.02634013,
  gamma2 = 0.02634013,
  accrualDuration = NA,
  allocationRatioPlanned = 1,
  kMax = 3,
  alpha = 0.025,
  typeAlphaSpending = "sfOF"))

Group sequential design for mean difference in 2x2 crossover

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample mean difference in 2x2 crossover.

Usage

getDesignMeanDiffXO(
  beta = NA_real_,
  n = NA_real_,
  meanDiffH0 = 0,
  meanDiff = 0.5,
  stDev = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanDiffH0

The mean difference under the null hypothesis. Defaults to 0.

meanDiff

The mean difference under the alternative hypothesis.

stDev

The standard deviation for within-subject random error.

allocationRatioPlanned

Allocation ratio for sequence A/B versus sequence B/A. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanDiffXO object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanDiffH0: The mean difference under the null hypothesis.

    • meanDiff: The mean difference under the alternative hypothesis.

    • stDev: The standard deviation for within-subject random error.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyMeanDiff: The efficacy boundaries on the mean difference scale.

    • futilityMeanDiff: The futility boundaries on the mean difference scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for sequence A/B versus sequence B/A.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignMeanDiffXO(
  beta = 0.2, n = NA, meanDiff = 75, stDev = 150,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for equivalence in mean difference in 2x2 crossover

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in mean difference in 2x2 crossover.

Usage

getDesignMeanDiffXOEquiv(
  beta = NA_real_,
  n = NA_real_,
  meanDiffLower = NA_real_,
  meanDiffUpper = NA_real_,
  meanDiff = 0,
  stDev = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanDiffLower

The lower equivalence limit of mean difference.

meanDiffUpper

The upper equivalence limit of mean difference.

meanDiff

The mean difference under the alternative hypothesis.

stDev

The standard deviation for within-subject random error.

allocationRatioPlanned

Allocation ratio for sequence A/B versus sequence B/A. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanDiffXOEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanDiffLower: The lower equivalence limit of mean difference.

    • meanDiffUpper: The upper equivalence limit of mean difference.

    • meanDiff: The mean difference under the alternative hypothesis.

    • stDev: The standard deviation for within-subject random error.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlpha: The cumulative probability for efficacy stopping under H0.

    • efficacyMeanDiffLower: The efficacy boundaries on the mean difference scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyMeanDiffUpper: The efficacy boundaries on the mean difference scale for the one-sided null hypothesis on the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for sequence A/B versus sequence B/A.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignMeanDiffXOEquiv(
  beta = 0.1, n = NA, meanDiffLower = -1.3, meanDiffUpper = 1.3,
  meanDiff = 0, stDev = 2.2,
  kMax = 4, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for t-test
(design2 <- getDesignMeanDiffXOEquiv(
  beta = 0.1, n = NA, meanDiffLower = -1.3, meanDiffUpper = 1.3,
  meanDiff = 0, stDev = 2.2,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for two-sample mean ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample mean ratio.

Usage

getDesignMeanRatio(
  beta = NA_real_,
  n = NA_real_,
  meanRatioH0 = 1,
  meanRatio = 1.25,
  CV = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanRatioH0

The mean ratio under the null hypothesis. Defaults to 1.

meanRatio

The mean ratio under the alternative hypothesis.

CV

The coefficient of variation. The standard deviation on the log scale is equal to sqrt(log(1 + CV^2)).

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanRatio object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanRatioH0: The mean ratio under the null hypothesis.

    • meanRatio: The mean ratio under the alternative hypothesis.

    • CV: The coefficient of variation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • numberOfSubjects: The number of subjects.

    • efficacyMeanRatio: The efficacy boundaries on the mean ratio scale.

    • futilityMeanRatio: The futility boundaries on the mean ratio scale.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignMeanRatio(
  beta = 0.1, n = NA, meanRatio = 1.25, CV = 0.25,
  alpha = 0.05, normalApproximation = FALSE))

Group sequential design for equivalence in two-sample mean ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in two-sample mean ratio.

Usage

getDesignMeanRatioEquiv(
  beta = NA_real_,
  n = NA_real_,
  meanRatioLower = NA_real_,
  meanRatioUpper = NA_real_,
  meanRatio = 1,
  CV = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanRatioLower

The lower equivalence limit of mean ratio.

meanRatioUpper

The upper equivalence limit of mean ratio.

meanRatio

The mean ratio under the alternative hypothesis.

CV

The coefficient of variation.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanRatioEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlpha: The attained significance level.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanRatioLower: The lower equivalence limit of mean ratio.

    • meanRatioUpper: The upper equivalence limit of mean ratio.

    • meanRatio: The mean ratio under the alternative hypothesis.

    • CV: The coefficient of variation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlpha: The cumulative probability for efficacy stopping under H0.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

    • efficacyMeanRatioLower: The efficacy boundaries on the mean ratio scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyMeanRatioUpper: The efficacy boundaries on the mean ratio scale for the one-sided null hypothesis on the upper equivalence limit.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignMeanRatioEquiv(
  beta = 0.1, n = NA, meanRatioLower = 0.8, meanRatioUpper = 1.25,
  meanRatio = 1, CV = 0.35,
  kMax = 4, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for t-test
(design2 <- getDesignMeanRatioEquiv(
  beta = 0.1, n = NA, meanRatioLower = 0.8, meanRatioUpper = 1.25,
  meanRatio = 1, CV = 0.35,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for mean ratio in 2x2 crossover

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample mean ratio in 2x2 crossover.

Usage

getDesignMeanRatioXO(
  beta = NA_real_,
  n = NA_real_,
  meanRatioH0 = 1,
  meanRatio = 1.25,
  CV = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanRatioH0

The mean ratio under the null hypothesis. Defaults to 1.

meanRatio

The mean ratio under the alternative hypothesis.

CV

The coefficient of variation. The standard deviation on the log scale is equal to sqrt(log(1 + CV^2)).

allocationRatioPlanned

Allocation ratio for sequence A/B versus sequence B/A. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanRatioXO object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanRatioH0: The mean ratio under the null hypothesis.

    • meanRatio: The mean ratio under the alternative hypothesis.

    • CV: The coefficient of variation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyMeanRatio: The efficacy boundaries on the mean ratio scale.

    • futilityMeanRatio: The futility boundaries on the mean ratio scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for sequence A/B versus sequence B/A.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignMeanRatioXO(
  beta = 0.1, n = NA, meanRatio = 1.25, CV = 0.25,
  alpha = 0.05, normalApproximation = FALSE))

Group sequential design for equivalence in mean ratio in 2x2 crossover

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence mean ratio in 2x2 crossover.

Usage

getDesignMeanRatioXOEquiv(
  beta = NA_real_,
  n = NA_real_,
  meanRatioLower = NA_real_,
  meanRatioUpper = NA_real_,
  meanRatio = 1,
  CV = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanRatioLower

The lower equivalence limit of mean ratio.

meanRatioUpper

The upper equivalence limit of mean ratio.

meanRatio

The mean ratio under the alternative hypothesis.

CV

The coefficient of variation.

allocationRatioPlanned

Allocation ratio for sequence A/B versus sequence B/A. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designMeanRatioEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanRatioLower: The lower equivalence limit of mean ratio.

    • meanRatioUpper: The upper equivalence limit of mean ratio.

    • meanRatio: The mean ratio under the alternative hypothesis.

    • CV: The coefficient of variation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlpha: The cumulative probability for efficacy stopping under H0.

    • efficacyMeanRatioLower: The efficacy boundaries on the mean ratio scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyMeanRatioUpper: The efficacy boundaries on the mean ratio scale for the one-sided null hypothesis on the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for sequence A/B versus sequence B/A.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignMeanRatioXOEquiv(
  beta = 0.1, n = NA, meanRatioLower = 0.8, meanRatioUpper = 1.25,
  meanRatio = 1, CV = 0.35,
  kMax = 4, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for t-test
(design2 <- getDesignMeanRatioXOEquiv(
  beta = 0.1, n = NA, meanRatioLower = 0.8, meanRatioUpper = 1.25,
  meanRatio = 1, CV = 0.35,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for two-sample odds ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample odds ratio.

Usage

getDesignOddsRatio(
  beta = NA_real_,
  n = NA_real_,
  oddsRatioH0 = 1,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = FALSE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

oddsRatioH0

The odds ratio under the null hypothesis. Defaults to 1.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designOddsRatio object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • oddsRatioH0: The odds ratio under the null hypothesis.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyOdddsRatio: The efficacy boundaries on the odds ratio scale.

    • futilityOddsRatio: The futility boundaries on the odds ratio scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatio: The ratio of the variance under H0 to the variance under H1.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignOddsRatio(
  beta = 0.1, n = NA, pi1 = 0.5, pi2 = 0.3,
  alpha = 0.05))

Group sequential design for equivalence in two-sample odds ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in two-sample odds ratio.

Usage

getDesignOddsRatioEquiv(
  beta = NA_real_,
  n = NA_real_,
  oddsRatioLower = NA_real_,
  oddsRatioUpper = NA_real_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = FALSE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

oddsRatioLower

The lower equivalence limit of odds ratio.

oddsRatioUpper

The upper equivalence limit of odds ratio.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designOddsRatioEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH10: The expected information under H10.

    • expectedInformationH20: The expected information under H20.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH10: The expected number of subjects under H10.

    • expectedNumberOfSubjectsH20: The expected number of subjects under H20.

    • oddsRatioLower: The lower equivalence limit of odds ratio.

    • oddsRatioUpper: The upper equivalence limit of odds ratio.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

    • oddsRatio: The odds ratio.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • efficacyOddsRatioLower: The efficacy boundaries on the odds ratio scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyOddsRatioUpper: The efficacy boundaries on the odds ratio scale for the one-sided null hypothesis on the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • varianceRatioH10: The ratio of the variance under H10 to the variance under H1.

    • varianceRatioH20: The ratio of the variance under H20 to the variance under H1.

    • varianceRatioH12: The ratio of the variance under H10 to the variance under H20.

    • varianceRatioH21: The ratio of the variance under H20 to the variance under H10.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignOddsRatioEquiv(
  beta = 0.2, n = NA, oddsRatioLower = 0.8,
  oddsRatioUpper = 1.25, pi1 = 0.12, pi2 = 0.12,
  kMax = 3, alpha = 0.05, typeAlphaSpending = "sfOF"))

Group sequential design for one-sample mean

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for one-sample mean.

Usage

getDesignOneMean(
  beta = NA_real_,
  n = NA_real_,
  meanH0 = 0,
  mean = 0.5,
  stDev = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

meanH0

The mean under the null hypothesis. Defaults to 0.

mean

The mean under the alternative hypothesis.

stDev

The standard deviation.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designOneMean object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • meanH0: The mean under the null hypothesis.

    • mean: The mean under the alternative hypothesis.

    • stDev: The standard deviation.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyMean: The efficacy boundaries on the mean scale.

    • futilityMean: The futility boundaries on the mean scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignOneMean(
  beta = 0.1, n = NA, meanH0 = 7, mean = 6, stDev = 2.5,
  kMax = 5, alpha = 0.025, typeAlphaSpending = "sfOF",
  typeBetaSpending = "sfP"))

# Example 2: sample size calculation for one-sample t-test
(design2 <- getDesignOneMean(
  beta = 0.1, n = NA, meanH0 = 7, mean = 6, stDev = 2.5,
  normalApproximation = FALSE, alpha = 0.025))

Power and sample for one-sample multinomial response

Description

Obtains the power given sample size or obtains the sample size given power for one-sample multinomial response.

Usage

getDesignOneMultinom(
  beta = NA_real_,
  n = NA_real_,
  ncats = NA_integer_,
  piH0 = NA_real_,
  pi = NA_real_,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ncats

The number of categories of the multinomial response.

piH0

The prevalence of each category under the null hypothesis. Only need to provide the values for the first ncats-1 categories.

pi

The prevalence of each category. Only need to provide the values for the first ncats-1 categories.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Value

An S3 class designOneMultinom object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The maximum number of subjects.

  • ncats: The number of categories of the multinomial response.

  • piH0: The prevalence of each category under the null hypothesis.

  • pi: The prevalence of each category.

  • effectsize: The effect size for the chi-square test.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignOneMultinom(
  beta = 0.1, ncats = 3, piH0 = c(0.25, 0.25),
  pi = c(0.3, 0.4), alpha = 0.05))

Group sequential design for one-sample proportion

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for one-sample proportion.

Usage

getDesignOneProportion(
  beta = NA_real_,
  n = NA_real_,
  piH0 = 0.1,
  pi = 0.2,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

piH0

The response probability under the null hypothesis.

pi

The response probability under the alternative hypothesis.

normalApproximation

The type of computation of the p-values. If TRUE, the normal approximation will be used, otherwise the calculations are performed with the binomial distribution. The exact calculation using the binomial distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designOneProportion object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping as well as for the binomial exact test in a fixed design.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • piH0: The response probability under the null hypothesis.

    • pi: The response probability under the alternative hypothesis.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyResponses: The efficacy boundaries on the number of responses scale.

    • futilityResponses: The futility boundaries on the number of responses scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the binomial distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignOneProportion(
  beta = 0.2, n = NA, piH0 = 0.15, pi = 0.25,
  kMax = 3, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for one-sample binomial exact test
(design2 <- getDesignOneProportion(
  beta = 0.2, n = NA, piH0 = 0.15, pi = 0.25,
  normalApproximation = FALSE, alpha = 0.05))

Power and sample size for one-sample Poisson rate exact test

Description

Obtains the power given sample size or obtains the sample size given power for one-sample Poisson rate.

Usage

getDesignOneRateExact(
  beta = NA_real_,
  n = NA_real_,
  lambdaH0 = NA_real_,
  lambda = NA_real_,
  D = 1,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

lambdaH0

The Poisson rate under the null hypothesis.

lambda

The Poisson rate under the alternative hypothesis.

D

The average exposure per subject.

alpha

The one-sided significance level. Defaults to 0.025.

Value

A data frame containing the following variables:

  • alpha: The specified significance level.

  • attainedAlpha: The attained type I error of the exact test.

  • power: The actual power of the exact test.

  • n: The sample size.

  • lambdaH0: The Poisson rate under the null hypothesis.

  • lambda: The Poisson rate under the alternative hypothesis.

  • D: The average exposure per subject.

  • r: The critical value of the number of events for rejecting the null hypothesis. Reject H0 if Y >= r for upper-tailed test, and reject H0 if Y <= r for lower-tailed test.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: power calculation
(design1 <- getDesignOneRateExact(
  n = 525, lambdaH0 = 0.049, lambda = 0.012,
  D = 0.5, alpha = 0.025))

# Example 2: sample size calculation
(design2 <- getDesignOneRateExact(
  beta = 0.2, lambdaH0 = 0.2, lambda = 0.3,
  D = 1, alpha = 0.05))

Group sequential design for one-sample slope

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for one-sample slope.

Usage

getDesignOneSlope(
  beta = NA_real_,
  n = NA_real_,
  slopeH0 = 0,
  slope = 0.5,
  stDev = 1,
  stDevCovariate = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

slopeH0

The slope under the null hypothesis. Defaults to 0.

slope

The slope under the alternative hypothesis.

stDev

The standard deviation of the residual.

stDevCovariate

The standard deviation of the covariate.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designOneSlope object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • slopeH0: The slope under the null hypothesis.

    • slope: The slope under the alternative hypothesis.

    • stDev: The standard deviation of the residual.

    • stDevCovariate: The standard deviation of the covariate.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacySlope: The efficacy boundaries on the slope scale.

    • futilitySlope: The futility boundaries on the slope scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignOneSlope(
  beta = 0.1, n = NA, slope = 0.5,
  stDev = 15, stDevCovariate = 9,
  normalApproximation = FALSE,
  alpha = 0.025))

Power and sample size for Cochran-Armitage trend test for ordered multi-sample binomial response

Description

Obtains the power given sample size or obtains the sample size given power for the Cochran-Armitage trend test for ordered multi-sample binomial response.

Usage

getDesignOrderedBinom(
  beta = NA_real_,
  n = NA_real_,
  ngroups = NA_integer_,
  pi = NA_real_,
  w = NA_real_,
  allocationRatioPlanned = NA_integer_,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

pi

The response probabilities for the treatment groups.

w

The scores assigned to the treatment groups. This should reflect the ordinal nature of the treatment groups, e.g. dose levels. Defaults to equally spaced scores.

allocationRatioPlanned

Allocation ratio for the treatment groups.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Value

An S3 class designOrderedBinom object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The maximum number of subjects.

  • ngroups: The number of treatment groups.

  • pi: The response probabilities for the treatment groups.

  • w: The scores assigned to the treatment groups.

  • trendstat: The Cochran-Armitage trend test statistic.

  • allocationRatioPlanned: Allocation ratio for the treatment groups.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignOrderedBinom(
  beta = 0.1, ngroups = 3, pi = c(0.1, 0.25, 0.5), alpha = 0.05))

Group sequential design for paired mean difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for paired mean difference.

Usage

getDesignPairedMeanDiff(
  beta = NA_real_,
  n = NA_real_,
  pairedDiffH0 = 0,
  pairedDiff = 0.5,
  stDev = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

pairedDiffH0

The paired difference under the null hypothesis. Defaults to 0.

pairedDiff

The paired difference under the alternative hypothesis.

stDev

The standard deviation for paired difference.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designPairedMeanDiff object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • pairedDiffH0: The paired difference under the null hypothesis.

    • pairedDiff: The paired difference under the alternative hypothesis.

    • stDev: The standard deviation for paired difference.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyPairedDiff: The efficacy boundaries on the paired difference scale.

    • futilityPairedDiff: The futility boundaries on the paired difference scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignPairedMeanDiff(
  beta = 0.1, n = NA, pairedDiffH0 = 0, pairedDiff = -2, stDev = 5,
  kMax = 5, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for one-sample t-test
(design2 <- getDesignPairedMeanDiff(
  beta = 0.1, n = NA, pairedDiffH0 = 0, pairedDiff = -2, stDev = 5,
  normalApproximation = FALSE, alpha = 0.025))

Group sequential design for equivalence in paired mean difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in paired mean difference.

Usage

getDesignPairedMeanDiffEquiv(
  beta = NA_real_,
  n = NA_real_,
  pairedDiffLower = NA_real_,
  pairedDiffUpper = NA_real_,
  pairedDiff = 0,
  stDev = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

pairedDiffLower

The lower equivalence limit of paired difference.

pairedDiffUpper

The upper equivalence limit of paired difference.

pairedDiff

The paired difference under the alternative hypothesis.

stDev

The standard deviation for paired difference.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designPairedMeanDiffEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlpha: The attained significance level under H0.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • pairedDiffLower: The lower equivalence limit of paired difference.

    • pairedDiffUpper: The upper equivalence limit of paired difference.

    • pairedDiff: The paired difference under the alternative hypothesis.

    • stDev: The standard deviation for paired difference.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlpha: The cumulative probability for efficacy stopping under H0.

    • efficacyPairedDiffLower: The efficacy boundaries on the paired difference scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyPairedDiffUpper: The efficacy boundaries on the paired difference scale for the one-sided null hypothesis on the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignPairedMeanDiffEquiv(
  beta = 0.1, n = NA, pairedDiffLower = -1.3, pairedDiffUpper = 1.3,
  pairedDiff = 0, stDev = 2.2,
  kMax = 4, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for t-test
(design2 <- getDesignPairedMeanDiffEquiv(
  beta = 0.1, n = NA, pairedDiffLower = -1.3, pairedDiffUpper = 1.3,
  pairedDiff = 0, stDev = 2.2,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for paired mean ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for paired mean ratio.

Usage

getDesignPairedMeanRatio(
  beta = NA_real_,
  n = NA_real_,
  pairedRatioH0 = 1,
  pairedRatio = 1.2,
  CV = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

pairedRatioH0

The paired ratio under the null hypothesis.

pairedRatio

The paired ratio under the alternative hypothesis.

CV

The coefficient of variation for paired ratio.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designPairedMeanRatio object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • pairedRatioH0: The paired ratio under the null hypothesis.

    • pairedRatio: The paired ratio under the alternative hypothesis.

    • CV: The coefficient of variation for paired ratio.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • numberOfSubjects: The number of subjects.

    • efficacyPairedRatio: The efficacy boundaries on the paired ratio scale.

    • futilityPairedRatio: The futility boundaries on the paired ratio scale.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignPairedMeanRatio(
  beta = 0.1, n = NA, pairedRatio = 1.2, CV = 0.35,
  kMax = 5, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for one-sample t-test
(design2 <- getDesignPairedMeanRatio(
  beta = 0.1, n = NA, pairedRatio = 1.2, CV = 0.35,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for equivalence in paired mean ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in paired mean ratio.

Usage

getDesignPairedMeanRatioEquiv(
  beta = NA_real_,
  n = NA_real_,
  pairedRatioLower = NA_real_,
  pairedRatioUpper = NA_real_,
  pairedRatio = 1,
  CV = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

pairedRatioLower

The lower equivalence limit of paired ratio.

pairedRatioUpper

The upper equivalence limit of paired ratio.

pairedRatio

The paired ratio under the alternative hypothesis.

CV

The coefficient of variation for paired ratio.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designPairedMeanRatioEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlpha: The attained significance level under H0.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • pairedRatioLower: The lower equivalence limit of paired ratio.

    • pairedRatioUpper: The upper equivalence limit of paired ratio.

    • pairedRatio: The paired ratio under the alternative hypothesis.

    • CV: The coefficient of variation for paired ratios.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlpha: The cumulative alpha attained under H0.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

    • efficacyPairedRatioLower: The efficacy boundaries on the paired ratio scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyPairedRatioUpper: The efficacy boundaries on the paired ratio scale for the one-sided null hypothesis on the upper equivalence limit.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: group sequential trial power calculation
(design1 <- getDesignPairedMeanRatioEquiv(
  beta = 0.1, n = NA, pairedRatioLower = 0.8, pairedRatioUpper = 1.25,
  pairedRatio = 1, CV = 0.35,
  kMax = 4, alpha = 0.05, typeAlphaSpending = "sfOF"))

# Example 2: sample size calculation for t-test
(design2 <- getDesignPairedMeanRatioEquiv(
  beta = 0.1, n = NA, pairedRatioLower = 0.8, pairedRatioUpper = 1.25,
  pairedRatio = 1, CV = 0.35,
  normalApproximation = FALSE, alpha = 0.05))

Group sequential design for McNemar's test for paired proportions

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for McNemar's test for paired proportions.

Usage

getDesignPairedPropMcNemar(
  beta = NA_real_,
  n = NA_real_,
  pDiscordant = NA_real_,
  riskDiff = NA_real_,
  nullVariance = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

pDiscordant

The proportion of discordant pairs (xi = pi01 + pi10).

riskDiff

The risk difference between the active and control treatments (delta = pi_t - pi_c = pi01 - pi10)

nullVariance

Whether to use the variance under the null or the variance under the alternative.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designPairedPropMcNemar object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • pDiscordant: The proportion of discordant pairs (xi = pi01 + pi10).

    • riskDiff: The risk difference between the active and control treatments (delta = pi_t - pi_c = pi01 - pi10)

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyRiskDiff: The efficacy boundaries on the risk difference scale.

    • futilityRiskDiff: The futility boundaries on the risk difference scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatio: The ratio of the variance under H0 to the variance under H1.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: fixed design
(design1 <- getDesignPairedPropMcNemar(
  beta = 0.1, n = NA, pDiscordant = 0.16, riskDiff = 0.1,
  alpha = 0.025))

# Example 2: group sequential design
(design2 <- getDesignPairedPropMcNemar(
  beta = 0.1, n = NA, pDiscordant = 0.16, riskDiff = 0.1,
  alpha = 0.025, kMax = 3, typeAlphaSpending = "sfOF"))

Power and sample size for repeated-measures ANOVA

Description

Obtains the power and sample size for one-way repeated measures analysis of variance. Each subject takes all treatments in the longitudinal study.

Usage

getDesignRepeatedANOVA(
  beta = NA_real_,
  n = NA_real_,
  ngroups = 2,
  means = NA_real_,
  stDev = 1,
  corr = 0,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

means

The treatment group means.

stDev

The total standard deviation.

corr

The correlation among the repeated measures.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Details

Let yijy_{ij} denote the measurement under treatment condition j(j=1,,k)j (j=1,\ldots,k) for subject i(i=1,,n)i (i=1,\ldots,n). Then

yij=α+βj+bi+eij,y_{ij} = \alpha + \beta_j + b_i + e_{ij},

where bib_i denotes the subject random effect, biN(0,σb2),b_i \sim N(0, \sigma_b^2), and eijN(0,σe2)e_{ij} \sim N(0, \sigma_e^2) denotes the within-subject residual. If we set βk=0\beta_k = 0, then α\alpha is the mean of the last treatment (control), and βj\beta_j is the difference in means between the jjth treatment and the control for j=1,,k1j=1,\ldots,k-1.

The repeated measures have a compound symmetry covariance structure. Let σ2=σb2+σe2\sigma^2 = \sigma_b^2 + \sigma_e^2, and ρ=σb2σb2+σe2\rho = \frac{\sigma_b^2}{\sigma_b^2 + \sigma_e^2}. Then Var(yi)=σ2{(1ρ)Ik+ρ1k1kT}Var(y_i) = \sigma^2 \{(1-\rho) I_k + \rho 1_k 1_k^T\}. Let XiX_i denote the design matrix for subject ii. Let θ=(α,β1,,βk1)T\theta = (\alpha, \beta_1, \ldots, \beta_{k-1})^T. It follows that

Var(θ^)=(i=1nXiTVi1Xi)1.Var(\hat{\theta}) = \left(\sum_{i=1}^{n} X_i^T V_i^{-1} X_i\right)^{-1}.

It can be shown that

Var(β^)=σ2(1ρ)n(Ik1+1k11k1T).Var(\hat{\beta}) = \frac{\sigma^2 (1-\rho)}{n} (I_{k-1} + 1_{k-1} 1_{k-1}^T).

It follows that β^TV^β^1β^Fk1,(n1)(k1),λ,\hat{\beta}^T \hat{V}_{\hat{\beta}}^{-1} \hat{\beta} \sim F_{k-1,(n-1)(k-1), \lambda}, where the noncentrality parameter for the FF distribution is

λ=βTVβ^1β=nj=1k(μjμˉ)2σ2(1ρ).\lambda = \beta^T V_{\hat{\beta}}^{-1} \beta = \frac{n \sum_{j=1}^{k} (\mu_j - \bar{\mu})^2}{\sigma^2(1-\rho)}.

Value

An S3 class designRepeatedANOVA object with the following components:

  • power: The power to reject the null hypothesis that there is no difference among the treatment groups.

  • alpha: The two-sided significance level.

  • n: The number of subjects.

  • ngroups: The number of treatment groups.

  • means: The treatment group means.

  • stDev: The total standard deviation.

  • corr: The correlation among the repeated measures.

  • effectsize: The effect size.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRepeatedANOVA(
  beta = 0.1, ngroups = 4, means = c(1.5, 2.5, 2, 0),
  stDev = 5, corr = 0.2, alpha = 0.05))

Power and sample size for one-way repeated measures ANOVA contrast

Description

Obtains the power and sample size for a single contrast in one-way repeated measures analysis of variance.

Usage

getDesignRepeatedANOVAContrast(
  beta = NA_real_,
  n = NA_real_,
  ngroups = 2,
  means = NA_real_,
  stDev = 1,
  corr = 0,
  contrast = NA_real_,
  meanContrastH0 = 0,
  rounding = TRUE,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

means

The treatment group means.

stDev

The total standard deviation.

corr

The correlation among the repeated measures.

contrast

The coefficients for the single contrast.

meanContrastH0

The mean of the contrast under the null hypothesis.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The one-sided significance level. Defaults to 0.025.

Value

An S3 class designRepeatedANOVAContrast object with the following components:

  • power: The power to reject the null hypothesis for the treatment contrast.

  • alpha: The one-sided significance level.

  • n: The number of subjects.

  • ngroups: The number of treatment groups.

  • means: The treatment group means.

  • stDev: The total standard deviation.

  • corr: The correlation among the repeated measures.

  • contrast: The coefficients for the single contrast.

  • meanContrastH0: The mean of the contrast under the null hypothesis.

  • meanContrast: The mean of the contrast under the alternative hypothesis.

  • effectsize: The effect size.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRepeatedANOVAContrast(
  beta = 0.1, ngroups = 4, means = c(1.5, 2.5, 2, 0),
  stDev = 5, corr = 0.2, contrast = c(1, 1, 1, -3)/3,
  alpha = 0.025))

Group sequential design for two-sample risk difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample risk difference.

Usage

getDesignRiskDiff(
  beta = NA_real_,
  n = NA_real_,
  riskDiffH0 = 0,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = TRUE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

riskDiffH0

The risk difference under the null hypothesis. Defaults to 0.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designRiskDiff object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • riskDiffH0: The risk difference under the null hypothesis.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyRiskDiff: The efficacy boundaries on the risk difference scale.

    • futilityRiskDiff: The futility boundaries on the risk difference scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatio: The ratio of the variance under H0 to the variance under H1.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRiskDiff(
  beta = 0.2, n = NA, pi1 = 0.1, pi2 = 0.15,
  kMax = 3, alpha = 0.025, typeAlphaSpending = "sfOF",
  nullVariance = 0))

Group sequential design for equivalence in two-sample risk difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in two-sample risk difference.

Usage

getDesignRiskDiffEquiv(
  beta = NA_real_,
  n = NA_real_,
  riskDiffLower = NA_real_,
  riskDiffUpper = NA_real_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = FALSE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

riskDiffLower

The lower equivalence limit of risk difference.

riskDiffUpper

The upper equivalence limit of risk difference.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designRiskDiffEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH10: The expected information under H10.

    • expectedInformationH20: The expected information under H20.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH10: The expected number of subjects under H10.

    • expectedNumberOfSubjectsH20: The expected number of subjects under H20.

    • riskDiffLower: The lower equivalence limit of risk difference.

    • riskDiffUpper: The upper equivalence limit of risk difference.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

    • riskDiff: The risk difference.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • efficacyRiskDiffLower: The efficacy boundaries on the risk difference scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyRiskDiffUpper: The efficacy boundaries on the risk difference scale for the one-sided null hypothesis on the upper equivalence limit.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • varianceRatioH10: The ratio of the variance under H10 to the variance under H1.

    • varianceRatioH20: The ratio of the variance under H20 to the variance under H1.

    • varianceRatioH12: The ratio of the variance under H10 to the variance under H20.

    • varianceRatioH21: The ratio of the variance under H20 to the variance under H10.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRiskDiffEquiv(
  beta = 0.2, n = NA, riskDiffLower = -0.1,
  riskDiffUpper = 0.1, pi1 = 0.12, pi2 = 0.12,
  nullVariance = 1,
  kMax = 3, alpha = 0.05, typeAlphaSpending = "sfOF"))

Power and sample size for exact unconditional test for risk difference

Description

Obtains the power given sample size or obtains the sample size given power for exact unconditional test of risk difference.

Usage

getDesignRiskDiffExact(
  beta = NA_real_,
  n = NA_real_,
  riskDiffH0 = 0,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

riskDiffH0

The risk difference under the null hypothesis. Defaults to 0.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

alpha

The one-sided significance level. Defaults to 0.025.

Value

A data frame with the following variables:

  • alpha: The specified one-sided significance level.

  • attainedAlpha: The attained one-sided significance level.

  • power: The power.

  • n: The sample size.

  • riskDiffH0: The risk difference under the null hypothesis.

  • pi1: The assumed probability for the active treatment group.

  • pi2: The assumed probability for the control group.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

  • zstatRiskDiffBound: The critical value on the scale of score test statistic for risk difference.

  • pi2star: The response probability in the control group at which the critical value of the test statistic is attained.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Superiority test

getDesignRiskDiffExact(n = 50, pi1 = 0.6, pi2 = 0.25, alpha = 0.025)


# Non-inferiority test

getDesignRiskDiffExact(beta = 0.1, riskDiffH0 = -0.2,
                       pi1 = 0.8, pi2 = 0.8, alpha = 0.025)

Power and sample size for exact unconditional test for equivalence in risk difference

Description

Obtains the power given sample size or obtains the sample size given power for exact unconditional test of equivalence in risk difference.

Usage

getDesignRiskDiffExactEquiv(
  beta = NA_real_,
  n = NA_real_,
  riskDiffLower = NA_real_,
  riskDiffUpper = NA_real_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

riskDiffLower

The lower equivalence limit of risk difference.

riskDiffUpper

The upper equivalence limit of risk difference.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

Value

A data frame with the following variables:

  • alpha: The specified significance level for each of the two one-sided tests.

  • attainedAlpha: The attained significance level.

  • power: The power.

  • n: The sample size.

  • riskDiffLower: The lower equivalence limit of risk difference.

  • riskDiffUpper: The upper equivalence limit of risk difference.

  • pi1: The assumed probability for the active treatment group.

  • pi2: The assumed probability for the control group.

  • riskDiff: The risk difference.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

  • zstatRiskDiffLower: The efficacy boundaries on the z-test statistic scale for the one-sided null hypothesis on the lower equivalence limit.

  • zstatRiskDiffUpper: The efficacy boundaries on the z-test statistic scale for the one-sided null hypothesis on the upper equivalence limit.

Author(s)

Kaifeng Lu, [email protected]

Examples

getDesignRiskDiffExactEquiv(
  n = 200, riskDiffLower = -0.2, riskDiffUpper = 0.2,
  pi1 = 0.775, pi2 = 0.775, alpha = 0.05)

Group sequential design for two-sample risk ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample risk ratio.

Usage

getDesignRiskRatio(
  beta = NA_real_,
  n = NA_real_,
  riskRatioH0 = 1,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = TRUE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

riskRatioH0

The risk ratio under the null hypothesis. Defaults to 1.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designRiskRatio object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • riskRatioH0: The risk ratio under the null hypothesis.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyRiskRatio: The efficacy boundaries on the risk ratio scale.

    • futilityRiskRatio: The futility boundaries on the risk ratio scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatio: The ratio of the variance under H0 to the variance under H1.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRiskRatio(
  beta = 0.1, n = NA, pi1 = 0.5, pi2 = 0.3,
  alpha = 0.05))

Group sequential design for equivalence in two-sample risk ratio

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for equivalence in two-sample risk ratio.

Usage

getDesignRiskRatioEquiv(
  beta = NA_real_,
  n = NA_real_,
  riskRatioLower = NA_real_,
  riskRatioUpper = NA_real_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = FALSE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

riskRatioLower

The lower equivalence limit of risk ratio.

riskRatioUpper

The upper equivalence limit of risk ratio.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designRiskRatioEquiv object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The significance level for each of the two one-sided tests. Defaults to 0.05.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • kMax: The number of stages.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH10: The expected information under H10.

    • expectedInformationH20: The expected information under H20.

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH10: The expected number of subjects under H10.

    • expectedNumberOfSubjectsH20: The expected number of subjects under H20.

    • riskRatioLower: The lower equivalence limit of risk ratio.

    • riskRatioUpper: The upper equivalence limit of risk ratio.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

    • riskRatio: The risk ratio.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • efficacyRiskRatioLower: The efficacy boundaries on the risk ratio scale for the one-sided null hypothesis on the lower equivalence limit.

    • efficacyRiskRatioUpper: The efficacy boundaries on the risk ratio scale for the one-sided null hypothesis on the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • spendingTime: The error spending time at each analysis.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • varianceRatioH10: The ratio of the variance under H10 to the variance under H1.

    • varianceRatioH20: The ratio of the variance under H20 to the variance under H1.

    • varianceRatioH12: The ratio of the variance under H10 to the variance under H20.

    • varianceRatioH21: The ratio of the variance under H20 to the variance under H10.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRiskRatioEquiv(
  beta = 0.2, n = NA, riskRatioLower = 0.8,
  riskRatioUpper = 1.25, pi1 = 0.12, pi2 = 0.12,
  kMax = 3, alpha = 0.05, typeAlphaSpending = "sfOF"))

Power and sample size for exact unconditional test for risk ratio

Description

Obtains the power given sample size or obtains the sample size given power for exact unconditional test of risk ratio.

Usage

getDesignRiskRatioExact(
  beta = NA_real_,
  n = NA_real_,
  riskRatioH0 = 1,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  alpha = 0.025
)

Arguments

beta

The type II error.

n

The total sample size.

riskRatioH0

The risk ratio under the null hypothesis. Defaults to 0.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

alpha

The one-sided significance level. Defaults to 0.025.

Value

A data frame with the following variables:

  • alpha: The specified one-sided significance level.

  • attainedAlpha: The attained one-sided significance level.

  • power: The power.

  • n: The sample size.

  • riskRatioH0: The risk ratio under the null hypothesis.

  • pi1: The assumed probability for the active treatment group.

  • pi2: The assumed probability for the control group.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

  • zstatRiskRatioBound: The critical value on the scale of score test statistic for risk ratio.

  • pi2star: The response probability in the control group at which the critical value of the test statistic is attained.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Non-inferiority test

getDesignRiskRatioExact(beta = 0.1, riskRatioH0 = 0.833,
                        pi1 = 0.9, pi2 = 0.9, alpha = 0.025)

Power and sample size for exact unconditional test for equivalence in risk ratio

Description

Obtains the power given sample size or obtains the sample size given power for exact unconditional test of equivalence in risk ratio.

Usage

getDesignRiskRatioExactEquiv(
  beta = NA_real_,
  n = NA_real_,
  riskRatioLower = NA_real_,
  riskRatioUpper = NA_real_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

riskRatioLower

The lower equivalence limit of risk ratio.

riskRatioUpper

The upper equivalence limit of risk ratio.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

Value

A data frame with the following variables:

  • alpha: The specified significance level for each of the two one-sided tests.

  • attainedAlpha: The attained significance level.

  • power: The power.

  • n: The sample size.

  • riskRatioLower: The lower equivalence limit of risk ratio.

  • riskRatioUpper: The upper equivalence limit of risk ratio.

  • pi1: The assumed probability for the active treatment group.

  • pi2: The assumed probability for the control group.

  • riskRatio: The risk ratio.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

  • zstatRiskRatioLower: The efficacy boundaries on the z-test statistic scale for the one-sided null hypothesis on the lower equivalence limit.

  • zstatRiskRatioUpper: The efficacy boundaries on the z-test statistic scale for the one-sided null hypothesis on the upper equivalence limit.

Author(s)

Kaifeng Lu, [email protected]

Examples

getDesignRiskRatioExactEquiv(
  n = 200, riskRatioLower = 0.8, riskRatioUpper = 1.25,
  pi1 = 0.775, pi2 = 0.775, alpha = 0.05)

Group sequential design for two-sample risk ratio based on the Farrington-Manning score test

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample risk ratio based on the Farrington-Manning score test

Usage

getDesignRiskRatioFM(
  beta = NA_real_,
  n = NA_real_,
  riskRatioH0 = 1,
  pi1 = NA_real_,
  pi2 = NA_real_,
  nullVariance = TRUE,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

riskRatioH0

The risk ratio under the null hypothesis. Defaults to 1.

pi1

The assumed probability for the active treatment group.

pi2

The assumed probability for the control group.

nullVariance

Whether to use the variance under the null or the empirical variance under the alternative.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designRiskRatioFM object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • riskRatioH0: The risk ratio under the null hypothesis.

    • pi1: The assumed probability for the active treatment group.

    • pi2: The assumed probability for the control group.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyRiskRatioScore: The efficacy boundaries on the score test pi1 - riskRatioH0*pi2 score.

    • futilityRiskRatioScore: The futility boundaries on the score test pi1 - riskRatioH0*pi2 scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • varianceRatio: The ratio of the variance under H0 to the variance under H1.

    • nullVariance: Whether to use the variance under the null or the empirical variance under the alternative.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignRiskRatioFM(
  beta = 0.2, riskRatioH0 = 1.3, pi1 = 0.125, pi2 = 0.125,
  alpha = 0.05))

Group sequential design for two-sample slope difference

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample slope difference.

Usage

getDesignSlopeDiff(
  beta = NA_real_,
  n = NA_real_,
  slopeDiffH0 = 0,
  slopeDiff = 0.5,
  stDev = 1,
  stDevCovariate = 1,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

slopeDiffH0

The slope difference under the null hypothesis. Defaults to 0.

slopeDiff

The slope difference under the alternative hypothesis.

stDev

The standard deviation of the residual.

stDevCovariate

The standard deviation of the covariate.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designSlopeDiff object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • slopeDiffH0: The slope difference under the null hypothesis.

    • slopeDiff: The slope difference under the alternative hypothesis.

    • stDev: The standard deviation of the residual.

    • stDevCovariate: The standard deviation of the covariate.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacySlopeDiff: The efficacy boundaries on the slope difference scale.

    • futilitySlopeDiff: The futility boundaries on the slope difference scale.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignSlopeDiff(
  beta = 0.1, n = NA, slopeDiff = -0.5,
  stDev = 10, stDevCovariate = 6,
  normalApproximation = FALSE, alpha = 0.025))

Group sequential design for two-sample slope difference from the MMRM model

Description

Obtains the power given sample size or obtains the sample size given power for two-sample slope difference from the growth curve MMRM model.

Usage

getDesignSlopeDiffMMRM(
  beta = NA_real_,
  slopeDiffH0 = 0,
  slopeDiff = 0.5,
  stDev = 1,
  stDevIntercept = 1,
  stDevSlope = 1,
  corrInterceptSlope = 0.5,
  w = NA_real_,
  N = NA_real_,
  accrualTime = 0,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0,
  gamma1 = 0,
  gamma2 = 0,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  allocationRatioPlanned = 1,
  normalApproximation = TRUE,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

slopeDiffH0

The slope difference under the null hypothesis. Defaults to 0.

slopeDiff

The slope difference under the alternative hypothesis.

stDev

The standard deviation of the residual.

stDevIntercept

The standard deviation of the random intercept.

stDevSlope

The standard deviation of the random slope.

corrInterceptSlope

The correlation between the random intercept and random slope.

w

The number of time units per measurement visit in a period.

N

The number of measurement visits in a period.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

gamma1

The hazard rate for exponential dropout, or a vector of hazard rates for piecewise exponential dropout for the active treatment group.

gamma2

The hazard rate for exponential dropout, or a vector of hazard rates for piecewise exponential dropout for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

normalApproximation

The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution. The degrees of freedom for the t-distribution for testing the slope difference is calculated using the containment method, and is equal to the total number of observations minus two times the total number of subjects. The exact calculation using the t distribution is only implemented for the fixed design.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Details

We use the following random-effects model to compare two slopes:

yij=α+(β+γxi)tj+ai+bitj+eij,y_{ij} = \alpha + (\beta + \gamma x_i) t_j + a_i + b_i t_j + e_{ij},

where

  • α\alpha: overall intercept common across treatment groups due to randomization

  • β\beta: slope for the control group

  • γ\gamma: difference in slopes between the active treatment and control groups

  • xix_i: treatment indicator for subject ii, 1 for the active treatment and 0 for the control

  • tjt_j: time point jj for repeated measurements, t1=0<t2<<tkt_1 = 0 < t_2 < \ldots < t_k

  • (ai,bi)(a_i, b_i): random intercept and random slope for subject ii, Var(ai)=σa2Var(a_i) = \sigma_a^2, Var(bi)=σb2Var(b_i) = \sigma_b^2, Corr(ai,bi)=ρCorr(a_i, b_i) = \rho

  • eije_{ij}: within-subject residual with variance σe2\sigma_e^2

By accounting for randomization, we improve the efficiency for estimating the difference in slopes. We also allow for non-equal spacing of the time points and missing data due to dropouts.

Value

An S3 class designSlopeDiffMMRM object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping.

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • studyDuration: The maximum study duration.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • expectedStudyDurationH1: The expected study duration under H1.

    • expectedStudyDurationH0: The expected study duration under H0.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up time.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • slopeDiffH0: The slope difference under H0.

    • slopeDiff: The slope difference under H1.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacySlopeDiff: The efficacy boundaries on the slope difference scale.

    • futilitySlopeDiff: The futility boundaries on the slope difference scale.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: The allocation ratio for the active treatment versus control.

    • accrualTime: A vector that specifies the starting time of piecewise Poisson enrollment time intervals.

    • accrualIntensity: A vector of accrual intensities. One for each accrual time interval.

    • piecewiseSurvivalTime: A vector that specifies the starting time of piecewise exponential survival time intervals.

    • gamma1: The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout for the active treatment group.

    • gamma2: The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout for the control group.

    • w: The number of time units per measurement visit in a period.

    • N: The number of measurement visits in a period.

    • stdDev: The standard deviation of the residual.

    • G: The covariance matrix for the random intercept and random slope.

    • normalApproximation: The type of computation of the p-values. If TRUE, the variance is assumed to be known, otherwise the calculations are performed with the t distribution.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

References

Daniel O. Scharfstein, Anastasios A. Tsiatis, and James M. Robins. Semiparametric efficiency and its implication on the design and analysis of group-sequential studies. Journal of the American Statistical Association 1997; 92:1342-1350.

Examples

(design1 <- getDesignSlopeDiffMMRM(
  beta = 0.2, slopeDiff = log(1.15)/52,
  stDev = sqrt(.182),
  stDevIntercept = sqrt(.238960),
  stDevSlope = sqrt(.000057),
  corrInterceptSlope = .003688/sqrt(.238960*.000057),
  w = 8,
  N = 10000,
  accrualIntensity = 15,
  gamma1 = 1/(4.48*52),
  gamma2 = 1/(4.48*52),
  accrualDuration = NA,
  followupTime = 8,
  alpha = 0.025))

Power and sample for difference in two-sample multinomial responses

Description

Obtains the power given sample size or obtains the sample size given power for difference in two-sample multinomial responses.

Usage

getDesignTwoMultinom(
  beta = NA_real_,
  n = NA_real_,
  ncats = NA_integer_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ncats

The number of categories of the multinomial response.

pi1

The prevalence of each category for the treatment group. Only need to specify the valued for the first ncats-1 categories.

pi2

The prevalence of each category for the control group. Only need to specify the valued for the first ncats-1 categories.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Value

An S3 class designTwoMultinom object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The maximum number of subjects.

  • ncats: The number of categories of the multinomial response.

  • pi1: The prevalence of each category for the treatment group.

  • pi2: The prevalence of each category for the control group.

  • effectsize: The effect size for the chi-square test.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignTwoMultinom(
  beta = 0.1, ncats = 3, pi1 = c(0.3, 0.35),
  pi2 = c(0.2, 0.3), alpha = 0.05))

Power and sample size for the Wilcoxon test for two-sample ordinal response

Description

Obtains the power given sample size or obtains the sample size given power for the Wilcoxon test for two-sample ordinal response.

Usage

getDesignTwoOrdinal(
  beta = NA_real_,
  n = NA_real_,
  ncats = NA_integer_,
  pi1 = NA_real_,
  pi2 = NA_real_,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ncats

The number of categories of the ordinal response.

pi1

The prevalence of each category for the treatment group. Only need to specify the valued for the first ncats-1 categories.

pi2

The prevalence of each category for the control group. Only need to specify the valued for the first ncats-1 categories.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The significance level. Defaults to 0.025.

Value

An S3 class designTwoOrdinal object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The maximum number of subjects.

  • ncats: The number of categories of the ordinal response.

  • pi1: The prevalence of each category for the treatment group.

  • pi2: The prevalence of each category for the control group.

  • meanscore1: The mean midrank score for the treatment group.

  • meanscore2: The mean midrank score for the control group.

  • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignTwoOrdinal(
  beta = 0.1, ncats = 4, pi1 = c(0.55, 0.3, 0.1),
  pi2 = c(0.214, 0.344, 0.251), alpha = 0.025))

Power and sample size for two-way ANOVA

Description

Obtains the power and sample size for two-way analysis of variance.

Usage

getDesignTwoWayANOVA(
  beta = NA_real_,
  n = NA_real_,
  nlevelsA = 2,
  nlevelsB = 2,
  means = NA_real_,
  stDev = 1,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

nlevelsA

The number of groups for Factor A.

nlevelsB

The number of levels for Factor B.

means

The matrix of treatment means for Factors A and B combination.

stDev

The common standard deviation.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Value

An S3 class designTwoWayANOVA object with the following components:

  • alpha: The two-sided significance level.

  • nlevelsA: The number of levels for Factor A.

  • nlevelsB: The number of levels for Factor B.

  • means: The matrix of treatment group means.

  • stDev: The common standard deviation.

  • effectsizeA: The effect size for Factor A.

  • effectsizeB: The effect size for Factor B.

  • effectsizeAB: The effect size for Factor A and Factor B interaction.

  • rounding: Whether to round up sample size.

  • powerdf: The data frame containing the power and sample size results. It has the following variables:

    • n: The sample size.

    • powerA: The power to reject the null hypothesis that there is no difference among Factor A levels.

    • powerB: The power to reject the null hypothesis that there is no difference among Factor B levels.

    • powerAB: The power to reject the null hypothesis that there is no interaction between Factor A and Factor B.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignTwoWayANOVA(
  beta = 0.1, nlevelsA = 2, nlevelsB = 2,
  means = matrix(c(0.5, 4.7, 0.4, 6.9), 2, 2, byrow = TRUE),
  stDev = 2, alpha = 0.05))

Power and sample size for unordered multi-sample binomial response

Description

Obtains the power given sample size or obtains the sample size given power for the chi-square test for unordered multi-sample binomial response.

Usage

getDesignUnorderedBinom(
  beta = NA_real_,
  n = NA_real_,
  ngroups = NA_integer_,
  pi = NA_real_,
  allocationRatioPlanned = NA_integer_,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

pi

The response probabilities for the treatment groups.

allocationRatioPlanned

Allocation ratio for the treatment groups.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Value

An S3 class designUnorderedBinom object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The maximum number of subjects.

  • ngroups: The number of treatment groups.

  • pi: The response probabilities for the treatment groups.

  • effectsize: The effect size for the chi-square test.

  • allocationRatioPlanned: Allocation ratio for the treatment groups.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignUnorderedBinom(
  beta = 0.1, ngroups = 3, pi = c(0.1, 0.25, 0.5), alpha = 0.05))

Power and sample size for unordered multi-sample multinomial response

Description

Obtains the power given sample size or obtains the sample size given power for the chi-square test for unordered multi-sample multinomial response.

Usage

getDesignUnorderedMultinom(
  beta = NA_real_,
  n = NA_real_,
  ngroups = NA_integer_,
  ncats = NA_integer_,
  pi = NA_real_,
  allocationRatioPlanned = NA_integer_,
  rounding = TRUE,
  alpha = 0.05
)

Arguments

beta

The type II error.

n

The total sample size.

ngroups

The number of treatment groups.

ncats

The number of categories of the multinomial response.

pi

The matrix of response probabilities for the treatment groups. It should have ngroups rows and ncats-1 or ncats columns.

allocationRatioPlanned

Allocation ratio for the treatment groups.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

alpha

The two-sided significance level. Defaults to 0.05.

Value

An S3 class designUnorderedMultinom object with the following components:

  • power: The power to reject the null hypothesis.

  • alpha: The two-sided significance level.

  • n: The maximum number of subjects.

  • ngroups: The number of treatment groups.

  • ncats: The number of categories of the multinomial response.

  • pi: The response probabilities for the treatment groups.

  • effectsize: The effect size for the chi-square test.

  • allocationRatioPlanned: Allocation ratio for the treatment groups.

  • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

(design1 <- getDesignUnorderedMultinom(
  beta = 0.1, ngroups = 3, ncats = 4,
  pi = matrix(c(0.230, 0.320, 0.272,
                0.358, 0.442, 0.154,
                0.142, 0.036, 0.039),
              3, 3, byrow = TRUE),
  allocationRatioPlanned = c(2, 2, 1),
  alpha = 0.05))

Group sequential design for two-sample Wilcoxon test

Description

Obtains the power given sample size or obtains the sample size given power for a group sequential design for two-sample Wilcoxon test.

Usage

getDesignWilcoxon(
  beta = NA_real_,
  n = NA_real_,
  pLarger = 0.6,
  allocationRatioPlanned = 1,
  rounding = TRUE,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

beta

The type II error.

n

The total sample size.

pLarger

The probability that a randomly chosen sample from the treatment group is larger than a randomly chosen sample from the control group under the alternative hypothesis.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

kMax

The maximum number of stages.

informationRates

The information rates. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

Value

An S3 class designWilcoxon object with three components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlpha: The attained significance level, which is different from the overall significance level in the presence of futility stopping..

    • kMax: The number of stages.

    • theta: The parameter value.

    • information: The maximum information.

    • expectedInformationH1: The expected information under H1.

    • expectedInformationH0: The expected information under H0.

    • drift: The drift parameter, equal to theta*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numberOfSubjects: The maximum number of subjects.

    • expectedNumberOfSubjectsH1: The expected number of subjects under H1.

    • expectedNumberOfSubjectsH0: The expected number of subjects under H0.

    • pLarger: The probability that a randomly chosen sample from the treatment group is larger than a randomly chosen sample from the control group under the alternative hypothesis.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

    • rejectPerStageH0: The probability for efficacy stopping under H0.

    • futilityPerStageH0: The probability for futility stopping under H0.

    • cumulativeRejectionH0: The cumulative probability for efficacy stopping under H0.

    • cumulativeFutilityH0: The cumulative probability for futility stopping under H0.

    • efficacyPLarger: The efficacy boundaries on the proportion of pairs of samples from the two treatment groups with the sample from the treatment group greater than that from the control group.

    • futilityPLarger: The futility boundaries on the proportion of pairs of samples from the two treatment groups with the sample from the treatment group greater than that from the control group.

    • numberOfSubjects: The number of subjects.

  • settings: A list containing the following input parameters:

    • typeAlphaSpending: The type of alpha spending.

    • parameterAlphaSpending: The parameter value for alpha spending.

    • userAlphaSpending: The user defined alpha spending.

    • typeBetaSpending: The type of beta spending.

    • parameterBetaSpending: The parameter value for beta spending.

    • userBetaSpending: The user defined beta spending.

    • spendingTime: The error spending time at each analysis.

    • allocationRatioPlanned: Allocation ratio for the active treatment versus control.

    • rounding: Whether to round up sample size.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: fixed design
(design1 <- getDesignWilcoxon(
  beta = 0.1, n = NA,
  pLarger = pnorm((8 - 2)/sqrt(2*25^2)), alpha = 0.025))

# Example 2: group sequential design
(design2 <- getDesignWilcoxon(
  beta = 0.1, n = NA,
  pLarger = pnorm((8 - 2)/sqrt(2*25^2)), alpha = 0.025,
  kMax = 3, typeAlphaSpending = "sfOF"))

Range of accrual duration for target number of events

Description

Obtains a range of accrual duration to reach the target number of events.

Usage

getDurationFromNevents(
  nevents = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  npoints = 23L,
  interval = as.numeric(c(0.001, 240))
)

Arguments

nevents

The target number of events.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

followupTime

Follow-up time for the last enrolled subjects. Must be provided for fixed follow-up design.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

npoints

The number of accrual duration time points. Defaults to 23.

interval

The interval to search for the solution of accrualDuration. Defaults to c(0.001, 240).

Value

A data frame of the following variables:

  • nevents: The target number of events.

  • fixedFollowup: Whether a fixed follow-up design is used.

  • accrualDuration: The accrual duration.

  • subjects: The total number of subjects.

  • followupTime: The follow-up time for the last enrolled subject.

  • studyDuration: The study duration.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survivals, and 5% dropout by
# the end of 1 year.

getDurationFromNevents(
  nevents = 80, allocationRatioPlanned = 1,
  accrualTime = seq(0, 8),
  accrualIntensity = 26/9*seq(1, 9),
  piecewiseSurvivalTime = c(0, 6),
  stratumFraction = c(0.2, 0.8),
  lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
  lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
  gamma1 = -log(1-0.05)/12,
  gamma2 = -log(1-0.05)/12,
  fixedFollowup = FALSE)

Get the required number of events given hazard ratio

Description

Obtains the required number of events given the hazard ratios under the null and alternative hypotheses for a group sequential design.

Usage

getNeventsFromHazardRatio(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  spendingTime = NA_real_,
  hazardRatioH0 = 1,
  hazardRatio = NA_real_,
  allocationRatioPlanned = 1,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates in terms of number of events. Fixed prior to the trial. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

hazardRatioH0

Hazard ratio under the null hypothesis for the active treatment versus control. Defaults to 1 for superiority test.

hazardRatio

Hazard ratio under the alternative hypothesis for the active treatment versus control. Defaults to 0.5.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

rounding

Whether to round up the number of events. Defaults to 1 for rounding.

Value

The required number of events.

Author(s)

Kaifeng Lu, [email protected]

Examples

getNeventsFromHazardRatio(
  beta = 0.2, kMax = 2,
  informationRates = c(0.5,1),
  alpha = 0.025, typeAlphaSpending = "sfOF",
  typeBetaSpending = "sfP",
  hazardRatio = 0.673)

Repeated confidence interval for group sequential design

Description

Obtains the repeated confidence interval for a group sequential trial.

Usage

getRCI(
  L = NA_integer_,
  zL = NA_real_,
  IMax = NA_real_,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  spendingTime = NA_real_
)

Arguments

L

The look of interest.

zL

The z-test statistic at the look.

IMax

The maximum information of the trial.

informationRates

The information rates up to look L.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage up to look L. Defaults to true if left unspecified.

criticalValues

The upper boundaries on the z-test statistic scale for efficacy stopping up to look L.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value of alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

spendingTime

The error spending time up to look L. Defaults to missing, in which case, it is the same as informationRates.

Value

A data frame with the following components:

  • pvalue: Repeated p-value for rejecting the null hypothesis.

  • thetahat: Point estimate of the parameter.

  • cilevel: Confidence interval level.

  • lower: Lower bound of repeated confidence interval.

  • upper: Upper bound of repeated confidence interval.

Author(s)

Kaifeng Lu, [email protected]

References

Christopher Jennison and Bruce W. Turnbull. Interim analyses: the repeated confidence interval approach (with discussion). J R Stat Soc Series B. 1989;51:305-361.

Examples

# group sequential design with 90% power to detect delta = 6
delta = 6
sigma = 17
n = 282
(des1 = getDesign(IMax = n/(4*sigma^2), theta = delta, kMax = 3,
                  alpha = 0.05, typeAlphaSpending = "sfHSD",
                  parameterAlphaSpending = -4))

# results at the second look
L = 2
n1 = n*2/3
delta1 = 7
sigma1 = 20
zL = delta1/sqrt(4/n1*sigma1^2)

# repeated confidence interval
getRCI(L = L, zL = zL, IMax = n/(4*sigma1^2),
       informationRates = c(1/3, 2/3), alpha = 0.05,
       typeAlphaSpending = "sfHSD", parameterAlphaSpending = -4)

Stanford heart transplant data from the survival package

Description

Survival of patients on the waiting list for the Stanford heart transplant program.

start, stop, event

entry and exit time and status for the time interval

age

age-48 years

year

year of acceptance (in years after Nov 1, 1967)

surgery

prior bypass surgery 1=yes, 0=no

transplant

received transplant 1=yes, 0=no

id

patient id

Usage

heart

Format

An object of class data.frame with 172 rows and 8 columns.


Hedges' g effect size

Description

Obtains Hedges' g estimate and confidence interval of effect size.

Usage

hedgesg(tstat, m, ntilde, cilevel = 0.95)

Arguments

tstat

The value of the t-test statistic for comparing two treatment conditions.

m

The degrees of freedom for the t-test.

ntilde

The normalizing sample size to convert the standardized treatment difference to the t-test statistic, i.e., tstat = sqrt(ntilde)*meanDiff/stDev.

cilevel

The confidence interval level. Defaults to 0.95.

Details

Hedges' gg is an effect size measure commonly used in meta-analysis to quantify the difference between two groups. It's an improvement over Cohen's dd, particularly when dealing with small sample sizes.

The formula for Hedges' gg is

g=c(m)d,g = c(m) d,

where dd is Cohen's dd effect size estimate, and c(m)c(m) is the bias correction factor,

d=(μ^1μ^2)/σ^,d = (\hat{\mu}_1 - \hat{\mu}_2)/\hat{\sigma},

c(m)=134m1.c(m) = 1 - \frac{3}{4m-1}.

Since c(m)<1c(m) < 1, Cohen's dd overestimates the true effect size. δ=(μ1μ2)/σ.\delta = (\mu_1 - \mu_2)/\sigma. Since

t=n~d,t = \sqrt{\tilde{n}} d,

we have

g=c(m)n~t,g = \frac{c(m)}{\sqrt{\tilde{n}}} t,

where tt has a noncentral tt distribution with mm degrees of freedom and noncentrality parameter n~δ\sqrt{\tilde{n}} \delta.

The asymptotic variance of gg can be approximated by

Var(g)=1n~+g22m.Var(g) = \frac{1}{\tilde{n}} + \frac{g^2}{2m}.

The confidence interval for δ\delta can be constructed using normal approximation.

For two-sample mean difference with sample size n1n_1 for the treatment group and n2n_2 for the control group, we have n~=n1n2n1+n2\tilde{n} = \frac{n_1n_2}{n_1+n_2} and m=n1+n22m=n_1+n_2-2 for pooled variance estimate.

Value

A data frame with the following variables:

  • tstat: The value of the t test statistic.

  • m: The degrees of freedom for the t-test.

  • ntilde: The normalizing sample size to convert the standardized treatment difference to the t-test statistic.

  • g: Hedges' g effect size estimate.

  • varg: Variance of g.

  • lower: The lower confidence limit for effect size.

  • upper: The upper confidence limit for effect size.

  • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

References

Larry V. Hedges. Distribution theory for Glass's estimator of effect size and related estimators. Journal of Educational Statistics 1981; 6:107-128.

Examples

n1 = 7
n2 = 8
meanDiff = 0.444
stDev = 1.201
m = n1+n2-2
ntilde = n1*n2/(n1+n2)
tstat = sqrt(ntilde)*meanDiff/stDev

hedgesg(tstat, m, ntilde)

Simulated Concorde trial data from the rpsftm package

Description

Patients were randomly assigned to receive treatment immediately or deferred, and those in the deferred arm could cross over and receive treatment. The primary endpoint was time to disease progression.

id

Patient identification number

def

Indicator that the participant was assigned to the deferred treatment arm

imm

Indicator that the participant was assigned to the immediate treatment arm

censyrs

The censoring time, in years, corresponding to the close of study minus the time of entry for each patient

xo

Indicator that crossover occurred

xoyrs

The time, in years, from entry to switching, or 0 for patients in the immediate arm

prog

Indicator of disease progression (1), or censoring (0)

progyrs

Time, in years, from entry to disease progression or censoring

entry

The time of entry into the study, measured in years from the date of randomisation

Usage

immdef

Format

An object of class data.frame with 1000 rows and 9 columns.


Estimate of milestone survival difference

Description

Obtains the estimate of milestone survival difference between two treatment groups.

Usage

kmdiff(
  data,
  rep = "rep",
  stratum = "stratum",
  treat = "treat",
  time = "time",
  event = "event",
  milestone = NA_real_,
  survDiffH0 = 0,
  confint = 0.95
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • treat: The treatment.

  • time: The possibly right-censored survival time.

  • event: The event indicator.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

treat

The name of the treatment variable in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

milestone

The milestone time at which to calculate the survival probability.

survDiffH0

The difference in milestone survival probabilities under the null hypothesis. Defaults to 0 for superiority test.

confint

The level of the two-sided confidence interval for the difference in milestone survival probabilities. Defaults to 0.95.

Value

A data frame with the following variables:

  • rep: The replication.

  • milestone: The milestone time relative to randomization.

  • survDiffH0: The difference in milestone survival probabilities under the null hypothesis.

  • surv1: The estimated milestone survival probability for the treatment group.

  • surv2: The estimated milestone survival probability for the control group.

  • survDiff: The estimated difference in milestone survival probabilities.

  • vsurv1: The variance for surv1.

  • vsurv2: The variance for surv2.

  • vsurvDiff: The variance for survDiff.

  • survDiffZ: The Z-statistic value.

  • survDiffPValue: The one-sided p-value.

  • lower: The lower bound of confidence interval.

  • upper: The upper bound of confidence interval.

  • confint: The level of confidence interval.

Author(s)

Kaifeng Lu, [email protected]

Examples

df <- kmdiff(data = rawdata, rep = "iterationNumber",
             stratum = "stratum", treat = "treatmentGroup",
             time = "timeUnderObservation", event = "event",
             milestone = 12)
head(df)

Kaplan-Meier estimates of the survival curve

Description

Obtains the Kaplan-Meier estimates of the survival curve.

Usage

kmest(
  data,
  rep = "rep",
  stratum = "stratum",
  time = "time",
  event = "event",
  conftype = "log-log",
  confint = 0.95
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • time: The possibly right-censored survival time.

  • event: The event indicator.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

conftype

The type of confidence interval. One of "none", "plain", "log", "log-log" (the default), or "arcsin". The arcsin option bases the intervals on asin(sqrt(survival)).

confint

The level of the two-sided confidence interval for the survival probabilities. Defaults to 0.95.

Value

A data frame with the following variables:

  • rep: The replication.

  • stratum: The stratum.

  • size: The number of subjects in the stratum.

  • time: The event time.

  • nrisk: The number of subjects at risk.

  • nevent: The number of subjects having the event.

  • survival: The Kaplan-Meier estimate of the survival probability.

  • stderr: The standard error of the estimated survival probability based on the Greendwood formula.

  • lower: The lower bound of confidence interval if requested.

  • upper: The upper bound of confidence interval if requested.

  • confint: The level of confidence interval if requested.

  • conftype: The type of confidence interval if requested.

Author(s)

Kaifeng Lu, [email protected]

Examples

kmest(data = aml, stratum = "x",
      time = "time", event = "status")

Power for difference in milestone survival probabilities

Description

Estimates the power for testing the difference in milestone survival probabilities in a two-sample survival design.

Usage

kmpower(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  milestone = NA_real_,
  survDiffH0 = 0,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

milestone

The milestone time at which to calculate the survival probability.

survDiffH0

The difference in milestone survival probabilities under the null hypothesis. Defaults to 0 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class kmpower object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • drift: The drift parameter, equal to (survDiff - survDiffH0)*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • kMax: The number of stages.

    • milestone: The milestone time relative to randomization.

    • survDiffH0: The difference in milestone survival probabilities under the null hypothesis.

    • surv1: The milestone survival probability for the treatment group.

    • surv2: The milestone survival probability for the control group.

    • survDiff: The difference in milestone survival probabilities, equal to surv1 - surv2.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacySurvDiff: The efficacy boundaries on the survival difference scale.

    • futilitySurvDiff: The futility boundaries on the survival difference scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda1, lambda2, gamma1, gamma2, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survival, and 5% dropout by
# the end of 1 year.

kmpower(kMax = 2, informationRates = c(0.8, 1),
        alpha = 0.025, typeAlphaSpending = "sfOF",
        milestone = 18,
        allocationRatioPlanned = 1, accrualTime = seq(0, 8),
        accrualIntensity = 26/9*seq(1, 9),
        piecewiseSurvivalTime = c(0, 6),
        stratumFraction = c(0.2, 0.8),
        lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
        lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
        gamma1 = -log(1-0.05)/12,
        gamma2 = -log(1-0.05)/12, accrualDuration = 22,
        followupTime = 18, fixedFollowup = FALSE)

Power for one-sample milestone survival probability

Description

Estimates the power, stopping probabilities, and expected sample size in a one-group survival design.

Usage

kmpower1s(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  milestone = NA_real_,
  survH0 = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda = NA_real_,
  gamma = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

milestone

The milestone time at which to calculate the survival probability.

survH0

The milestone survival probability under the null hypothesis.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda

A vector of hazard rates for the event in each analysis time interval by stratum under the alternative hypothesis.

gamma

The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout. Defaults to 0 for no dropout.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class kmpower1s object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • drift: The drift parameter, equal to (surv - survH0)*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • kMax: The number of stages.

    • milestone: The milestone time to calculate the survival probability.

    • survH0: The milestone survival probability under the null hypothesis.

    • surv: The milestone survival probability under the alternative hypothesis.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacySurv: The efficacy boundaries on the milestone survival probability scale.

    • futilitySurv: The futility boundaries on the milestone survival probability scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda, gamma, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

See Also

kmstat

Examples

kmpower1s(kMax = 2, informationRates = c(0.8, 1),
          alpha = 0.025, typeAlphaSpending = "sfOF",
          milestone = 18, survH0 = 0.30,
          accrualTime = seq(0, 8),
          accrualIntensity = 26/9*seq(1, 9),
          piecewiseSurvivalTime = c(0, 6),
          stratumFraction = c(0.2, 0.8),
          lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
          gamma = -log(1-0.05)/12, accrualDuration = 22,
          followupTime = 18, fixedFollowup = FALSE)

Power for equivalence in milestone survival probability difference

Description

Obtains the power for equivalence in milestone survival probability difference.

Usage

kmpowerequiv(
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  milestone = NA_real_,
  survDiffLower = NA_real_,
  survDiffUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

milestone

The milestone time at which to calculate the survival probability.

survDiffLower

The lower equivalence limit of milestone survival probability difference.

survDiffUpper

The upper equivalence limit of milestone survival probability difference.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class kmpowerequiv object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • kMax: The number of stages.

    • milestone: The milestone time relative to randomization.

    • survDiffLower: The lower equivalence limit of milestone survival probability difference.

    • survDiffUpper: The upper equivalence limit of milestone survival probability difference.

    • surv1: The milestone survival probability for the treatment group.

    • surv2: The milestone survival probability for the control group.

    • survDiff: The milestone survival probability difference.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacySurvDiffLower: The efficacy boundaries on the milestone survival probability difference scale for the one-sided null hypothesis at the lower equivalence limit.

    • efficacySurvDiffUpper: The efficacy boundaries on the milestone survival probability difference scale for the one-sided null hypothesis at the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda1, lambda2, gamma1, gamma2, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

See Also

kmstat

Examples

kmpowerequiv(kMax = 2, informationRates = c(0.5, 1),
             alpha = 0.05, typeAlphaSpending = "sfOF",
             milestone = 18,
             survDiffLower = -0.13, survDiffUpper = 0.13,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = 18, fixedFollowup = FALSE)

Sample size for difference in milestone survival probabilities

Description

Obtains the needed accrual duration given power, accrual intensity, and follow-up time, the needed follow-up time given power, accrual intensity, and accrual duration, or the needed absolute accrual intensity given power, relative accrual intensity, accrual duration, and follow-up time in a two-group survival design.

Usage

kmsamplesize(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  milestone = NA_real_,
  survDiffH0 = 0,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

milestone

The milestone time at which to calculate the survival probability.

survDiffH0

The difference in milestone survival probabilities under the null hypothesis. Defaults to 0 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupTime, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

A list of two components:

  • resultsUnderH1: An S3 class kmpower object under the alternative hypothesis.

  • resultsUnderH0: An S3 class kmpower object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

kmpower

Examples

# Example 1: Obtains follow-up time given power, accrual intensity,
# and accrual duration for variable follow-up. Of note, the power
# reaches the maximum when the follow-up time equals milestone.

kmsamplesize(beta = 0.25, kMax = 2, informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             milestone = 18,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = NA, fixedFollowup = FALSE)

# Example 2: Obtains accrual intensity given power, accrual duration, and
# follow-up time for variable follow-up

kmsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             milestone = 18,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = 18, fixedFollowup = FALSE)


# Example 3: Obtains accrual duration given power, accrual intensity, and
# follow-up time for fixed follow-up

kmsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             milestone = 18,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = NA,
             followupTime = 18, fixedFollowup = TRUE)

Sample size for one-sample milestone survival probability

Description

Obtains the needed accrual duration given power and follow-up time, the needed follow-up time given power and accrual duration, or the needed absolute accrual rates given power, accrual duration, follow-up duration, and relative accrual rates in a one-group survival design.

Usage

kmsamplesize1s(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  milestone = NA_real_,
  survH0 = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda = NA_real_,
  gamma = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

milestone

The milestone time at which to calculate the survival probability.

survH0

The milestone survival probability under the null hypothesis.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda

A vector of hazard rates for the event in each analysis time interval by stratum under the alternative hypothesis.

gamma

The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout. Defaults to 0 for no dropout.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

A list of two components:

  • resultsUnderH1: An S3 class kmpower1s object under the alternative hypothesis.

  • resultsUnderH0: An S3 class kmpower1s object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

kmpower1s

Examples

# Example 1: Obtains follow-up duration given power, accrual intensity,
# and accrual duration for variable follow-up

kmsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.8, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               milestone = 18, survH0 = 0.30,
               accrualTime = seq(0, 8),
               accrualIntensity = 26/9*seq(1, 9),
               piecewiseSurvivalTime = c(0, 6),
               stratumFraction = c(0.2, 0.8),
               lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
               gamma = -log(1-0.05)/12, accrualDuration = 22,
               followupTime = NA, fixedFollowup = FALSE)

# Example 2: Obtains accrual intensity given power, accrual duration, and
# follow-up duration for variable follow-up

kmsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.8, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               milestone = 18, survH0 = 0.30,
               accrualTime = seq(0, 8),
               accrualIntensity = 26/9*seq(1, 9),
               piecewiseSurvivalTime = c(0, 6),
               stratumFraction = c(0.2, 0.8),
               lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
               gamma = -log(1-0.05)/12, accrualDuration = 22,
               followupTime = 18, fixedFollowup = FALSE)


# Example 3: Obtains accrual duration given power, accrual intensity, and
# follow-up duration for fixed follow-up

kmsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.8, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               milestone = 18, survH0 = 0.30,
               accrualTime = seq(0, 8),
               accrualIntensity = 26/9*seq(1, 9),
               piecewiseSurvivalTime = c(0, 6),
               stratumFraction = c(0.2, 0.8),
               lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
               gamma = -log(1-0.05)/12, accrualDuration = NA,
               followupTime = 18, fixedFollowup = TRUE)

Sample size for equivalence in milestone survival probability difference

Description

Obtains the sample size for equivalence in milestone survival probability difference.

Usage

kmsamplesizeequiv(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  milestone = NA_real_,
  survDiffLower = NA_real_,
  survDiffUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

The type II error.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

milestone

The milestone time at which to calculate the survival probability.

survDiffLower

The lower equivalence limit of milestone survival probability difference.

survDiffUpper

The upper equivalence limit of milestone survival probability difference.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

An S3 class kmpowerequiv object

Author(s)

Kaifeng Lu, [email protected]

See Also

kmpowerequiv

Examples

kmsamplesizeequiv(beta = 0.1, kMax = 2, informationRates = c(0.5, 1),
                  alpha = 0.05, typeAlphaSpending = "sfOF",
                  milestone = 18,
                  survDiffLower = -0.13, survDiffUpper = 0.13,
                  allocationRatioPlanned = 1, accrualTime = seq(0, 8),
                  accrualIntensity = 26/9*seq(1, 9),
                  piecewiseSurvivalTime = c(0, 6),
                  stratumFraction = c(0.2, 0.8),
                  lambda1 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
                  lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
                  gamma1 = -log(1-0.05)/12,
                  gamma2 = -log(1-0.05)/12, accrualDuration = NA,
                  followupTime = 18, fixedFollowup = FALSE)

Stratified difference in milestone survival probabilities

Description

Obtains the stratified milestone survival probabilities and difference in milestone survival probabilities at given calendar times.

Usage

kmstat(
  time = NA_real_,
  milestone = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L
)

Arguments

time

A vector of calendar times for data cut.

milestone

The milestone time at which to calculate the survival probability.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

Value

A data frame containing the following variables:

  • time: The calendar time since trial start.

  • subjects: The number of enrolled subjects.

  • milestone: The milestone time relative to randomization.

  • surv1: The milestone survival probability for the treatment group.

  • surv2: The milestone survival probability for the control group.

  • survDiff: The difference in milestone survival probabilities, i.e., surv1 - surv2.

  • vsurv1: The variance for surv1.

  • vsurv2: The variance for surv2.

  • vsurvDiff: The variance for survDiff.

  • information: The information for survDiff, equal to 1/vsurvDiff.

  • survDiffZ: The Z-statistic value, i.e., survDiff/sqrt(vsurvDiff).

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survivals, and 5% dropout by
# the end of 1 year.

kmstat(time = c(22, 40),
       milestone = 18,
       allocationRatioPlanned = 1,
       accrualTime = seq(0, 8),
       accrualIntensity = 26/9*seq(1, 9),
       piecewiseSurvivalTime = c(0, 6),
       stratumFraction = c(0.2, 0.8),
       lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
       lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
       gamma1 = -log(1-0.05)/12,
       gamma2 = -log(1-0.05)/12,
       accrualDuration = 22,
       followupTime = 18, fixedFollowup = FALSE)

Parametric regression models for failure time data

Description

Obtains the parameter estimates from parametric regression models with uncensored, right censored, left censored, or interval censored data.

Usage

liferegr(
  data,
  rep = "rep",
  stratum = "stratum",
  time = "time",
  time2 = "time2",
  event = "event",
  covariates = "treat",
  weight = "weight",
  id = "id",
  dist = "weibull",
  robust = 0L
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • time: The follow-up time for right censored data, or the left end of each interval for interval censored data.

  • time2: The right end of each interval for interval censored data.

  • event: The event indicator, normally 1=event, 0=no event.

  • covariates: The values of baseline covariates. This is the full-rank design matrix (excluding the intercept) for the regression model, assuming that factor variables have already been expanded into dummy variables. The intercept will be added automatically.

  • weight: The weight for each observation.

  • id: The optional subject ID to group the score residuals in computing the robust sandwich variance.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

time

The name of the time variable or the left end of each interval for interval censored data in the input data.

time2

The name of the right end of each interval for interval censored data in the input data.

event

The name of the event variable in the input data for right censored data.

covariates

The vector of names of baseline covariates in the input data.

weight

The name of the weighting variable in the input data.

id

The name of the id variable in the input data.

dist

The assumed distribution for time to event. Options include "exponential", "weibull", "lognormal", and "loglogistic" to be modeled on the log-scale, and "normal" and "logistic" to be modeled on the original scale.

robust

Whether a robust sandwich variance estimate should be computed. The default is TRUE if there are fractional weights or there is at least 1 id with >1 event. In the presence of the id variable, the score residual will be aggregated for each id when computing the robust sandwich variance estimate.

Details

There are two ways to specify the model, one for right censored data through the time and event variables, and the other for interval censored data through the time and time2 variables. For the second form, we follow the convention used in SAS PROC LIFEREG:

  • If lower is not missing, upper is not missing, and lower is equal to upper, then there is no censoring and the event occurred at time lower.

  • If lower is not missing, upper is not missing, and lower < upper, then the event time is censored within the interval (lower, upper).

  • If lower is missing, but upper is not missing, then upper will be used as the left censoring value.

  • If lower is not missing, but upper is missing, then lower will be used as the right censoring value.

  • If lower is not missing, upper is not missing, but lower > upper, or if both lower and upper are missing, then the observation will not be used.

Value

A list with the following components:

  • sumstat: The data frame of summary statistics of model fit with the following variables:

    • rep: The replication.

    • n: The number of observations.

    • nevents: The number of events.

    • loglik0: The log-likelihood under null.

    • loglik1: The maximum log-likelihood.

    • scoretest: The score test statistic.

  • parest: The data frame of parameter estimates with the following variables:

    • rep: The replication.

    • param: The name of the covariate for the parameter estimate.

    • beta: The parameter estimate.

    • sebeta: The standard error of parameter estimate.

    • z: The Wald test statistic.

    • expbeta: The exponentiated parameter.

    • vbeta: The covariance matrix for parameter estimates.

Author(s)

Kaifeng Lu, [email protected]

Examples

library(dplyr)

# right censored data
liferegr(data = rawdata %>% mutate(treat = 1*(treatmentGroup == 1)),
         rep = "iterationNumber", stratum = "stratum",
         time = "timeUnderObservation", event = "event",
         covariates = "treat", dist = "weibull")

# tobit regression for left censored data
liferegr(data = tobin %>% mutate(time = ifelse(durable>0, durable, NA)),
         time = "time", time2 = "durable",
         covariates = c("age", "quant"), dist = "normal")

Log-rank test power

Description

Estimates the power, stopping probabilities, and expected sample size in a two-group survival design.

Usage

lrpower(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  hazardRatioH0 = 1,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  numSubintervals = 300L,
  estimateHazardRatio = 1L,
  typeOfComputation = "direct",
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates in terms of number of events for the conventional log-rank test and in terms of the actual information for weighted log-rank tests. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

hazardRatioH0

Hazard ratio under the null hypothesis for the active treatment versus control. Defaults to 1 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

numSubintervals

Number of sub-intervals to approximate the mean and variance of the weighted log-rank test score statistic. Defaults to 300. Specify a larger number for better approximation.

estimateHazardRatio

Whether to estimate the hazard ratio from weighted Cox regression model and report the stopping boundaries on the hazard ratio scale.

typeOfComputation

The type of computation, either "direct" for the direct approximation method, or "schoenfeld" for the Schoenfeld method. Defaults to "direct". Can use "Schoenfeld" under proportional hazards and conventional log-rank test.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class lrpower object with 4 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • numberOfEvents: The total number of events.

    • numberOfDropouts: The total number of dropouts.

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfEvents: The expected number of events.

    • expectedNumberOfDropouts: The expected number of dropouts.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up time.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • rho1: The first parameter of the Fleming-Harrington family of weighted log-rank test.

    • rho2: The second parameter of the Fleming-Harrington family of weighted log-rank test.

    • kMax: The number of stages.

    • hazardRatioH0: The hazard ratio under the null hypothesis.

    • typeOfComputation: The type of computation, either "direct" for the direct approximation method, or "schoenfeld" for the Schoenfeld method.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfEvents: The number of events.

    • numberOfDropouts: The number of dropouts.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacyHR: The efficacy boundaries on the hazard ratio scale if estimateHazardRatio.

    • futilityHR: The futility boundaries on the hazard ratio scale if estimateHazardRatio.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • HR: The average hazard ratio.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda1, lambda2, gamma1, gamma2, estimateHazardRatio, and spendingTime.

  • byTreatmentCounts: A list containing the following counts by treatment group:

    • numberOfEvents1: The number of events by stage for the treatment group.

    • numberOfDropouts1: The number of dropouts by stage for the treatment group.

    • numberOfSubjects1: The number of subjects by stage for the treatment group.

    • numberOfEvents2: The number of events by stage for the control group.

    • numberOfDropouts2: The number of dropouts by stage for the control group.

    • numberOfSubjects2: The number of subjects by stage for the control group.

    • expectedNumberOfEvents1: The expected number of events for the treatment group.

    • expectedNumberOfDropouts1: The expected number of dropouts for the treatment group.

    • expectedNumberOfSubjects1: The expected number of subjects for the treatment group.

    • expectedNumberOfEvents2: The expected number of events for control group.

    • expectedNumberOfDropouts2: The expected number of dropouts for the control group.

    • expectedNumberOfSubjects2: The expected number of subjects for the control group.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survival, and 5% dropout by
# the end of 1 year.

lrpower(kMax = 2, informationRates = c(0.8, 1),
        alpha = 0.025, typeAlphaSpending = "sfOF",
        allocationRatioPlanned = 1, accrualTime = seq(0, 8),
        accrualIntensity = 26/9*seq(1, 9),
        piecewiseSurvivalTime = c(0, 6),
        stratumFraction = c(0.2, 0.8),
        lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
        lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
        gamma1 = -log(1-0.05)/12,
        gamma2 = -log(1-0.05)/12, accrualDuration = 22,
        followupTime = 18, fixedFollowup = FALSE)

Power for equivalence in hazard ratio

Description

Obtains the power for equivalence in hazard ratio.

Usage

lrpowerequiv(
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  hazardRatioLower = NA_real_,
  hazardRatioUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  typeOfComputation = "direct",
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

hazardRatioLower

The lower equivalence limit of hazard ratio.

hazardRatioUpper

The upper equivalence limit of hazard ratio.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

typeOfComputation

The type of computation, either "direct" for the direct approximation method, or "schoenfeld" for the Schoenfeld method. Defaults to "direct". Can use "Schoenfeld" under proportional hazards and conventional log-rank test.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class lrpowerequiv object with 4 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • numberOfEvents: The total number of events.

    • numberOfDropouts: The total number of dropouts.

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfEvents: The expected number of events.

    • expectedNumberOfDropouts: The expected number of dropouts.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • kMax: The number of stages.

    • hazardRatioLower: The lower equivalence limit of hazard ratio.

    • hazardRatioUpper: The upper equivalence limit of hazard ratio.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up time.

    • fixedFollowup: Whether a fixed follow-up design is used.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • numberOfEvents: The number of events.

    • numberOfDropouts: The number of dropouts.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacyHRLower: The efficacy boundaries on the hazard ratio scale for the one-sided null hypothesis at the lower equivalence limit.

    • efficacyHRUpper: The efficacy boundaries on the hazard ratio scale for the one-sided null hypothesis at the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

    • HR: The average hazard ratio.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda1, lambda2, gamma1, gamma2, typeOfComputation, and spendingTime.

  • byTreatmentCounts: A list containing the following counts by treatment group:

    • numberOfEvents1: The number of events by stage for the treatment group.

    • numberOfDropouts1: The number of dropouts by stage for the treatment group.

    • numberOfSubjects1: The number of subjects by stage for the treatment group.

    • numberOfEvents2: The number of events by stage for the control group.

    • numberOfDropouts2: The number of dropouts by stage for the control group.

    • numberOfSubjects2: The number of subjects by stage for the control group.

    • expectedNumberOfEvents1: The expected number of events for the treatment group.

    • expectedNumberOfDropouts1: The expected number of dropouts for the treatment group.

    • expectedNumberOfSubjects1: The expected number of subjects for the treatment group.

    • expectedNumberOfEvents2: The expected number of events for control group.

    • expectedNumberOfDropouts2: The expected number of dropouts for the control group.

    • expectedNumberOfSubjects2: The expected number of subjects for the control group.

Author(s)

Kaifeng Lu, [email protected]

See Also

rmstat

Examples

lrpowerequiv(kMax = 2, informationRates = c(0.5, 1),
             alpha = 0.05, typeAlphaSpending = "sfOF",
             hazardRatioLower = 0.71, hazardRatioUpper = 1.4,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 100/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = 18, fixedFollowup = FALSE)

Log-rank test sample size

Description

Obtains the needed accrual duration given power and follow-up time, the needed follow-up time given power and accrual duration, or the needed absolute accrual rates given power, accrual duration, follow-up time, and relative accrual rates in a two-group survival design.

Usage

lrsamplesize(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  hazardRatioH0 = 1,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  numSubintervals = 300L,
  estimateHazardRatio = 1L,
  typeOfComputation = "direct",
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates in terms of number of events for the conventional log-rank test and in terms of the actual information for weighted log-rank tests. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

hazardRatioH0

Hazard ratio under the null hypothesis for the active treatment versus control. Defaults to 1 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

numSubintervals

Number of sub-intervals to approximate the mean and variance of the weighted log-rank test score statistic. Defaults to 300. Specify a larger number for better approximation.

estimateHazardRatio

Whether to estimate the hazard ratio from weighted Cox regression model and report the stopping boundaries on the hazard ratio scale.

typeOfComputation

The type of computation, either "direct" for the direct approximation method, or "schoenfeld" for the Schoenfeld method. Defaults to "direct". Can use "Schoenfeld" under proportional hazards and conventional log-rank test.

interval

The interval to search for the solution of accrualDuration, followupTime, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240). Adjustment may be needed for non-monotone relationship with study power.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size and events. Defaults to 1 for sample size rounding.

Value

A list of two components:

  • resultsUnderH1: An S3 class lrpower object under the alternative hypothesis.

  • resultsUnderH0: An S3 class lrpower object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

lrpower

Examples

# Piecewise accrual, piecewise exponential survival, and 5% dropout by
# the end of 1 year.

# Example 1: Obtains accrual duration given power and follow-up time

lrsamplesize(beta = 0.2, kMax = 2,
             informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12,
             accrualDuration = NA,
             followupTime = 18, fixedFollowup = FALSE)


# Example 2: Obtains follow-up time given power and accrual duration

lrsamplesize(beta = 0.2, kMax = 2,
             informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12,
             accrualDuration = 22,
             followupTime = NA, fixedFollowup = FALSE)


# Example 3: Obtains absolute accrual intensity given power,
# accrual duration, follow-up time, and relative accrual intensity

lrsamplesize(beta = 0.2, kMax = 2,
             informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             accrualTime = seq(0, 8),
             accrualIntensity = 26/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12,
             accrualDuration = 22,
             followupTime = 18, fixedFollowup = FALSE)

Sample size for equivalence in hazard ratio

Description

Obtains the sample size for equivalence in hazard ratio.

Usage

lrsamplesizeequiv(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  hazardRatioLower = NA_real_,
  hazardRatioUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  typeOfComputation = "direct",
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

The type II error.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

hazardRatioLower

The lower equivalence limit of hazard ratio.

hazardRatioUpper

The upper equivalence limit of hazard ratio.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

typeOfComputation

The type of computation, either "direct" for the direct approximation method, or "schoenfeld" for the Schoenfeld method. Defaults to "direct". Can use "Schoenfeld" under proportional hazards and conventional log-rank test.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

An S3 class lrpowerequiv object

Author(s)

Kaifeng Lu, [email protected]

See Also

lrpowerequiv

Examples

lrsamplesizeequiv(kMax = 2, informationRates = c(0.5, 1),
                  alpha = 0.05, typeAlphaSpending = "sfOF",
                  hazardRatioLower = 0.71, hazardRatioUpper = 1.4,
                  allocationRatioPlanned = 1, accrualTime = seq(0, 8),
                  accrualIntensity = 26/9*seq(1, 9),
                  piecewiseSurvivalTime = c(0, 6),
                  stratumFraction = c(0.2, 0.8),
                  lambda1 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
                  lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
                  gamma1 = -log(1-0.05)/12,
                  gamma2 = -log(1-0.05)/12, accrualDuration = NA,
                  followupTime = 18, fixedFollowup = FALSE)

Log-rank test simulation

Description

Performs simulation for two-arm group sequential trials based on weighted log-rank test.

Usage

lrsim(
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  futilityBounds = NA_real_,
  hazardRatioH0 = 1,
  allocation1 = 1L,
  allocation2 = 1L,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  plannedEvents = NA_integer_,
  plannedTime = NA_real_,
  maxNumberOfIterations = 1000L,
  maxNumberOfRawDatasetsPerStage = 0L,
  seed = NA_integer_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates in terms of number of events for the conventional log-rank test and in terms of the actual information for weighted log-rank tests. Fixed prior to the trial. If left unspecified, it defaults to plannedEvents / plannedEvents[kMax] when plannedEvents is provided and to plannedTime / plannedTime[kMax] otherwise.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

hazardRatioH0

Hazard ratio under the null hypothesis for the active treatment versus control. Defaults to 1 for superiority test.

allocation1

Number of subjects in the active treatment group in a randomization block. Defaults to 1 for equal randomization.

allocation2

Number of subjects in the control group in a randomization block. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

plannedEvents

The planned cumulative total number of events at each stage.

plannedTime

The calendar times for the analyses. To use calendar time to plan the analyses, plannedEvents should be missing.

maxNumberOfIterations

The number of simulation iterations. Defaults to 1000.

maxNumberOfRawDatasetsPerStage

The number of raw datasets per stage to extract.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified,

Value

An S3 class lrsim object with 3 components:

  • overview: A list containing the following information:

    • rejectPerStage: The efficacy stopping probability by stage.

    • futilityPerStage: The futility stopping probability by stage.

    • cumulativeRejection: Cumulative efficacy stopping probability by stage.

    • cumulativeFutility: The cumulative futility stopping probability by stage.

    • numberOfEvents: The average number of events by stage.

    • numberOfDropouts: The average number of dropouts by stage.

    • numberOfSubjects: The average number of subjects by stage.

    • analysisTime: The average analysis time by stage.

    • overallReject: The overall rejection probability.

    • expectedNumberOfEvents: The expected number of events for the overall study.

    • expectedNumberOfDropouts: The expected number of dropouts for the overall study.

    • expectedNumberOfSubjects: The expected number of subjects for the overall study.

    • expectedStudyDuration: The expected study duration.

    • hazardRatioH0: Hazard ratio under the null hypothesis for the active treatment versus control.

    • useEvents: whether the analyses are planned based on the number of events or calendar time.

    • accrualDuration: Duration of the enrollment period.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • rho1: The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

    • rho2: The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

    • kMax: The maximum number of stages.

  • sumdata: A data frame of summary data by iteration and stage:

    • iterationNumber: The iteration number.

    • stopStage: The stage at which the trial stops.

    • eventsNotAchieved: Whether the target number of events is not achieved for the iteration.

    • stageNumber: The stage number, covering all stages even if the trial stops at an interim look.

    • analysisTime: The time for the stage since trial start.

    • accruals1: The number of subjects enrolled at the stage for the treatment group.

    • accruals2: The number of subjects enrolled at the stage for the control group.

    • totalAccruals: The total number of subjects enrolled at the stage.

    • events1: The number of events at the stage for the treatment group.

    • events2: The number of events at the stage for the control group.

    • totalEvents: The total number of events at the stage.

    • dropouts1: The number of dropouts at the stage for the treatment group.

    • dropouts2: The number of dropouts at the stage for the control group.

    • totalDropouts: The total number of dropouts at the stage.

    • uscore: The numerator of the log-rank test statistic.

    • vscore: The variance of the log-rank test statistic.

    • logRankStatistic: The log-rank test Z-statistic.

    • rejectPerStage: Whether to reject the null hypothesis at the stage.

    • futilityPerStage: Whether to stop the trial for futility at the stage.

  • rawdata (exists if maxNumberOfRawDatasetsPerStage is a positive integer): A data frame for subject-level data for selected replications, containing the following variables:

    • iterationNumber: The iteration number.

    • stopStage: The stage at which the trial stops.

    • analysisTime: The time for the stage since trial start.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • treatmentGroup: The treatment group (1 or 2) for the subject.

    • survivalTime: The underlying survival time for the subject.

    • dropoutTime: The underlying dropout time for the subject.

    • timeUnderObservation: The time under observation since randomization.

    • event: Whether the subject experienced the event.

    • dropoutEvent: Whether the subject dropped out.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: analyses based on number of events

sim1 = lrsim(kMax = 2, informationRates = c(0.5, 1),
             criticalValues = c(2.797, 1.977),
             accrualIntensity = 11,
             lambda1 = 0.018, lambda2 = 0.030,
             accrualDuration = 12,
             plannedEvents = c(60, 120),
             maxNumberOfIterations = 1000,
             maxNumberOfRawDatasetsPerStage = 1,
             seed = 314159)

# summary statistics
sim1

# summary for each simulated data set
head(sim1$sumdata)

# raw data for selected replication
head(sim1$rawdata)


# Example 2: analyses based on calendar time have similar power

sim2 = lrsim(kMax = 2, informationRates = c(0.5, 1),
             criticalValues = c(2.797, 1.977),
             accrualIntensity = 11,
             lambda1 = 0.018, lambda2 = 0.030,
             accrualDuration = 12,
             plannedTime = c(31.9, 113.2),
             maxNumberOfIterations = 1000,
             maxNumberOfRawDatasetsPerStage = 1,
             seed = 314159)

# summary statistics
sim2

# summary for each simulated data set
head(sim2$sumdata)

Log-rank test simulation for two endpoints

Description

Performs simulation for two-endpoint two-arm group sequential trials based on weighted log-rank test. The first kMaxe1 looks are driven by the total number of PFS events in two arms combined, and the subsequent looks are driven by the total number of OS events in two arms combined. Alternatively, the analyses can be planned to occur at specified calendar times.

Usage

lrsim2e(
  kMax = NA_integer_,
  kMaxe1 = NA_integer_,
  hazardRatioH0e1 = 1,
  hazardRatioH0e2 = 1,
  allocation1 = 1L,
  allocation2 = 1L,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  rho = 0,
  lambda1e1 = NA_real_,
  lambda2e1 = NA_real_,
  lambda1e2 = NA_real_,
  lambda2e2 = NA_real_,
  gamma1e1 = 0L,
  gamma2e1 = 0L,
  gamma1e2 = 0L,
  gamma2e2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  plannedEvents = NA_integer_,
  plannedTime = NA_real_,
  maxNumberOfIterations = 1000L,
  maxNumberOfRawDatasetsPerStage = 0L,
  seed = NA_integer_
)

Arguments

kMax

The maximum number of stages.

kMaxe1

Number of stages with timing determined by PFS events. Ranges from 0 (none) to kMax.

hazardRatioH0e1

Hazard ratio under the null hypothesis for the active treatment vs control for endpoint 1 (PFS). Defaults to 1 for superiority test.

hazardRatioH0e2

Hazard ratio under the null hypothesis for the active treatment vs control for endpoint 2 (OS). Defaults to 1 for superiority test.

allocation1

Number of subjects in the treatment group in a randomization block. Defaults to 1 for equal randomization.

allocation2

Number of subjects in the control group in a randomization block. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

rho

The correlation coefficient for the standard bivariate normal random variables used to generate time to disease progression and time to death using the inverse CDF method.

lambda1e1

A vector of hazard rates for the event in each analysis time interval by stratum for the treatment group and endpoint 1 (PFS).

lambda2e1

A vector of hazard rates for the event in each analysis time interval by stratum for the control group and endpoint 1 (PFS).

lambda1e2

A vector of hazard rates for the event in each analysis time interval by stratum for the treatment group and endpoint 2 (OS).

lambda2e2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group and endpoint 2 (OS).

gamma1e1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the treatment group and endpoint 1 (PFS).

gamma2e1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group and endpoint 1 (PFS).

gamma1e2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the treatment group and endpoint 2 (OS).

gamma2e2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group and endpoint 2 (OS).

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

plannedEvents

The planned cumulative total number of PFS events at Look 1 to Look kMaxe1 and the planned cumulative total number of OS events at Look kMaxe1+1 to Look kMax.

plannedTime

The calendar times for the analyses. To use calendar time to plan the analyses, plannedEvents should be missing.

maxNumberOfIterations

The number of simulation iterations. Defaults to 1000.

maxNumberOfRawDatasetsPerStage

The number of raw datasets per stage to extract.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified,

Value

A list with 2 components:

  • sumdata: A data frame of summary data by iteration and stage:

    • iterationNumber: The iteration number.

    • eventsNotAchieved: Whether the target number of events is not achieved for the iteration.

    • stageNumber: The stage number, covering all stages even if the trial stops at an interim look.

    • analysisTime: The time for the stage since trial start.

    • accruals1: The number of subjects enrolled at the stage for the treatment group.

    • accruals2: The number of subjects enrolled at the stage for the control group.

    • totalAccruals: The total number of subjects enrolled at the stage.

    • endpoint: The endpoint (1 or 2) under consideration.

    • events1: The number of events at the stage for the treatment group.

    • events2: The number of events at the stage for the control group.

    • totalEvents: The total number of events at the stage.

    • dropouts1: The number of dropouts at the stage for the treatment group.

    • dropouts2: The number of dropouts at the stage for the control group.

    • totalDropouts: The total number of dropouts at the stage.

    • logRankStatistic: The log-rank test Z-statistic for the endpoint.

  • rawdata (exists if maxNumberOfRawDatasetsPerStage is a positive integer): A data frame for subject-level data for selected replications, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage under consideration.

    • analysisTime: The time for the stage since trial start.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • treatmentGroup: The treatment group (1 or 2) for the subject.

    • survivalTime1: The underlying survival time for event endpoint 1 for the subject.

    • dropoutTime1: The underlying dropout time for event endpoint 1 for the subject.

    • timeUnderObservation1: The time under observation since randomization for event endpoint 1 for the subject.

    • event1: Whether the subject experienced event endpoint 1.

    • dropoutEvent1: Whether the subject dropped out for endpoint 1.

    • survivalTime2: The underlying survival time for event endpoint 2 for the subject.

    • dropoutTime2: The underlying dropout time for event endpoint 2 for the subject.

    • timeUnderObservation2: The time under observation since randomization for event endpoint 2 for the subject.

    • event2: Whether the subject experienced event endpoint 2.

    • dropoutEvent2: Whether the subject dropped out for endpoint 2.

Author(s)

Kaifeng Lu, [email protected]

Examples

sim1 = lrsim2e(
  kMax = 3,
  kMaxe1 = 2,
  allocation1 = 2,
  allocation2 = 1,
  accrualTime = c(0, 8),
  accrualIntensity = c(10, 28),
  piecewiseSurvivalTime = 0,
  rho = 0,
  lambda1e1 = log(2)/12*0.60,
  lambda2e1 = log(2)/12,
  lambda1e2 = log(2)/30*0.65,
  lambda2e2 = log(2)/30,
  accrualDuration = 20.143,
  plannedEvents = c(186, 259, 183),
  maxNumberOfIterations = 1000,
  maxNumberOfRawDatasetsPerStage = 1,
  seed = 314159)

head(sim1$sumdata)
head(sim1$rawdata)

Log-rank test simulation for two endpoints and three arms

Description

Performs simulation for two-endpoint three-arm group sequential trials based on weighted log-rank test. The first kMaxe1 looks are driven by the total number of PFS events in Arm A and Arm C combined, and the subsequent looks are driven by the total number of OS events in Arm A and Arm C combined. Alternatively, the analyses can be planned to occur at specified calendar times.

Usage

lrsim2e3a(
  kMax = NA_integer_,
  kMaxe1 = NA_integer_,
  hazardRatioH013e1 = 1,
  hazardRatioH023e1 = 1,
  hazardRatioH012e1 = 1,
  hazardRatioH013e2 = 1,
  hazardRatioH023e2 = 1,
  hazardRatioH012e2 = 1,
  allocation1 = 1L,
  allocation2 = 1L,
  allocation3 = 1L,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  rho = 0,
  lambda1e1 = NA_real_,
  lambda2e1 = NA_real_,
  lambda3e1 = NA_real_,
  lambda1e2 = NA_real_,
  lambda2e2 = NA_real_,
  lambda3e2 = NA_real_,
  gamma1e1 = 0L,
  gamma2e1 = 0L,
  gamma3e1 = 0L,
  gamma1e2 = 0L,
  gamma2e2 = 0L,
  gamma3e2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  plannedEvents = NA_integer_,
  plannedTime = NA_real_,
  maxNumberOfIterations = 1000L,
  maxNumberOfRawDatasetsPerStage = 0L,
  seed = NA_integer_
)

Arguments

kMax

The maximum number of stages.

kMaxe1

Number of stages with timing determined by PFS events. Ranges from 0 (none) to kMax.

hazardRatioH013e1

Hazard ratio under the null hypothesis for arm 1 vs arm 3 for endpoint 1 (PFS). Defaults to 1 for superiority test.

hazardRatioH023e1

Hazard ratio under the null hypothesis for arm 2 vs arm 3 for endpoint 1 (PFS). Defaults to 1 for superiority test.

hazardRatioH012e1

Hazard ratio under the null hypothesis for arm 1 vs arm 2 for endpoint 1 (PFS). Defaults to 1 for superiority test.

hazardRatioH013e2

Hazard ratio under the null hypothesis for arm 1 vs arm 3 for endpoint 2 (OS). Defaults to 1 for superiority test.

hazardRatioH023e2

Hazard ratio under the null hypothesis for arm 2 vs arm 3 for endpoint 2 (OS). Defaults to 1 for superiority test.

hazardRatioH012e2

Hazard ratio under the null hypothesis for arm 1 vs arm 2 for endpoint 2 (OS). Defaults to 1 for superiority test.

allocation1

Number of subjects in Arm A in a randomization block. Defaults to 1 for equal randomization.

allocation2

Number of subjects in Arm B in a randomization block. Defaults to 1 for equal randomization.

allocation3

Number of subjects in Arm C in a randomization block. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

rho

The correlation coefficient for the standard bivariate normal random variables used to generate time to disease progression and time to death using the inverse CDF method.

lambda1e1

A vector of hazard rates for the event in each analysis time interval by stratum for arm 1 and endpoint 1 (PFS).

lambda2e1

A vector of hazard rates for the event in each analysis time interval by stratum for arm 2 and endpoint 1 (PFS).

lambda3e1

A vector of hazard rates for the event in each analysis time interval by stratum for arm 3 and endpoint 1 (PFS).

lambda1e2

A vector of hazard rates for the event in each analysis time interval by stratum for arm 1 and endpoint 2 (OS).

lambda2e2

A vector of hazard rates for the event in each analysis time interval by stratum for arm 2 and endpoint 2 (OS).

lambda3e2

A vector of hazard rates for the event in each analysis time interval by stratum for arm 3 and endpoint 2 (OS).

gamma1e1

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 1 and endpoint 1 (PFS).

gamma2e1

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 2 and endpoint 1 (PFS).

gamma3e1

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 3 and endpoint 1 (PFS).

gamma1e2

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 1 and endpoint 2 (OS).

gamma2e2

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 2 and endpoint 2 (OS).

gamma3e2

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 3 and endpoint 2 (OS).

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

plannedEvents

The planned cumulative total number of PFS events at Look 1 to Look kMaxe1 for Arms A and C combined and the planned cumulative total number of OS events at Look kMaxe1+1 to Look kMax for Arms A and C combined.

plannedTime

The calendar times for the analyses. To use calendar time to plan the analyses, plannedEvents should be missing.

maxNumberOfIterations

The number of simulation iterations. Defaults to 1000.

maxNumberOfRawDatasetsPerStage

The number of raw datasets per stage to extract.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified,

Value

A list with 2 components:

  • sumdata: A data frame of summary data by iteration and stage:

    • iterationNumber: The iteration number.

    • eventsNotAchieved: Whether the target number of events is not achieved for the iteration.

    • stageNumber: The stage number, covering all stages even if the trial stops at an interim look.

    • analysisTime: The time for the stage since trial start.

    • accruals1: The number of subjects enrolled at the stage for the active treatment 1 group.

    • accruals2: The number of subjects enrolled at the stage for the active treatment 2 group.

    • accruals3: The number of subjects enrolled at the stage for the control group.

    • totalAccruals: The total number of subjects enrolled at the stage.

    • endpoint: The endpoint (1 or 2) under consideration.

    • events1: The number of events at the stage for the active treatment 1 group.

    • events2: The number of events at the stage for the active treatment 2 group.

    • events3: The number of events at the stage for the control group.

    • totalEvents: The total number of events at the stage.

    • dropouts1: The number of dropouts at the stage for the active treatment 1 group.

    • dropouts2: The number of dropouts at the stage for the active treatment 2 group.

    • dropouts3: The number of dropouts at the stage for the control group.

    • totalDropouts: The total number of dropouts at the stage.

    • logRankStatistic13: The log-rank test Z-statistic comparing the active treatment 1 to the control for the endpoint.

    • logRankStatistic23: The log-rank test Z-statistic comparing the active treatment 2 to the control for the endpoint.

    • logRankStatistic12: The log-rank test Z-statistic comparing the active treatment 1 to the active treatment 2 for the endpoint.

  • rawdata (exists if maxNumberOfRawDatasetsPerStage is a positive integer): A data frame for subject-level data for selected replications, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage under consideration.

    • analysisTime: The time for the stage since trial start.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • treatmentGroup: The treatment group (1, 2, or 3) for the subject.

    • survivalTime1: The underlying survival time for event endpoint 1 for the subject.

    • dropoutTime1: The underlying dropout time for event endpoint 1 for the subject.

    • timeUnderObservation1: The time under observation since randomization for event endpoint 1 for the subject.

    • event1: Whether the subject experienced event endpoint 1.

    • dropoutEvent1: Whether the subject dropped out for endpoint 1.

    • survivalTime2: The underlying survival time for event endpoint 2 for the subject.

    • dropoutTime2: The underlying dropout time for event endpoint 2 for the subject.

    • timeUnderObservation2: The time under observation since randomization for event endpoint 2 for the subject.

    • event2: Whether the subject experienced event endpoint 2.

    • dropoutEvent2: Whether the subject dropped out for endpoint 2.

Author(s)

Kaifeng Lu, [email protected]

Examples

sim1 = lrsim2e3a(
  kMax = 3,
  kMaxe1 = 2,
  allocation1 = 2,
  allocation2 = 2,
  allocation3 = 1,
  accrualTime = c(0, 8),
  accrualIntensity = c(10, 28),
  piecewiseSurvivalTime = 0,
  rho = 0,
  lambda1e1 = log(2)/12*0.60,
  lambda2e1 = log(2)/12*0.70,
  lambda3e1 = log(2)/12,
  lambda1e2 = log(2)/30*0.65,
  lambda2e2 = log(2)/30*0.75,
  lambda3e2 = log(2)/30,
  accrualDuration = 30.143,
  plannedEvents = c(186, 259, 183),
  maxNumberOfIterations = 1000,
  maxNumberOfRawDatasetsPerStage = 1,
  seed = 314159)

head(sim1$sumdata)
head(sim1$rawdata)

Log-rank test simulation for three arms

Description

Performs simulation for three-arm group sequential trials based on weighted log-rank test. The looks are driven by the total number of events in Arm A and Arm C combined. Alternatively, the analyses can be planned to occur at specified calendar times.

Usage

lrsim3a(
  kMax = NA_integer_,
  hazardRatioH013 = 1,
  hazardRatioH023 = 1,
  hazardRatioH012 = 1,
  allocation1 = 1L,
  allocation2 = 1L,
  allocation3 = 1L,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  lambda3 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  gamma3 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  plannedEvents = NA_integer_,
  plannedTime = NA_real_,
  maxNumberOfIterations = 1000L,
  maxNumberOfRawDatasetsPerStage = 0L,
  seed = NA_integer_
)

Arguments

kMax

The maximum number of stages.

hazardRatioH013

Hazard ratio under the null hypothesis for arm 1 versus arm 3. Defaults to 1 for superiority test.

hazardRatioH023

Hazard ratio under the null hypothesis for arm 2 versus arm 3. Defaults to 1 for superiority test.

hazardRatioH012

Hazard ratio under the null hypothesis for arm 1 versus arm 2. Defaults to 1 for superiority test.

allocation1

Number of subjects in Arm A in a randomization block. Defaults to 1 for equal randomization.

allocation2

Number of subjects in Arm B in a randomization block. Defaults to 1 for equal randomization.

allocation3

Number of subjects in Arm C in a randomization block. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for arm 1.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for arm 2.

lambda3

A vector of hazard rates for the event in each analysis time interval by stratum for arm 3.

gamma1

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 1.

gamma2

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 2.

gamma3

The hazard rate for exponential dropout. A vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for arm 3.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

plannedEvents

The planned cumulative total number of events at Look 1 to Look kMax for Arms A and C combined.

plannedTime

The calendar times for the analyses. To use calendar time to plan the analyses, plannedEvents should be missing.

maxNumberOfIterations

The number of simulation iterations. Defaults to 1000.

maxNumberOfRawDatasetsPerStage

The number of raw datasets per stage to extract.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified,

Value

A list with 2 components:

  • sumdata: A data frame of summary data by iteration and stage:

    • iterationNumber: The iteration number.

    • eventsNotAchieved: Whether the target number of events is not achieved for the iteration.

    • stageNumber: The stage number, covering all stages even if the trial stops at an interim look.

    • analysisTime: The time for the stage since trial start.

    • accruals1: The number of subjects enrolled at the stage for the active treatment 1 group.

    • accruals2: The number of subjects enrolled at the stage for the active treatment 2 group.

    • accruals3: The number of subjects enrolled at the stage for the control group.

    • totalAccruals: The total number of subjects enrolled at the stage.

    • events1: The number of events at the stage for the active treatment 1 group.

    • events2: The number of events at the stage for the active treatment 2 group.

    • events3: The number of events at the stage for the control group.

    • totalEvents: The total number of events at the stage.

    • dropouts1: The number of dropouts at the stage for the active treatment 1 group.

    • dropouts2: The number of dropouts at the stage for the active treatment 2 group.

    • dropouts3: The number of dropouts at the stage for the control group.

    • totalDropouts: The total number of dropouts at the stage.

    • logRankStatistic13: The log-rank test Z-statistic comparing the active treatment 1 to the control.

    • logRankStatistic23: The log-rank test Z-statistic comparing the active treatment 2 to the control.

    • logRankStatistic12: The log-rank test Z-statistic comparing the active treatment 1 to the active treatment 2.

  • rawdata (exists if maxNumberOfRawDatasetsPerStage is a positive integer): A data frame for subject-level data for selected replications, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage under consideration.

    • analysisTime: The time for the stage since trial start.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • treatmentGroup: The treatment group (1, 2, or 3) for the subject.

    • survivalTime: The underlying survival time for the subject.

    • dropoutTime: The underlying dropout time for the subject.

    • timeUnderObservation: The time under observation since randomization for the subject.

    • event: Whether the subject experienced the event.

    • dropoutEvent: Whether the subject dropped out.

Author(s)

Kaifeng Lu, [email protected]

Examples

sim1 = lrsim3a(
  kMax = 3,
  allocation1 = 2,
  allocation2 = 2,
  allocation3 = 1,
  accrualTime = c(0, 8),
  accrualIntensity = c(10, 28),
  piecewiseSurvivalTime = 0,
  lambda1 = log(2)/12*0.60,
  lambda2 = log(2)/12*0.70,
  lambda3 = log(2)/12,
  accrualDuration = 30.143,
  plannedEvents = c(186, 259, 295),
  maxNumberOfIterations = 1000,
  maxNumberOfRawDatasetsPerStage = 1,
  seed = 314159)

head(sim1$sumdata)
head(sim1$rawdata)

Number of subjects having an event and log-rank statistics

Description

Obtains the number of subjects accrued, number of events, number of dropouts, and number of subjects reaching the maximum follow-up in each group, mean and variance of weighted log-rank score statistic, estimated hazard ratio from weighted Cox regression and variance of log hazard ratio estimate at given calendar times.

Usage

lrstat(
  time = NA_real_,
  hazardRatioH0 = 1,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  rho1 = 0,
  rho2 = 0,
  numSubintervals = 300L,
  predictTarget = 2L
)

Arguments

time

A vector of calendar times at which to calculate the number of events and the mean and variance of log-rank test score statistic.

hazardRatioH0

Hazard ratio under the null hypothesis for the active treatment versus control. Defaults to 1 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

numSubintervals

Number of sub-intervals to approximate the mean and variance of the weighted log-rank test score statistic. Defaults to 300. Specify a larger number for better approximation.

predictTarget

The target of prediction. Set predictTarget = 1 to predict the number of events only. Set predictTarget = 2 (default) to predict the number of events and log-rank score statistic mean and variance. Set predictTarget = 3 to predict the number of events, log-rank score statistic mean and variance, and hazard ratio and variance of log hazard ratio.

Value

A data frame containing the following variables if predictTarget = 1:

  • time: The analysis time since trial start.

  • subjects: The number of enrolled subjects.

  • nevents: The total number of events.

  • nevents1: The number of events in the active treatment group.

  • nevents2: The number of events in the control group.

  • ndropouts: The total number of dropouts.

  • ndropouts1: The number of dropouts in the active treatment group.

  • ndropouts2: The number of dropouts in the control group.

  • nfmax: The total number of subjects reaching maximum follow-up.

  • nfmax1: The number of subjects reaching maximum follow-up in the active treatment group.

  • nfmax2: The number of subjects reaching maximum follow-up in the control group.

If predictTarget = 2, the following variables will also be included:

  • uscore: The numerator of the log-rank test statistic.

  • vscore: The variance of the log-rank score test statistic.

  • logRankZ: The log-rank test statistic on the Z-scale.

  • hazardRatioH0: The hazard ratio under the null hypothesis.

Furthermore, if predictTarget = 3, the following additional variables will also be included:

  • HR: The average hazard ratio from weighted Cox regression.

  • vlogHR: The variance of log hazard ratio.

  • zlogHR: The Z-statistic for log hazard ratio.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survivals, and 5% dropout by
# the end of 1 year.

lrstat(time = c(22, 40), allocationRatioPlanned = 1,
       accrualTime = seq(0, 8),
       accrualIntensity = 26/9*seq(1, 9),
       piecewiseSurvivalTime = c(0, 6),
       stratumFraction = c(0.2, 0.8),
       lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
       lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
       gamma1 = -log(1-0.05)/12,
       gamma2 = -log(1-0.05)/12,
       accrualDuration = 22,
       followupTime = 18, fixedFollowup = FALSE)

Log-rank test of survival curve difference

Description

Obtains the log-rank test using the Fleming-Harrington family of weights.

Usage

lrtest(
  data,
  rep = "rep",
  stratum = "stratum",
  treat = "treat",
  time = "time",
  event = "event",
  rho1 = 0,
  rho2 = 0
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • treat: The treatment.

  • time: The possibly right-censored survival time.

  • event: The event indicator.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

treat

The name of the treatment variable in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

rho1

The first parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

rho2

The second parameter of the Fleming-Harrington family of weighted log-rank test. Defaults to 0 for conventional log-rank test.

Value

A data frame with the following variables:

  • rep: The replication.

  • uscore: The numerator of the log-rank test statistic.

  • vscore: The variance of the log-rank score test statistic.

  • logRankZ: The Z-statistic value.

  • logRankPValue: The one-sided p-value.

  • rho1: The first parameter of the Fleming-Harrington weights.

  • rho2: The second parameter of the Fleming-Harrington weights.

Author(s)

Kaifeng Lu, [email protected]

Examples

df <- lrtest(data = rawdata, rep = "iterationNumber",
             stratum = "stratum", treat = "treatmentGroup",
             time = "timeUnderObservation", event = "event",
             rho1 = 0.5, rho2 = 0)
head(df)

Miettinen-Nurminen score confidence interval for two-sample odds ratio

Description

Obtains the Miettinen-Nurminen score confidence interval for two-sample odds ratio possibly with stratification.

Usage

mnOddsRatioCI(
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_,
  cilevel = 0.95
)

Arguments

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

cilevel

The confidence interval level.

Details

The Mantel-Haenszel sample size weights are used for stratified samples.

Value

A list with two components:

  • data A data frame containing the input sample size and number of responses for each treatment group. It has the following variables:

    • n1: The sample size for the active treatment group.

    • y1: The number of responses for the active treatment group.

    • n2: The sample size for the control group.

    • y2: The number of responses for the control group.

  • estimates: A data frame containing the point estimate and confidence interval for odds ratio. It has the following variables:

    • scale: The scale of treatment effect.

    • estimate: The point estimate.

    • lower: The lower limit of the confidence interval.

    • upper: The upper limit of the confidence interval.

    • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

mnOddsRatioCI(n1 = c(10,10), y1 = c(4,3), n2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score confidence interval for two-sample rate difference

Description

Obtains the Miettinen-Nurminen score confidence interval for two-sample rate difference possibly with stratification.

Usage

mnRateDiffCI(
  t1 = NA_real_,
  y1 = NA_real_,
  t2 = NA_real_,
  y2 = NA_real_,
  cilevel = 0.95
)

Arguments

t1

The exposure for the active treatment group.

y1

The number of events for the active treatment group.

t2

The exposure for the control group.

y2

The number of events for the control group.

cilevel

The confidence interval level.

Details

The Mantel-Haenszel weights are used for stratified samples.

Value

A list with two components:

  • data A data frame containing the input exposure and number of events for each treatment group. It has the following variables:

    • t1: The exposure for the active treatment group.

    • y1: The number of events for the active treatment group.

    • t2: The exposure for the control group.

    • y2: The number of events for the control group.

  • estimates: A data frame containing the point estimate and confidence interval for rate difference. It has the following variables:

    • scale: The scale of treatment effect.

    • estimate: The point estimate.

    • lower: The lower limit of the confidence interval.

    • upper: The upper limit of the confidence interval.

    • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

mnRateDiffCI(t1 = c(10,10), y1 = c(4,3), t2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score confidence interval for two-sample rate ratio

Description

Obtains the Miettinen-Nurminen score confidence interval for two-sample rate ratio possibly with stratification.

Usage

mnRateRatioCI(t1, y1, t2, y2, cilevel = 0.95)

Arguments

t1

The exposure for the active treatment group.

y1

The number of events for the active treatment group.

t2

The exposure for the control group.

y2

The number of events for the control group.

cilevel

The confidence interval level.

Details

The Mantel-Haenszel weights are used for stratified samples.

Value

A list with two components:

  • data A data frame containing the input exposure and number of events for each treatment group. It has the following variables:

    • t1: The exposure for the active treatment group.

    • y1: The number of events for the active treatment group.

    • t2: The exposure for the control group.

    • y2: The number of events for the control group.

  • estimates: A data frame containing the point estimate and confidence interval for rate ratio. It has the following variables:

    • scale: The scale of treatment effect.

    • estimate: The point estimate.

    • lower: The lower limit of the confidence interval.

    • upper: The upper limit of the confidence interval.

    • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

mnRateRatioCI(t1 = c(10,10), y1 = c(4,3), t2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score confidence interval for two-sample risk difference

Description

Obtains the Miettinen-Nurminen score confidence interval for two-sample risk difference possibly with stratification.

Usage

mnRiskDiffCI(
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_,
  cilevel = 0.95
)

Arguments

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

cilevel

The confidence interval level.

Details

The Mantel-Haenszel sample size weights are used for stratified samples.

Value

A list with two components:

  • data A data frame containing the input sample size and number of responses for each treatment group. It has the following variables:

    • n1: The sample size for the active treatment group.

    • y1: The number of responses for the active treatment group.

    • n2: The sample size for the control group.

    • y2: The number of responses for the control group.

  • estimates: A data frame containing the point estimate and confidence interval for risk difference. It has the following variables:

    • scale: The scale of treatment effect.

    • estimate: The point estimate.

    • lower: The lower limit of the confidence interval.

    • upper: The upper limit of the confidence interval.

    • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

mnRiskDiffCI(n1 = c(10,10), y1 = c(4,3), n2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score confidence interval for two-sample risk ratio

Description

Obtains the Miettinen-Nurminen score confidence interval for two-sample risk ratio possibly with stratification.

Usage

mnRiskRatioCI(
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_,
  cilevel = 0.95
)

Arguments

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

cilevel

The confidence interval level.

Details

The Mantel-Haenszel sample size weights are used for stratified samples.

Value

A list with two components:

  • data A data frame containing the input sample size and number of responses for each treatment group. It has the following variables:

    • n1: The sample size for the active treatment group.

    • y1: The number of responses for the active treatment group.

    • n2: The sample size for the control group.

    • y2: The number of responses for the control group.

  • estimates: A data frame containing the point estimate and confidence interval for risk ratio. It has the following variables:

    • scale: The scale of treatment effect.

    • estimate: The point estimate.

    • lower: The lower limit of the confidence interval.

    • upper: The upper limit of the confidence interval.

    • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

mnRiskRatioCI(n1 = c(10,10), y1 = c(4,3), n2 = c(20,10), y2 = c(2,0))

mTPI-2 decision table

Description

Obtains the decision table for the modified toxicity probability interval-2 (mTPI-2) design.

Usage

mTPI2Table(
  nMax = NA_integer_,
  pT = 0.3,
  epsilon1 = 0.05,
  epsilon2 = 0.05,
  a = 1,
  b = 1,
  pExcessTox = 0.95
)

Arguments

nMax

The maximum number of subjects in a dose cohort.

pT

The target toxicity probability. Defaults to 0.3.

epsilon1

The lower equivalence margin from the target. Defaults to 0.05.

epsilon2

The upper equivalence margin from the target. Defaults to 0.05.

a

The prior toxicity parameter for the beta prior.

b

The prior non-toxicity parameter for the beta prior.

pExcessTox

The threshold for excessive toxicity, i.e., if Prob(p > pT | Data) > pExcessTox, then the current and all higher doses will be excluded and never be used again in the remainder of the trial to avoid any other subjects receiving treatment at those doses. Defaults to 0.95.

Value

An S3 class mTPI2Table object with the following components:

  • settings: The input settings data frame with the following variables:

    • nMax: The maximum number of subjects in a dose cohort.

    • pT: The target toxicity probability.

    • epsilon1: The lower equivalence margin from the target.

    • epsilon2: The upper equivalence margin from the target.

    • a: The prior toxicity parameter for the beta prior.

    • b: The prior non-toxicity parameter for the beta prior.

    • pExcessTox: The threshold for excessive toxicity.

  • subintervals: The subintervals of equal length in the mTPI-2 design. It includes the following variables:

    • lower: The lower bound of the subinterval.

    • upper: The upper bound of the subinterval.

    • decision: The dosing decision for the subinterval.

  • decisionDataFrame: The decision data frame for the mTPI-2 design. It includes the following variables:

    • n: The sample size.

    • y: The number of toxicities.

    • decision: The dosing decision.

  • decisionMatrix: The decision matrix corresponding to the decision data frame.

Author(s)

Kaifeng Lu, [email protected]

Examples

mTPI2Table(nMax = 18, pT = 0.3, epsilon1 = 0.05, epsilon2 = 0.05)

Power for negative binomial rate ratio

Description

Estimates the power for negative binomial rate ratio test.

Usage

nbpower(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  rateRatioH0 = 1,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa1 = NA_real_,
  kappa2 = NA_real_,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_,
  nullVariance = 0L
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

rateRatioH0

Rate ratio under the null hypothesis.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa1

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the active treatment group by stratum.

kappa2

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the control group by stratum.

lambda1

The rate parameter of the negative binomial distribution for the active treatment group by stratum.

lambda2

The rate parameter of the negative binomial distribution for the control group by stratum.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

nullVariance

Whether to calculate the variance for log rate ratio under the null hypothesis.

Value

An S3 class nbpower object with 4 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • numberOfEvents: The total number of events.

    • numberOfDropouts: The total number of dropouts.

    • numbeOfSubjects: The total number of subjects.

    • exposure: The total exposure.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfEvents: The expected number of events.

    • expectedNumberOfDropouts: The expected number of dropouts.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedExposure: The expected exposure.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • kMax: The number of stages.

    • rateRatioH0: The rate ratio under the null hypothesis.

    • rateRatio: The rate ratio.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfEvents: The number of events.

    • numberOfDropouts: The number of dropouts.

    • numberOfSubjects: The number of subjects.

    • exposure: The exposure.

    • analysisTime: The average time since trial start.

    • efficacyRateRatio: The efficacy boundaries on the rate ratio scale.

    • futilityRateRatio: The futility boundaries on the rate ratio scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, kappa1, kappa2, lambda1, lambda2, gamma1, gamma2, spendingTime, and nullVariance.

  • byTreatmentCounts: A list containing the following counts by treatment group:

    • numberOfEvents1: The number of events by stage for the treatment group.

    • numberOfDropouts1: The number of dropouts by stage for the treatment group.

    • numberOfSubjects1: The number of subjects by stage for the treatment group.

    • exposure1: The exposure by stage for the treatment group.

    • numberOfEvents2: The number of events by stage for the control group.

    • numberOfDropouts2: The number of dropouts by stage for the control group.

    • numberOfSubjects2: The number of subjects by stage for the control group.

    • exposure2: The exposure by stage for the control group.

    • expectedNumberOfEvents1: The expected number of events for the treatment group.

    • expectedNumberOfDropouts1: The expected number of dropouts for the treatment group.

    • expectedNumberOfSubjects1: The expected number of subjects for the treatment group.

    • expectedExposure1: The expected exposure for the treatment group.

    • expectedNumberOfEvents2: The expected number of events for control group.

    • expectedNumberOfDropouts2: The expected number of dropouts for the control group.

    • expectedNumberOfSubjects2: The expected number of subjects for the control group.

    • expectedExposure2: The expected exposure for the control group.

Author(s)

Kaifeng Lu, [email protected]

See Also

nbstat

Examples

# Example 1: Variable follow-up design

nbpower(kMax = 2, informationRates = c(0.5, 1),
        alpha = 0.025, typeAlphaSpending = "sfOF",
        accrualIntensity = 1956/1.25,
        stratumFraction = c(0.2, 0.8),
        kappa1 = 5, kappa2 = 5,
        lambda1 = c(0.7*0.125, 0.75*0.25),
        lambda2 = c(0.125, 0.25),
        gamma1 = 0, gamma2 = 0,
        accrualDuration = 1.25,
        followupTime = 2.75, fixedFollowup = FALSE,
        nullVariance = 1)

# Example 2: Fixed follow-up design

nbpower(kMax = 2, informationRates = c(0.5, 1),
        alpha = 0.025, typeAlphaSpending = "sfOF",
        accrualIntensity = 220/1.5,
        kappa1 = 3, kappa2 = 3,
        lambda1 = 0.5*8.4, lambda2 = 8.4,
        gamma1 = 0, gamma2 = 0,
        accrualDuration = 1.5,
        followupTime = 0.5, fixedFollowup = TRUE)

Power for one-sample negative binomial rate

Description

Estimates the power, stopping probabilities, and expected sample size in a one-group negative binomial design.

Usage

nbpower1s(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  lambdaH0 = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa = NA_real_,
  lambda = NA_real_,
  gamma = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

lambdaH0

The rate parameter of the negative binomial distribution under the null hypothesis.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) of the negative binomial distribution by stratum.

lambda

The rate parameter of the negative binomial distribution under the alternative hypothesis by stratum.

gamma

The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout by stratum. Defaults to 0 for no dropout.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class nbpower1s object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • numberOfEvents: The total number of events.

    • numberOfDropouts: The total number of dropouts.

    • numbeOfSubjects: The total number of subjects.

    • exposure: The total exposure.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfEvents: The expected number of events.

    • expectedNumberOfDropouts: The expected number of dropouts.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedExposure: The expected exposure.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • kMax: The number of stages.

    • lambdaH0: The rate parameter of the negative binomial distribution under the null hypothesis.

    • lambda: The overall rate parameter of the negative binomial distribution under the alternative hypothesis.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfEvents: The number of events.

    • numberOfDropouts: The number of dropouts.

    • numberOfSubjects: The number of subjects.

    • exposure: The exposure.

    • analysisTime: The average time since trial start.

    • efficacyRate: The efficacy boundaries on the rate scale.

    • futilityRate: The futility boundaries on the rate scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, kappa, lambda, gamma, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

See Also

nbstat

Examples

# Example 1: Variable follow-up design

nbpower1s(kMax = 2, informationRates = c(0.5, 1),
          alpha = 0.025, typeAlphaSpending = "sfOF",
          lambdaH0 = 0.125, accrualIntensity = 500,
          stratumFraction = c(0.2, 0.8),
          kappa = c(3, 5), lambda = c(0.0875, 0.085),
          gamma = 0, accrualDuration = 1.25,
          followupTime = 2.75, fixedFollowup = FALSE)

# Example 2: Fixed follow-up design

nbpower1s(kMax = 2, informationRates = c(0.5, 1),
          alpha = 0.025, typeAlphaSpending = "sfOF",
          lambdaH0 = 8.4, accrualIntensity = 40,
          kappa = 3, lambda = 0.5*8.4,
          gamma = 0, accrualDuration = 1.5,
          followupTime = 0.5, fixedFollowup = TRUE)

Power for equivalence in negative binomial rate ratio

Description

Obtains the power for equivalence in negative binomial rate ratio.

Usage

nbpowerequiv(
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  rateRatioLower = NA_real_,
  rateRatioUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa1 = NA_real_,
  kappa2 = NA_real_,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_,
  nullVariance = 0L
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

rateRatioLower

The lower equivalence limit of rate ratio.

rateRatioUpper

The upper equivalence limit of rate ratio.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa1

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the active treatment group by stratum.

kappa2

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the control group by stratum.

lambda1

The rate parameter of the negative binomial distribution for the active treatment group by stratum.

lambda2

The rate parameter of the negative binomial distribution for the control group by stratum.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

nullVariance

Whether to calculate the variance for log rate ratio under the null hypothesis.

Value

An S3 class nbpowerequiv object with 4 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • numberOfEvents: The total number of events.

    • numberOfDropouts: The total number of dropouts.

    • numbeOfSubjects: The total number of subjects.

    • exposure: The total exposure.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfEvents: The expected number of events.

    • expectedNumberOfDropouts: The expected number of dropouts.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedExposure: The expected exposure.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • kMax: The number of stages.

    • rateRatioLower: The lower equivalence limit of rate ratio.

    • rateRatioUpper: The upper equivalence limit of rate ratio.

    • rateRatio: The rate ratio.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • numberOfEvents: The number of events.

    • numberOfDropouts: The number of dropouts.

    • numberOfSubjects: The number of subjects.

    • exposure: The exposure.

    • analysisTime: The average time since trial start.

    • efficacyRateRatioLower: The efficacy boundaries on the rate ratio scale for the one-sided null hypothesis at the lower equivalence limit.

    • efficacyRateRatioUpper: The efficacy boundaries on the rate ratio scale for the one-sided null hypothesis at the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, kappa1, kappa2, lambda1, lambda2, gamma1, gamma2, accrualDuration, followupTime, fixedFollowup, spendingTime, nullVariance, and varianceRatios. The varianceRatios is a data frame with the following variables:

    • varianceRatioH10: The ratio of the variance under H10 to the variance under H1.

    • varianceRatioH20: The ratio of the variance under H20 to the variance under H1.

    • varianceRatioH12: The ratio of the variance under H10 to the variance under H20.

    • varianceRatioH21: The ratio of the variance under H20 to the variance under H10.

  • byTreatmentCounts: A list containing the following counts by treatment group:

    • numberOfEvents1: The number of events by stage for the treatment group.

    • numberOfDropouts1: The number of dropouts by stage for the treatment group.

    • numberOfSubjects1: The number of subjects by stage for the treatment group.

    • exposure1: The exposure by stage for the treatment group.

    • numberOfEvents2: The number of events by stage for the control group.

    • numberOfDropouts2: The number of dropouts by stage for the control group.

    • numberOfSubjects2: The number of subjects by stage for the control group.

    • exposure2: The exposure by stage for the control group.

    • expectedNumberOfEvents1: The expected number of events for the treatment group.

    • expectedNumberOfDropouts1: The expected number of dropouts for the treatment group.

    • expectedNumberOfSubjects1: The expected number of subjects for the treatment group.

    • expectedExposure1: The expected exposure for the treatment group.

    • expectedNumberOfEvents2: The expected number of events for control group.

    • expectedNumberOfDropouts2: The expected number of dropouts for the control group.

    • expectedNumberOfSubjects2: The expected number of subjects for the control group.

    • expectedExposure2: The expected exposure for the control group.

Author(s)

Kaifeng Lu, [email protected]

See Also

nbstat

Examples

# Example 1: Variable follow-up design
nbpowerequiv(kMax = 2, informationRates = c(0.5, 1),
             alpha = 0.05, typeAlphaSpending = "sfOF",
             rateRatioLower = 2/3, rateRatioUpper = 3/2,
             accrualIntensity = 1956/1.25,
             kappa1 = 5, kappa2 = 5,
             lambda1 = 0.125, lambda2 = 0.125,
             gamma1 = 0, gamma2 = 0,
             accrualDuration = 1.25,
             followupTime = 2.75, fixedFollowup = FALSE,
             nullVariance = 1)

# Example 2: Fixed follow-up design
nbpowerequiv(kMax = 2, informationRates = c(0.5, 1),
             alpha = 0.05, typeAlphaSpending = "sfOF",
             rateRatioLower = 0.5, rateRatioUpper = 2,
             accrualIntensity = 220/1.5,
             stratumFraction = c(0.2, 0.8),
             kappa1 = 3, kappa2 = 3,
             lambda1 = c(8.4, 10.2),
             lambda2 = c(8.0, 11.5),
             gamma1 = 0, gamma2 = 0,
             accrualDuration = 1.5,
             followupTime = 0.5, fixedFollowup = TRUE)

Sample size for negative binomial rate ratio

Description

Obtains the needed accrual duration given power and follow-up time, the needed follow-up time given power and accrual duration, or the needed absolute accrual rates given power, accrual duration, follow-up duration, and relative accrual rates in a two-group negative binomial design.

Usage

nbsamplesize(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  rateRatioH0 = 1,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa1 = NA_real_,
  kappa2 = NA_real_,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L,
  nullVariance = 0L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

rateRatioH0

Rate ratio under the null hypothesis.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa1

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the active treatment group by stratum.

kappa2

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the control group by stratum.

lambda1

The rate parameter of the negative binomial distribution for the active treatment group by stratum.

lambda2

The rate parameter of the negative binomial distribution for the control group by stratum.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

nullVariance

Whether to calculate the variance for log rate ratio under the null hypothesis.

Value

A list of two components:

  • resultsUnderH1: An S3 class nbpower object under the alternative hypothesis.

  • resultsUnderH0: An S3 class nbpower object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

nbpower

Examples

# Example 1: Obtains follow-up duration given power, accrual intensity,
# and accrual duration for variable follow-up

nbsamplesize(beta = 0.2, kMax = 2,
             informationRates = c(0.5, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             accrualIntensity = 1956/1.25,
             kappa1 = 5, kappa2 = 5,
             lambda1 = 0.0875, lambda2 = 0.125,
             gamma1 = 0, gamma2 = 0,
             accrualDuration = 1.25,
             followupTime = NA, fixedFollowup = FALSE)

# Example 2: Obtains accrual intensity given power, accrual duration, and
# follow-up duration for variable follow-up

nbsamplesize(beta = 0.2, kMax = 2,
             informationRates = c(0.5, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             accrualIntensity = 100,
             kappa1 = 5, kappa2 = 5,
             lambda1 = 0.0875, lambda2 = 0.125,
             gamma1 = 0, gamma2 = 0,
             accrualDuration = 1.25,
             followupTime = 2.25, fixedFollowup = FALSE)


# Example 3: Obtains accrual duration given power, accrual intensity, and
# follow-up duration for fixed follow-up

nbsamplesize(beta = 0.2, kMax = 2,
             informationRates = c(0.5, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             accrualIntensity = 1667,
             stratumFraction = c(0.2, 0.8),
             kappa1 = 5, kappa2 = 5,
             lambda1 = c(0.7*0.125, 0.75*0.25),
             lambda2 = c(0.125, 0.25),
             gamma1 = 0, gamma2 = 0,
             accrualDuration = NA,
             followupTime = 0.5, fixedFollowup = TRUE)

Sample size for one-sample negative binomial rate

Description

Obtains the needed accrual duration given power and follow-up time, the needed follow-up time given power and accrual duration, or the needed absolute accrual rates given power, accrual duration, follow-up duration, and relative accrual rates in a one-group negative binomial design.

Usage

nbsamplesize1s(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  lambdaH0 = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa = NA_real_,
  lambda = NA_real_,
  gamma = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

lambdaH0

The rate parameter of the negative binomial distribution under the null hypothesis.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) of the negative binomial distribution by stratum.

lambda

The rate parameter of the negative binomial distribution under the alternative hypothesis by stratum.

gamma

The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout by stratum. Defaults to 0 for no dropout.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

A list of two components:

  • resultsUnderH1: An S3 class nbpower1s object under the alternative hypothesis.

  • resultsUnderH0: An S3 class nbpower1s object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

nbpower1s

Examples

# Example 1: Obtains follow-up duration given power, accrual intensity,
# and accrual duration for variable follow-up

nbsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.5, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               lambdaH0 = 0.125, accrualIntensity = 500,
               stratumFraction = c(0.2, 0.8),
               kappa = c(3, 5), lambda = c(0.0875, 0.085),
               gamma = 0, accrualDuration = 1.25,
               followupTime = NA, fixedFollowup = FALSE)

# Example 2: Obtains accrual intensity given power, accrual duration, and
# follow-up duration for variable follow-up

nbsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.5, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               lambdaH0 = 0.125, accrualIntensity = 100,
               kappa = 5, lambda = 0.0875,
               gamma = 0, accrualDuration = 1.25,
               followupTime = 2.25, fixedFollowup = FALSE)


# Example 3: Obtains accrual duration given power, accrual intensity, and
# follow-up duration for fixed follow-up

nbsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.5, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               lambdaH0 = 8.4, accrualIntensity = 40,
               kappa = 3, lambda = 4.2,
               gamma = 0, accrualDuration = NA,
               followupTime = 0.5, fixedFollowup = TRUE)

Sample size for equivalence in negative binomial rate ratio

Description

Obtains the sample size for equivalence in negative binomial rate ratio.

Usage

nbsamplesizeequiv(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  rateRatioLower = NA_real_,
  rateRatioUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa1 = NA_real_,
  kappa2 = NA_real_,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L,
  nullVariance = 0L
)

Arguments

beta

The type II error.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

rateRatioLower

The lower equivalence limit of rate ratio.

rateRatioUpper

The upper equivalence limit of rate ratio.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa1

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the active treatment group by stratum.

kappa2

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the control group by stratum.

lambda1

The rate parameter of the negative binomial distribution for the active treatment group by stratum.

lambda2

The rate parameter of the negative binomial distribution for the control group by stratum.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

nullVariance

Whether to calculate the variance for log rate ratio under the null hypothesis.

Value

An S3 class nbpowerequiv object

Author(s)

Kaifeng Lu, [email protected]

See Also

nbpowerequiv

Examples

# Example 1: Variable follow-up design and solve for follow-up time
nbsamplesizeequiv(beta = 0.1, kMax = 2, informationRates = c(0.5, 1),
                  alpha = 0.05, typeAlphaSpending = "sfOF",
                  rateRatioLower = 2/3, rateRatioUpper = 3/2,
                  accrualIntensity = 1956/1.25,
                  stratumFraction = c(0.2, 0.8),
                  kappa1 = c(3, 5),
                  kappa2 = c(2, 3),
                  lambda1 = c(0.125, 0.165),
                  lambda2 = c(0.135, 0.175),
                  gamma1 = -log(1-0.05),
                  gamma2 = -log(1-0.10),
                  accrualDuration = 1.25,
                  followupTime = NA, fixedFollowup = FALSE,
                  nullVariance = 1)

# Example 2: Fixed follow-up design and solve for accrual duration
nbsamplesizeequiv(beta = 0.2, kMax = 2, informationRates = c(0.5, 1),
                  alpha = 0.05, typeAlphaSpending = "sfOF",
                  rateRatioLower = 0.5, rateRatioUpper = 2,
                  accrualIntensity = 220/1.5,
                  kappa1 = 3, kappa2 = 3,
                  lambda1 = 8.4, lambda2 = 8.4,
                  gamma1 = 0, gamma2 = 0,
                  accrualDuration = NA,
                  followupTime = 0.5, fixedFollowup = TRUE)

Negative binomial rate ratio

Description

Obtains the number of subjects accrued, number of events, number of dropouts, number of subjects reaching the maximum follow-up, total exposure, and variance for log rate in each group, rate ratio, variance, and Wald test statistic of log rate ratio at given calendar times.

Usage

nbstat(
  time = NA_real_,
  rateRatioH0 = 1,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  kappa1 = NA_real_,
  kappa2 = NA_real_,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  nullVariance = 0L
)

Arguments

time

A vector of calendar times for data cut.

rateRatioH0

Rate ratio under the null hypothesis.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

kappa1

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the active treatment group by stratum.

kappa2

The dispersion parameter (reciprocal of the shape parameter of the gamma mixing distribution) for the control group by stratum.

lambda1

The rate parameter of the negative binomial distribution for the active treatment group by stratum.

lambda2

The rate parameter of the negative binomial distribution for the control group by stratum.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

nullVariance

Whether to calculate the variance for log rate ratio under the null hypothesis.

Details

The probability mass function for a negative binomial distribution with dispersion parameter κi\kappa_i and rate parameter λi\lambda_i is given by

P(Yij=y)=Γ(y+1/κi)Γ(1/κi)y!(11+κiλitij)1/κi(κiλitij1+κiλitij)y,P(Y_{ij} = y) = \frac{\Gamma(y+1/\kappa_i)}{\Gamma(1/\kappa_i) y!} \left(\frac{1}{1 + \kappa_i \lambda_i t_{ij}}\right)^{1/\kappa_i} \left(\frac{\kappa_i \lambda_i t_{ij}} {1 + \kappa_i \lambda_i t_{ij}}\right)^{y},

where YijY_{ij} is the event count for subject jj in treatment group ii, and tijt_{ij} is the exposure time for the subject. If κi=0\kappa_i=0, the negative binomial distribution reduces to the Poisson distribution.

For treatment group ii, let βi=log(λi)\beta_i = \log(\lambda_i). The likelihood for {(κi,βi):i=1,2}\{(\kappa_i, \beta_i):i=1,2\} can be written as

l=i=12j=1ni{logΓ(yij+1/κi)logΓ(1/κi)+yij(log(κi)+βi)(yij+1/κi)log(1+κiexp(βi)tij)}.l = \sum_{i=1}^{2}\sum_{j=1}^{n_{i}} \{\log \Gamma(y_{ij} + 1/\kappa_i) - \log \Gamma(1/\kappa_i) + y_{ij} (\log(\kappa_i) + \beta_i) - (y_{ij} + 1/\kappa_i) \log(1+ \kappa_i \exp(\beta_i) t_{ij})\}.

It follows that

lβi=j=1ni{yij(yij+1/κi)κiexp(βi)tij1+κiexp(βi)tij},\frac{\partial l}{\partial \beta_i} = \sum_{j=1}^{n_i} \left\{y_{ij} - (y_{ij} + 1/\kappa_i) \frac{\kappa_i \exp(\beta_i) t_{ij}} {1 + \kappa_i \exp(\beta_i)t_{ij}}\right\},

and

2lβi2=j=1ni(yij+1/κi)κiλitij(1+κiλitij)2.-\frac{\partial^2 l}{\partial \beta_i^2} = \sum_{j=1}^{n_i} (y_{ij} + 1/\kappa_i) \frac{\kappa_i \lambda_i t_{ij}} {(1 + \kappa_i \lambda_i t_{ij})^2}.

The Fisher information for βi\beta_i is

E(2lβi2)=niE(λitij1+κiλitij).E\left(-\frac{\partial^2 l}{\partial \beta_i^2}\right) = n_i E\left(\frac{\lambda_i t_{ij}} {1 + \kappa_i \lambda_i t_{ij}}\right).

In addition, we can show that

E(2lβiκi)=0.E\left(-\frac{\partial^2 l} {\partial \beta_i \partial \kappa_i}\right) = 0.

Therefore, the variance of β^i\hat{\beta}_i is

Var(β^i)=1ni{E(λitij1+κiλitij)}1.Var(\hat{\beta}_i) = \frac{1}{n_i} \left\{ E\left(\frac{\lambda_i t_{ij}}{1 + \kappa_i \lambda_i t_{ij}}\right) \right\}^{-1}.

To evaluate the integral, we need to obtain the distribution of the exposure time,

tij=min(τWij,Cij,Tfmax),t_{ij} = \min(\tau - W_{ij}, C_{ij}, T_{fmax}),

where τ\tau denotes the calendar time since trial start, WijW_{ij} denotes the enrollment time for subject jj in treatment group ii, CijC_{ij} denotes the time to dropout after enrollment for subject jj in treatment group ii, and TfmaxT_{fmax} denotes the maximum follow-up time for all subjects. Therefore,

P(tijt)=P(Wijτt)P(Cijt)I(tTfmax).P(t_{ij} \geq t) = P(W_{ij} \leq \tau - t)P(C_{ij} \geq t) I(t\leq T_{fmax}).

Let HH denote the distribution function of the enrollment time, and GiG_i denote the survival function of the dropout time for treatment group ii. By the change of variables, we have

E(λitij1+κiλitij)=0τTfmaxλi(1+κiλit)2H(τt)Gi(t)dt.E\left(\frac{\lambda_i t_{ij}}{1 + \kappa_i \lambda_i t_{ij}} \right) = \int_{0}^{\tau \wedge T_{fmax}} \frac{\lambda_i}{(1 + \kappa_i \lambda_i t)^2} H(\tau - t) G_i(t) dt.

A numerical integration algorithm for a univariate function can be used to evaluate the above integral.

For the restricted maximum likelihood (reml) estimate of (β1,β2)(\beta_1,\beta_2) subject to the constraint that β1β2=Δ\beta_1 - \beta_2 = \Delta, we express the log-likelihood in terms of (β2,Δ,κ1,κ2)(\beta_2,\Delta,\kappa_1,\kappa_2), and takes the derivative of the log-likelihood function with respect to β2\beta_2. The resulting score equation has asymptotic limit

E(lβ2)=s1+s2,E\left(\frac{\partial l}{\partial \beta_2}\right) = s_1 + s_2,

where

s1=nrE{λ11t1j(λ1t1j+1κ1)κ1eβ~2+Δt1j1+κ1eβ~2+Δt1j},s_1 = n r E\left\{\lambda1_1 t_{1j} - \left(\lambda_1t_{1j} + \frac{1}{\kappa_1}\right) \frac{\kappa_1 e^{\tilde{\beta}_2 + \Delta}t_{1j}}{1 + \kappa_1 e^{\tilde{\beta}_2 +\Delta}t_{1j}}\right\},

and

s2=n(1r)E{λ2t2j(λ2t2j+1κ2)κ2eβ~2t2j1+κ2eβ~2t2j}.s_2 = n (1-r) E\left\{\lambda_2 t_{2j} - \left(\lambda_2 t_{2j} + \frac{1}{\kappa_2}\right) \frac{\kappa_2 e^{\tilde{\beta}_2} t_{2j}} {1 + \kappa_2 e^{\tilde{\beta}_2}t_{2j}}\right\}.

Here rr is the randomization probability for the active treatment group. The asymptotic limit of the reml of β2\beta_2 is the solution β~2\tilde{\beta}_2 to E(lβ2)=0.E\left(\frac{\partial l}{\partial \beta_2}\right) = 0.

Value

A list with two components:

  • resultsUnderH1: A data frame containing the following variables:

    • time: The analysis time since trial start.

    • subjects: The number of enrolled subjects.

    • nevents: The total number of events.

    • nevents1: The number of events in the active treatment group.

    • nevents2: The number of events in the control group.

    • ndropouts: The total number of dropouts.

    • ndropouts1: The number of dropouts in the active treatment group.

    • ndropouts2: The number of dropouts in the control group.

    • nfmax: The total number of subjects reaching maximum follow-up.

    • nfmax1: The number of subjects reaching maximum follow-up in the active treatment group.

    • nfmax2: The number of subjects reaching maximum follow-up in the control group.

    • exposure: The total exposure time.

    • exposure1: The exposure time for the active treatment group.

    • exposure2: The exposure time for the control group.

    • rateRatio: The rate ratio of the active treatment group versus the control group.

    • vlogRate1: The variance for the log rate parameter for the active treatment group.

    • vlogRate2: The variance for the log rate parameter for the control group.

    • vlogRR: The variance of log rate ratio.

    • information: The information of log rate ratio.

    • zlogRR: The Z-statistic for log rate ratio.

  • resultsUnderH0 when nullVariance = TRUE: A data frame with the following variables:

    • time: The analysis time since trial start.

    • lambda1H0: The restricted maximum likelihood estimate of the event rate for the active treatment group.

    • lambda2H0: The restricted maximum likelihood estimate of the event rate for the control group.

    • rateRatioH0: The rate ratio under H0.

    • vlogRate1H0: The variance for the log rate parameter for the active treatment group under H0.

    • vlogRate2H0: The variance for the log rate parameter for the control group under H0.

    • vlogRRH0: The variance of log rate ratio under H0.

    • informationH0: The information of log rate ratio under H0.

    • zlogRRH0: The Z-statistic for log rate ratio with variance evaluated under H0.

    • varianceRatio: The ratio of the variance under H0 versus the variance under H1.

    • lambda1: The true event rate for the active treatment group.

    • lambda2: The true event rate for the control group.

    • rateRatio: The true rate ratio.

  • resultsUnderH0 when nullVariance = FALSE: A data frame with the following variables:

    • time: The analysis time since trial start.

    • rateRatioH0: The rate ratio under H0.

    • varianceRatio: Equal to 1.

    • lambda1: The true event rate for the active treatment group.

    • lambda2: The true event rate for the control group.

    • rateRatio: The true rate ratio.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: Variable follow-up design

nbstat(time = c(1, 1.25, 2, 3, 4),
       accrualIntensity = 1956/1.25,
       kappa1 = 5,
       kappa2 = 5,
       lambda1 = 0.7*0.125,
       lambda2 = 0.125,
       gamma1 = 0,
       gamma2 = 0,
       accrualDuration = 1.25,
       followupTime = 2.75)

# Example 2: Fixed follow-up design

nbstat(time = c(0.5, 1, 1.5, 2),
       accrualIntensity = 220/1.5,
       stratumFraction = c(0.2, 0.8),
       kappa1 = 3,
       kappa2 = 3,
       lambda1 = c(0.5*8.4, 0.6*10.5),
       lambda2 = c(8.4, 10.5),
       gamma1 = 0,
       gamma2 = 0,
       accrualDuration = 1.5,
       followupTime = 0.5,
       fixedFollowup = 1,
       nullVariance = 1)

Proportional hazards regression model

Description

Obtains the hazard ratio estimates from the proportional hazards regression model with right censored or counting process data.

Usage

phregr(
  data,
  rep = "rep",
  stratum = "stratum",
  time = "time",
  time2 = "time2",
  event = "event",
  covariates = "treat",
  weight = "weight",
  id = "id",
  ties = "efron",
  robust = 0L
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • time: The follow-up time for right censored data, or the left end of each interval for counting process data.

  • time2: The right end of each interval for counting process data only. Intervals are assumed to be open on the left and closed on the right, and event indicates whether an event occurred at the right end of each interval.

  • event: The event indicator, normally 1=event, 0=no event.

  • covariates: The values of baseline covariates (and time-dependent covariates in each interval for counting process data). This is the full-rank design matrix for the Cox model, assuming that factor variables have already been expanded into dummy variables.

  • weight: The weight for each observation.

  • id: The optional subject ID for counting process data with time-dependent covariates.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

time

The name of the time variable or the left end of each interval for counting process data in the input data.

time2

The name of the right end of each interval for counting process data in the input data.

event

The name of the event variable in the input data.

covariates

The vector of names of baseline and time-dependent covariates in the input data.

weight

The name of the weighting variable in the input data.

id

The name of the id variable in the input data.

ties

The method for handling ties with options including "breslow" and "efron" (default).

robust

Whether a robust sandwich variance estimate should be computed. The default is TRUE if there are fractional weights or there is at least 1 id with >1 event. In the presence of the id variable, the score residual will be aggregated for each id when computing the robust sandwich variance estimate.

Value

A list with the following components:

  • sumstat: The data frame of summary statistics of model fit with the following variables:

    • rep: The replication.

    • n: The number of observations.

    • nevents: The number of events.

    • loglik0: The log-likelihood under null.

    • loglik1: The maximum log-likelihood.

    • scoretest: The score test statistic.

  • parest: The data frame of parameter estimates with the following variables:

    • rep: The replication.

    • param: The name of the covariate for the parameter estimate.

    • beta: The log hazard ratio estimate.

    • sebeta: The standard error of log hazard ratio estimate.

    • rsebeta: The robust standard error of log hazard ratio estimate if robust variance is requested.

    • z: The Wald test statistic for log hazard ratio. The rsebeta will be used if robust variance is requested.

    • hazardRatio: The hazard ratio estimate.

    • vbeta: The covariance matrix for parameter estimates.

    • rvbeta: The robust covariance matrix for parameter estimates if robust variance is requested.

Author(s)

Kaifeng Lu, [email protected]

Examples

library(dplyr)

# Example 1 with right-censored data
phregr(data = rawdata %>% mutate(treat = 1*(treatmentGroup == 1)),
       rep = "iterationNumber", stratum = "stratum",
       time = "timeUnderObservation", event = "event",
       covariates = "treat")

# Example 2 with counting process data and robust variance estimate
phregr(data = heart %>% mutate(rx = as.numeric(transplant) - 1),
       time = "start", time2 = "stop", event = "event",
       covariates = c("rx", "age"), id = "id", robust = 1)

Distribution function of truncated piecewise exponential distribution

Description

Obtains the probability of a truncated piecewise exponential distribution.

Usage

ptpwexp(
  q,
  piecewiseSurvivalTime = 0,
  lambda = 0.0578,
  lowerBound = 0,
  lower.tail = TRUE,
  log.p = FALSE
)

Arguments

q

The vector of quantiles.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

lambda

A vector of hazard rates for the event. One for each analysis time interval.

lowerBound

The left truncation time point for the survival time. Defaults to 0 for no truncation.

lower.tail

Logical; if TRUE (default), probabilities are P(X <= x), otherwise, P(X > x).

log.p

Logical; if TRUE, probabilities p are given as log(p).

Value

The probability p such that P(X > q | X > lowerBound) = 1 - p.

Author(s)

Kaifeng Lu, [email protected]

Examples

ptpwexp(q = c(8, 18), piecewiseSurvivalTime = c(0, 6, 9, 15),
        lambda = c(0.025, 0.04, 0.015, 0.007))

Piecewise exponential approximation to a survival distribution

Description

Obtains the piecewise exponential distribution that approximates a survival distribution.

Usage

pwexpcuts(S, ...)

Arguments

S

The survival function of a univariate survival time.

...

Additional arguments to be passed to S.

Value

A list with three components:

  • piecewiseSurvivalTime: A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf).

  • lambda: A vector of hazard rates for the event. One for each analysis time interval.

  • loglik: The sequence of the asymptotic limit of the piecewise exponential log-likelihood for an increasing number of change points.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: Piecewise exponential 
pwexpcuts(ptpwexp, piecewiseSurvivalTime = c(0, 3.4, 5.5), 
          lambda = c(0.0168, 0.0833, 0.0431), lowerBound = 0,
          lower.tail = FALSE) 
 
# Example 2: Weibull
pwexpcuts(pweibull, shape = 1.37, scale = 1/0.818, lower.tail = FALSE)

Profile log-likelihood function for the change points in piecewise exponential approximation

Description

Obtains the profile log-likelihood function for the change points in the piecewise exponential approximation to a survival function.

Usage

pwexploglik(tau, S, ...)

Arguments

tau

The numeric vector of change points.

S

The survival function of a univariate survival time.

...

Additional arguments to be passed to S.

Value

A list with the following three components:

  • piecewiseSurvivalTime: A vector that specifies the starting time of piecewise exponential survival time intervals.

  • lambda: A vector of hazard rates for the event. One for each analysis time interval.

  • loglik: The value of the profile log-likelihood.

Author(s)

Kaifeng Lu, [email protected]

Examples

pwexploglik(tau = c(0.5, 1.2, 2.8), pweibull, 
            shape = 1.37, scale = 1/0.818, lower.tail = FALSE)

Quantile function of truncated piecewise exponential distribution

Description

Obtains the quantile of a truncated piecewise exponential distribution.

Usage

qtpwexp(
  p,
  piecewiseSurvivalTime = 0,
  lambda = 0.0578,
  lowerBound = 0,
  lower.tail = TRUE,
  log.p = FALSE
)

Arguments

p

The vector of probabilities.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

lambda

A vector of hazard rates for the event. One for each analysis time interval.

lowerBound

The left truncation time point for the survival time. Defaults to 0 for no truncation.

lower.tail

Logical; if TRUE (default), probabilities are P(X <= x), otherwise, P(X > x).

log.p

Logical; if TRUE, probabilities p are given as log(p).

Value

The quantile q such that P(X > q | X > lowerBound) = 1 - p.

Author(s)

Kaifeng Lu, [email protected]

Examples

qtpwexp(p = c(0.205, 0.317), piecewiseSurvivalTime = c(0, 6, 9, 15),
        lambda = c(0.025, 0.04, 0.015, 0.007))

A simulated time-to-event data set with 10 replications

Description

A simulated data set with stratification and delayed treatment effect:

iterationNumber

The iteration number

arrivalTime

The enrollment time for the subject

stratum

The stratum for the subject

treatmentGroup

The treatment group for the subject

timeUnderObservation

The time under observation since randomization

event

Whether the subject experienced the event

dropoutEvent

Whether the subject dropped out

Usage

rawdata

Format

An object of class data.frame with 4910 rows and 7 columns.


REML estimates of individual proportions with specified odds ratio

Description

Obtains the restricted maximum likelihood estimates of individual proportions with specified odds ratio.

Usage

remlOddsRatio(
  oddsRatioH0 = 1,
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_
)

Arguments

oddsRatioH0

The specified odds ratio.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Value

A vector of the restricted maximum likelihood estimates of the response probabilities for the two treatment groups.

Author(s)

Kaifeng Lu, [email protected]

Examples

remlOddsRatio(oddsRatioH0 = 1.25, n1 = 10, y1 = 4, n2 = 20, y2 = 2)

REML estimates of individual rates with specified rate difference

Description

Obtains the restricted maximum likelihood estimates of individual proportions with specified rate difference.

Usage

remlRateDiff(
  rateDiffH0 = 0,
  t1 = NA_real_,
  y1 = NA_real_,
  t2 = NA_real_,
  y2 = NA_real_
)

Arguments

rateDiffH0

The specified rate difference.

t1

The exposure for the active treatment group.

y1

The number of events for the active treatment group.

t2

The exposure for the control group.

y2

The number of events for the control group.

Value

A vector of the restricted maximum likelihood estimates of the incidence rates for the two treatment groups.

Author(s)

Kaifeng Lu, [email protected]

Examples

remlRateDiff(rateDiffH0 = 0.1, t1 = 10, y1 = 4, t2 = 20, y2 = 2)

REML estimates of individual rates with specified rate ratio

Description

Obtains the restricted maximum likelihood estimates of individual proportions with specified rate ratio.

Usage

remlRateRatio(
  rateRatioH0 = 1,
  t1 = NA_real_,
  y1 = NA_real_,
  t2 = NA_real_,
  y2 = NA_real_
)

Arguments

rateRatioH0

The specified rate ratio.

t1

The exposure for the active treatment group.

y1

The number of events for the active treatment group.

t2

The exposure for the control group.

y2

The number of events for the control group.

Value

A vector of the restricted maximum likelihood estimates of the incidence rates for the two treatment groups.

Author(s)

Kaifeng Lu, [email protected]

Examples

remlRateRatio(rateRatioH0 = 1.1, t1 = 10, y1 = 4, t2 = 20, y2 = 2)

REML estimates of individual proportions with specified risk difference

Description

Obtains the restricted maximum likelihood estimates of individual proportions with specified risk difference.

Usage

remlRiskDiff(
  riskDiffH0 = 0,
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_
)

Arguments

riskDiffH0

The specified risk difference.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Value

A vector of the restricted maximum likelihood estimates of the response probabilities for the two treatment groups.

Author(s)

Kaifeng Lu, [email protected]

Examples

remlRiskDiff(riskDiffH0 = 0.1, n1 = 10, y1 = 4, n2 = 20, y2 = 0)

REML estimates of individual proportions with specified risk ratio

Description

Obtains the restricted maximum likelihood estimates of individual proportions with specified risk ratio.

Usage

remlRiskRatio(
  riskRatioH0 = 1,
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_
)

Arguments

riskRatioH0

The specified risk ratio.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Value

A vector of the restricted maximum likelihood estimates of the response probabilities for the two treatment groups.

Author(s)

Kaifeng Lu, [email protected]

Examples

remlRiskRatio(riskRatioH0 = 1.2, n1 = 10, y1 = 4, n2 = 20, y2 = 2)

Repeated p-values for group sequential design

Description

Obtains the repeated p-values for a group sequential design.

Usage

repeatedPValue(
  kMax,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA,
  maxInformation = 1,
  p,
  information,
  spendingTime = NULL
)

Arguments

kMax

The maximum number of stages.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

maxInformation

The target maximum information. Defaults to 1, in which case, information represents informationRates.

p

The raw p-values at look 1 to look k. It can be a matrix with k columns for k <= kMax.

information

The observed information by look. It can be a matrix with k columns.

spendingTime

The error spending time at each analysis, must be increasing and less than or equal to 1. Defaults to NULL, in which case, it is the same as informationRates derived from information and maxInformation. It can be a matrix with k columns.

Value

The repeated p-values at look 1 to look k.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Example 1: informationRates different from spendingTime
repeatedPValue(kMax = 3, typeAlphaSpending = "sfOF",
               maxInformation = 800,
               p = c(0.2, 0.15, 0.1),
               information = c(529, 700, 800),
               spendingTime = c(0.6271186, 0.8305085, 1))

# Example 2: Maurer & Bretz (2013), current look is not the last look
repeatedPValue(kMax = 3, typeAlphaSpending = "sfOF",
               p = matrix(c(0.0062, 0.017,
                            0.009, 0.13,
                            0.0002, 0.0035,
                            0.002, 0.06),
                          nrow=4, ncol=2),
               information = c(1/3, 2/3))

Exact unconditional confidence interval for risk difference

Description

Obtains the exact unconditional confidence interval for risk difference based on the standardized score statistic.

Usage

riskDiffExactCI(
  n1 = NA_integer_,
  y1 = NA_integer_,
  n2 = NA_integer_,
  y2 = NA_integer_,
  cilevel = 0.95
)

Arguments

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

cilevel

The confidence interval level.

Value

A data frame containing the following variables:

  • scale: The scale of treatment effect.

  • estimate: The point estimate.

  • lower: The lower limit of the confidence interval.

  • upper: The upper limit of the confidence interval.

  • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

riskDiffExactCI(n1 = 68, y1 = 2, n2 = 65, y2 = 1, cilevel = 0.95)

P-value for exact unconditional test of risk difference

Description

Obtains the p-value for exact unconditional test of risk difference.

Usage

riskDiffExactPValue(
  riskDiffH0 = 0,
  directionUpper = 1L,
  n1 = NA_integer_,
  y1 = NA_integer_,
  n2 = NA_integer_,
  y2 = NA_integer_
)

Arguments

riskDiffH0

The risk difference under the null hypothesis. Defaults to 0.

directionUpper

Whether larger values represent better responses.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Value

A data frame containing the following variables:

  • riskDiffH0: The risk difference under the null hypothesis.

  • directionUpper: Whether larger values represent better responses.

  • riskDiff: The observed risk difference.

  • zstat: The observed value of the Z test statistic.

  • pvalue: The one-sided p-value for the unconditional exact test.

  • pi2star: The value of pi2 that yields the p-value.

Author(s)

Kaifeng Lu, [email protected]

Examples

riskDiffExactPValue(riskDiffH0 = 0, directionUpper = 1,
                    n1 = 68, y1 = 2, n2 = 65, y2 = 1)

Exact unconditional confidence interval for risk ratio

Description

Obtains the exact unconditional confidence interval for risk ratio based on the standardized score statistic.

Usage

riskRatioExactCI(
  n1 = NA_integer_,
  y1 = NA_integer_,
  n2 = NA_integer_,
  y2 = NA_integer_,
  cilevel = 0.95
)

Arguments

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

cilevel

The confidence interval level.

Value

A data frame containing the following variables:

  • scale: The scale of treatment effect.

  • estimate: The point estimate.

  • lower: The lower limit of the confidence interval.

  • upper: The upper limit of the confidence interval.

  • cilevel: The confidence interval level.

Author(s)

Kaifeng Lu, [email protected]

Examples

riskRatioExactCI(n1 = 68, y1 = 2, n2 = 65, y2 = 1, cilevel = 0.95)

P-value for exact unconditional test of risk ratio

Description

Obtains the p-value for exact unconditional test of risk ratio.

Usage

riskRatioExactPValue(
  riskRatioH0 = 1,
  directionUpper = 1L,
  n1 = NA_integer_,
  y1 = NA_integer_,
  n2 = NA_integer_,
  y2 = NA_integer_
)

Arguments

riskRatioH0

The risk ratio under the null hypothesis. Defaults to 1.

directionUpper

Whether larger values represent better responses.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Value

A data frame containing the following variables:

  • riskRatioH0: The risk ratio under the null hypothesis.

  • directionUpper: Whether larger values represent better responses.

  • riskRatio: The observed risk ratio.

  • zstat: The observed value of the Z test statistic.

  • pvalue: The one-sided p-value for the unconditional exact test.

  • pi2star: The value of pi2 that yields the p-value.

Author(s)

Kaifeng Lu, [email protected]

Examples

riskRatioExactPValue(riskRatioH0 = 1, directionUpper = 1,
                     n1 = 68, y1 = 2, n2 = 65, y2 = 1)

Estimate of restricted mean survival time difference

Description

Obtains the estimate of restricted mean survival time difference between two treatment groups.

Usage

rmdiff(
  data,
  rep = "rep",
  stratum = "stratum",
  treat = "treat",
  time = "time",
  event = "event",
  milestone = NA_real_,
  rmstDiffH0 = 0,
  confint = 0.95,
  biascorrection = 0L
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • treat: The treatment.

  • time: The possibly right-censored survival time.

  • event: The event indicator.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

treat

The name of the treatment variable in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

milestone

The milestone time at which to calculate the restricted mean survival time.

rmstDiffH0

The difference in restricted mean survival times under the null hypothesis. Defaults to 0 for superiority test.

confint

The level of the two-sided confidence interval for the difference in restricted mean survival times. Defaults to 0.95.

biascorrection

Whether to apply bias correction for the variance estimate of individual restricted mean survival times. Defaults to no bias correction.

Value

A data frame with the following variables:

  • rep: The replication number.

  • milestone: The milestone time relative to randomization.

  • rmstDiffH0: The difference in restricted mean survival times under the null hypothesis.

  • rmst1: The estimated restricted mean survival time for the treatment group.

  • rmst2: The estimated restricted mean survival time for the control group.

  • rmstDiff: The estimated difference in restricted mean survival times.

  • vrmst1: The variance for rmst1.

  • vrmst2: The variance for rmst2.

  • vrmstDiff: The variance for rmstDiff.

  • rmstDiffZ: The Z-statistic value.

  • rmstDiffPValue: The one-sided p-value.

  • lower: The lower bound of confidence interval.

  • upper: The upper bound of confidence interval.

  • confint: The level of confidence interval.

  • biascorrection: Whether to apply bias correction for the variance estimate of individual restricted mean survival times.

Author(s)

Kaifeng Lu, [email protected]

Examples

df <- rmdiff(data = rawdata, rep = "iterationNumber",
             stratum = "stratum", treat = "treatmentGroup",
             time = "timeUnderObservation", event = "event",
             milestone = 12)
head(df)

Estimate of restricted mean survival time

Description

Obtains the estimate of restricted means survival time for each stratum.

Usage

rmest(
  data,
  rep = "rep",
  stratum = "stratum",
  time = "time",
  event = "event",
  milestone = NA_real_,
  confint = 0.95,
  biascorrection = 0L
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • time: The possibly right-censored survival time.

  • event: The event indicator.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

milestone

The milestone time at which to calculate the restricted mean survival time.

confint

The level of the two-sided confidence interval for the survival probabilities. Defaults to 0.95.

biascorrection

Whether to apply bias correction for the variance estimate. Defaults to no bias correction.

Value

A data frame with the following variables:

  • rep: The replication.

  • stratum: The stratum variable.

  • size: The number of subjects in the stratum.

  • milestone: The milestone time relative to randomization.

  • rmst: The estimate of restricted mean survival time.

  • stderr: The standard error of the estimated rmst.

  • lower: The lower bound of confidence interval if requested.

  • upper: The upper bound of confidence interval if requested.

  • confint: The level of confidence interval if requested.

  • biascorrection: Whether to apply bias correction for the variance estimate.

Author(s)

Kaifeng Lu, [email protected]

Examples

rmest(data = aml, stratum = "x",
      time = "time", event = "status", milestone = 24)

Power for difference in restricted mean survival times

Description

Estimates the power for testing the difference in restricted mean survival times in a two-sample survival design.

Usage

rmpower(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  milestone = NA_real_,
  rmstDiffH0 = 0,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

milestone

The milestone time at which to calculate the restricted mean survival time.

rmstDiffH0

The difference in restricted mean survival times under the null hypothesis. Defaults to 0 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class rmpower object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • drift: The drift parameter, equal to (rmstDiff - rmstDiffH0)*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • kMax: The number of stages.

    • milestone: The milestone time relative to randomization.

    • rmstDiffH0: The difference in restricted mean survival times under the null hypothesis.

    • rmst1: The restricted mean survival time for the treatment group.

    • rmst2: The restricted mean survival time for the control group.

    • rmstDiff: The difference in restricted mean survival times, equal to rmst1 - rmst2.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacyRmstDiff: The efficacy boundaries on the restricted mean survival time difference scale.

    • futilityRmstDiff: The futility boundaries on the restricted mean survival time difference scale.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda1, lambda2, gamma1, gamma2, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survival, and 5% dropout by
# the end of 1 year.

rmpower(kMax = 2, informationRates = c(0.8, 1),
        alpha = 0.025, typeAlphaSpending = "sfOF",
        milestone = 18,
        allocationRatioPlanned = 1, accrualTime = seq(0, 8),
        accrualIntensity = 100/9*seq(1, 9),
        piecewiseSurvivalTime = c(0, 6),
        stratumFraction = c(0.2, 0.8),
        lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
        lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
        gamma1 = -log(1-0.05)/12,
        gamma2 = -log(1-0.05)/12, accrualDuration = 22,
        followupTime = 18, fixedFollowup = FALSE)

Power for one-sample restricted mean survival time

Description

Estimates the power, stopping probabilities, and expected sample size in a one-group survival design.

Usage

rmpower1s(
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  milestone = NA_real_,
  rmstH0 = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda = NA_real_,
  gamma = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

milestone

The milestone time at which to calculate the restricted mean survival time.

rmstH0

The restricted mean survival time under the null hypothesis.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda

A vector of hazard rates for the event in each analysis time interval by stratum under the alternative hypothesis.

gamma

The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout. Defaults to 0 for no dropout.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class rmpower1s object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • drift: The drift parameter, equal to (rmst - rmstH0)*sqrt(information).

    • inflationFactor: The inflation factor (relative to the fixed design).

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

    • kMax: The number of stages.

    • milestone: The milestone time relative to randomization.

    • rmstH0: The restricted mean survival time under the null hypothesis.

    • rmst: The restricted mean survival time under the alternative hypothesis.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale.

    • futilityBounds: The futility boundaries on the Z-scale.

    • rejectPerStage: The probability for efficacy stopping.

    • futilityPerStage: The probability for futility stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeFutility: The cumulative probability for futility stopping.

    • cumulativeAlphaSpent: The cumulative alpha spent.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacyRmst: The efficacy boundaries on the restricted mean survival time.

    • futilityRmst: The futility boundaries on the restricted mean survival time.

    • efficacyP: The efficacy boundaries on the p-value scale.

    • futilityP: The futility boundaries on the p-value scale.

    • information: The cumulative information.

    • efficacyStopping: Whether to allow efficacy stopping.

    • futilityStopping: Whether to allow futility stopping.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, typeBetaSpending, parameterBetaSpending, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda, gamma, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

See Also

rmstat

Examples

rmpower1s(kMax = 2, informationRates = c(0.8, 1),
          alpha = 0.025, typeAlphaSpending = "sfOF",
          milestone = 18, rmstH0 = 10,
          accrualTime = seq(0, 8),
          accrualIntensity = 26/9*seq(1, 9),
          piecewiseSurvivalTime = c(0, 6),
          stratumFraction = c(0.2, 0.8),
          lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
          gamma = -log(1-0.05)/12, accrualDuration = 22,
          followupTime = 18, fixedFollowup = FALSE)

Power for equivalence in restricted mean survival time difference

Description

Obtains the power for equivalence in restricted mean survival time difference.

Usage

rmpowerequiv(
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  milestone = NA_real_,
  rmstDiffLower = NA_real_,
  rmstDiffUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  spendingTime = NA_real_,
  studyDuration = NA_real_
)

Arguments

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

milestone

The milestone time at which to calculate the restricted mean survival time.

rmstDiffLower

The lower equivalence limit of restricted mean survival time difference.

rmstDiffUpper

The upper equivalence limit of restricted mean survival time difference.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

studyDuration

Study duration for fixed follow-up design. Defaults to missing, which is to be replaced with the sum of accrualDuration and followupTime. If provided, the value is allowed to be less than the sum of accrualDuration and followupTime.

Value

An S3 class rmpowerequiv object with 3 components:

  • overallResults: A data frame containing the following variables:

    • overallReject: The overall rejection probability.

    • alpha: The overall significance level.

    • attainedAlphaH10: The attained significance level under H10.

    • attainedAlphaH20: The attained significance level under H20.

    • numbeOfSubjects: The total number of subjects.

    • studyDuration: The total study duration.

    • information: The maximum information.

    • expectedNumberOfSubjects: The expected number of subjects.

    • expectedStudyDuration: The expected study duration.

    • expectedInformation: The expected information.

    • kMax: The number of stages.

    • milestone: The milestone time relative to randomization.

    • rmstDiffLower: The lower equivalence limit of restricted mean survival time difference.

    • rmstDiffUpper: The upper equivalence limit of restricted mean survival time difference.

    • rmst1: The restricted mean survival time for the treatment group.

    • rmst2: The restricted mean survival time for the control group.

    • rmstDiff: The restricted mean survival time difference.

    • accrualDuration: The accrual duration.

    • followupTime: The follow-up duration.

    • fixedFollowup: Whether a fixed follow-up design is used.

  • byStageResults: A data frame containing the following variables:

    • informationRates: The information rates.

    • efficacyBounds: The efficacy boundaries on the Z-scale for each of the two one-sided tests.

    • rejectPerStage: The probability for efficacy stopping.

    • cumulativeRejection: The cumulative probability for efficacy stopping.

    • cumulativeAlphaSpent: The cumulative alpha for each of the two one-sided tests.

    • cumulativeAttainedAlphaH10: The cumulative alpha attained under H10.

    • cumulativeAttainedAlphaH20: The cumulative alpha attained under H20.

    • numberOfSubjects: The number of subjects.

    • analysisTime: The average time since trial start.

    • efficacyRmstDiffLower: The efficacy boundaries on the restricted mean survival time difference scale for the one-sided null hypothesis at the lower equivalence limit.

    • efficacyRmstDiffUpper: The efficacy boundaries on the restricted mean survival time difference scale for the one-sided null hypothesis at the upper equivalence limit.

    • efficacyP: The efficacy bounds on the p-value scale for each of the two one-sided tests.

    • information: The cumulative information.

  • settings: A list containing the following input parameters: typeAlphaSpending, parameterAlphaSpending, userAlphaSpending, allocationRatioPlanned, accrualTime, accuralIntensity, piecewiseSurvivalTime, stratumFraction, lambda1, lambda2, gamma1, gamma2, and spendingTime.

Author(s)

Kaifeng Lu, [email protected]

See Also

rmstat

Examples

rmpowerequiv(kMax = 2, informationRates = c(0.5, 1),
             alpha = 0.05, typeAlphaSpending = "sfOF",
             milestone = 18,
             rmstDiffLower = -2, rmstDiffUpper = 2,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 100/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = 18, fixedFollowup = FALSE)

Sample size for difference in restricted mean survival times

Description

Obtains the needed accrual duration given power, accrual intensity, and follow-up time, the needed follow-up time given power, accrual intensity, and accrual duration, or the needed absolute accrual intensity given power, relative accrual intensity, accrual duration, and follow-up time in a two-group survival design.

Usage

rmsamplesize(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  milestone = NA_real_,
  rmstDiffH0 = 0,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

milestone

The milestone time at which to calculate the restricted mean survival time.

rmstDiffH0

The difference in restricted mean survival times under the null hypothesis. Defaults to 0 for superiority test.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupTime, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

A list of two components:

  • resultsUnderH1: An S3 class rmpower object under the alternative hypothesis.

  • resultsUnderH0: An S3 class rmpower object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

rmpower

Examples

# Example 1: Obtains follow-up time given power, accrual intensity,
# and accrual duration for variable follow-up. Of note, the power
# reaches the maximum when the follow-up time equals milestone.

rmsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             milestone = 18,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 100/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = NA, fixedFollowup = FALSE)

# Example 2: Obtains accrual intensity given power, accrual duration, and
# follow-up time for variable follow-up

rmsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             milestone = 18,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 100/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = 22,
             followupTime = 18, fixedFollowup = FALSE)


# Example 3: Obtains accrual duration given power, accrual intensity, and
# follow-up time for fixed follow-up

rmsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
             alpha = 0.025, typeAlphaSpending = "sfOF",
             milestone = 18,
             allocationRatioPlanned = 1, accrualTime = seq(0, 8),
             accrualIntensity = 100/9*seq(1, 9),
             piecewiseSurvivalTime = c(0, 6),
             stratumFraction = c(0.2, 0.8),
             lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
             lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
             gamma1 = -log(1-0.05)/12,
             gamma2 = -log(1-0.05)/12, accrualDuration = NA,
             followupTime = 18, fixedFollowup = TRUE)

Sample size for one-sample restricted mean survival time

Description

Obtains the needed accrual duration given power and follow-up time, the needed follow-up time given power and accrual duration, or the needed absolute accrual rates given power, accrual duration, follow-up duration, and relative accrual rates in a one-group survival design.

Usage

rmsamplesize1s(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  efficacyStopping = NA_integer_,
  futilityStopping = NA_integer_,
  criticalValues = NA_real_,
  alpha = 0.025,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  futilityBounds = NA_real_,
  typeBetaSpending = "none",
  parameterBetaSpending = NA_real_,
  userBetaSpending = NA_real_,
  milestone = NA_real_,
  rmstH0 = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda = NA_real_,
  gamma = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

Type II error. Defaults to 0.2.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

efficacyStopping

Indicators of whether efficacy stopping is allowed at each stage. Defaults to true if left unspecified.

futilityStopping

Indicators of whether futility stopping is allowed at each stage. Defaults to true if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level. Defaults to 0.025.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

futilityBounds

Lower boundaries on the z-test statistic scale for stopping for futility at stages 1, ..., kMax-1. Defaults to rep(-6, kMax-1) if left unspecified. The futility bounds are non-binding for the calculation of critical values.

typeBetaSpending

The type of beta spending. One of the following: "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early futility stopping. Defaults to "none".

parameterBetaSpending

The parameter value for the beta spending. Corresponds to rho for "sfKD", and gamma for "sfHSD".

userBetaSpending

The user defined beta spending. Cumulative beta spent up to each stage.

milestone

The milestone time at which to calculate the restricted survival time.

rmstH0

The restricted mean survival time under the null hypothesis.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda

A vector of hazard rates for the event in each analysis time interval by stratum under the alternative hypothesis.

gamma

The hazard rate for exponential dropout or a vector of hazard rates for piecewise exponential dropout. Defaults to 0 for no dropout.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

A list of two components:

  • resultsUnderH1: An S3 class rmpower1s object under the alternative hypothesis.

  • resultsUnderH0: An S3 class rmpower1s object under the null hypothesis.

Author(s)

Kaifeng Lu, [email protected]

See Also

rmpower1s

Examples

# Example 1: Obtains follow-up duration given power, accrual intensity,
# and accrual duration for variable follow-up

rmsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.8, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               milestone = 18, rmstH0 = 10,
               accrualTime = seq(0, 8),
               accrualIntensity = 26/9*seq(1, 9),
               piecewiseSurvivalTime = c(0, 6),
               stratumFraction = c(0.2, 0.8),
               lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
               gamma = -log(1-0.05)/12, accrualDuration = 22,
               followupTime = NA, fixedFollowup = FALSE)

# Example 2: Obtains accrual intensity given power, accrual duration, and
# follow-up duration for variable follow-up

rmsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.8, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               milestone = 18, rmstH0 = 10,
               accrualTime = seq(0, 8),
               accrualIntensity = 26/9*seq(1, 9),
               piecewiseSurvivalTime = c(0, 6),
               stratumFraction = c(0.2, 0.8),
               lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
               gamma = -log(1-0.05)/12, accrualDuration = 22,
               followupTime = 18, fixedFollowup = FALSE)


# Example 3: Obtains accrual duration given power, accrual intensity, and
# follow-up duration for fixed follow-up

rmsamplesize1s(beta = 0.2, kMax = 2,
               informationRates = c(0.8, 1),
               alpha = 0.025, typeAlphaSpending = "sfOF",
               milestone = 18, rmstH0 = 10,
               accrualTime = seq(0, 8),
               accrualIntensity = 26/9*seq(1, 9),
               piecewiseSurvivalTime = c(0, 6),
               stratumFraction = c(0.2, 0.8),
               lambda = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
               gamma = -log(1-0.05)/12, accrualDuration = NA,
               followupTime = 18, fixedFollowup = TRUE)

Sample size for equivalence in restricted mean survival time difference

Description

Obtains the sample size for equivalence in restricted mean survival time difference.

Usage

rmsamplesizeequiv(
  beta = 0.2,
  kMax = 1L,
  informationRates = NA_real_,
  criticalValues = NA_real_,
  alpha = 0.05,
  typeAlphaSpending = "sfOF",
  parameterAlphaSpending = NA_real_,
  userAlphaSpending = NA_real_,
  milestone = NA_real_,
  rmstDiffLower = NA_real_,
  rmstDiffUpper = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L,
  interval = as.numeric(c(0.001, 240)),
  spendingTime = NA_real_,
  rounding = 1L
)

Arguments

beta

The type II error.

kMax

The maximum number of stages.

informationRates

The information rates. Defaults to (1:kMax) / kMax if left unspecified.

criticalValues

Upper boundaries on the z-test statistic scale for stopping for efficacy.

alpha

The significance level for each of the two one-sided tests. Defaults to 0.05.

typeAlphaSpending

The type of alpha spending. One of the following: "OF" for O'Brien-Fleming boundaries, "P" for Pocock boundaries, "WT" for Wang & Tsiatis boundaries, "sfOF" for O'Brien-Fleming type spending function, "sfP" for Pocock type spending function, "sfKD" for Kim & DeMets spending function, "sfHSD" for Hwang, Shi & DeCani spending function, "user" for user defined spending, and "none" for no early efficacy stopping. Defaults to "sfOF".

parameterAlphaSpending

The parameter value for the alpha spending. Corresponds to Delta for "WT", rho for "sfKD", and gamma for "sfHSD".

userAlphaSpending

The user defined alpha spending. Cumulative alpha spent up to each stage.

milestone

The milestone time at which to calculate the restricted mean survival time.

rmstDiffLower

The lower equivalence limit of restricted mean survival time difference.

rmstDiffUpper

The upper equivalence limit of restricted mean survival time difference.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

interval

The interval to search for the solution of accrualDuration, followupDuration, or the proportionality constant of accrualIntensity. Defaults to c(0.001, 240).

spendingTime

A vector of length kMax for the error spending time at each analysis. Defaults to missing, in which case, it is the same as informationRates.

rounding

Whether to round up sample size. Defaults to 1 for sample size rounding.

Value

An S3 class rmpowerequiv object

Author(s)

Kaifeng Lu, [email protected]

See Also

rmpowerequiv

Examples

rmsamplesizeequiv(beta = 0.1, kMax = 2, informationRates = c(0.5, 1),
                  alpha = 0.05, typeAlphaSpending = "sfOF",
                  milestone = 18,
                  rmstDiffLower = -2, rmstDiffUpper = 2,
                  allocationRatioPlanned = 1, accrualTime = seq(0, 8),
                  accrualIntensity = 26/9*seq(1, 9),
                  piecewiseSurvivalTime = c(0, 6),
                  stratumFraction = c(0.2, 0.8),
                  lambda1 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
                  lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
                  gamma1 = -log(1-0.05)/12,
                  gamma2 = -log(1-0.05)/12, accrualDuration = NA,
                  followupTime = 18, fixedFollowup = FALSE)

Restricted mean survival time

Description

Obtains the restricted mean survival time over an interval.

Usage

rmst(t1 = 0, t2 = NA_real_, piecewiseSurvivalTime = 0L, lambda = NA_real_)

Arguments

t1

Lower bound of the analysis time interval.

t2

Upper bound of the analysis time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

lambda

A vector of hazard rates for the event. One for each analysis time interval.

Value

The integral of the survival function from t1 to t2

Author(s)

Kaifeng Lu, [email protected]

Examples

rmst(t1 = 0, t2 = 7, piecewiseSurvivalTime = c(0, 6),
     lambda = c(0.0533, 0.0309))

Stratified difference in restricted mean survival times

Description

Obtains the stratified restricted mean survival times and difference in restricted mean survival times at given calendar times.

Usage

rmstat(
  time = NA_real_,
  milestone = NA_real_,
  allocationRatioPlanned = 1,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  piecewiseSurvivalTime = 0L,
  stratumFraction = 1L,
  lambda1 = NA_real_,
  lambda2 = NA_real_,
  gamma1 = 0L,
  gamma2 = 0L,
  accrualDuration = NA_real_,
  followupTime = NA_real_,
  fixedFollowup = 0L
)

Arguments

time

A vector of calendar times at which to calculate the restricted mean survival time.

milestone

The milestone time at which to calculate the restricted mean survival time.

allocationRatioPlanned

Allocation ratio for the active treatment versus control. Defaults to 1 for equal randomization.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda1

A vector of hazard rates for the event in each analysis time interval by stratum for the active treatment group.

lambda2

A vector of hazard rates for the event in each analysis time interval by stratum for the control group.

gamma1

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the active treatment group.

gamma2

The hazard rate for exponential dropout, a vector of hazard rates for piecewise exponential dropout applicable for all strata, or a vector of hazard rates for dropout in each analysis time interval by stratum for the control group.

accrualDuration

Duration of the enrollment period.

followupTime

Follow-up time for the last enrolled subject.

fixedFollowup

Whether a fixed follow-up design is used. Defaults to 0 for variable follow-up.

Value

A data frame containing the following variables:

  • time: The calendar time at which to calculate the restricted mean survival time.

  • subjects: The number of enrolled subjects.

  • milestone: The milestone time relative to randomization.

  • rmst1: The restricted mean survival time for the treatment group.

  • rmst2: The restricted mean survival time for the control group.

  • rmstDiff: The difference in restricted mean survival times, i.e., rmst1 - rmst2.

  • vrmst1: The variance for rmst1.

  • vrmst2: The variance for rmst2.

  • vrmstDiff: The variance for rmstDiff.

  • information: The information for rmstDiff, equal to 1/vrmstDiff.

  • rmstDiffZ: The Z-statistic value, i.e., rmstDiff/sqrt(vrmstDiff).

Author(s)

Kaifeng Lu, [email protected]

Examples

# Piecewise accrual, piecewise exponential survivals, and 5% dropout by
# the end of 1 year.

rmstat(time = c(22, 40),
       milestone = 18,
       allocationRatioPlanned = 1,
       accrualTime = seq(0, 8),
       accrualIntensity = 26/9*seq(1, 9),
       piecewiseSurvivalTime = c(0, 6),
       stratumFraction = c(0.2, 0.8),
       lambda1 = c(0.0533, 0.0309, 1.5*0.0533, 1.5*0.0309),
       lambda2 = c(0.0533, 0.0533, 1.5*0.0533, 1.5*0.0533),
       gamma1 = -log(1-0.05)/12,
       gamma2 = -log(1-0.05)/12,
       accrualDuration = 22,
       followupTime = 18, fixedFollowup = FALSE)

Rank preserving structured failure time model (RPSFTM) for treatment switching

Description

Obtains the causal parameter estimate of the RPSFTM from the log-rank test and the hazard ratio estimate from the Cox model.

Usage

rpsft(
  data,
  stratum = "stratum",
  time = "time",
  event = "event",
  treat = "treat",
  rx = "rx",
  censor_time = "censor_time",
  base_cov = "none",
  low_psi = -1,
  hi_psi = 1,
  n_eval_z = 100L,
  alpha = 0.05,
  treat_modifier = 1,
  recensor = 1L,
  autoswitch = 1L,
  gridsearch = 0L,
  boot = 0L,
  n_boot = 1000L
)

Arguments

data

The input data frame that contains the following variables:

  • stratum: The stratum.

  • time: The survival time for right censored data.

  • event: The event indicator, 1=event, 0=no event.

  • treat: The randomized treatment indicator, 1=treatment, 0=control.

  • rx: The proportion of time on active treatment.

  • censor_time: The administrative censoring time. It should be provided for all subjects including those who had events.

  • base_cov: The values of baseline covariates. This is the full-rank design matrix (excluding treat) for the Cox model, assuming that factor variables have already been expanded into dummy variables.

stratum

The name of the stratum variable in the input data.

time

The name of the time variable in the input data.

event

The name of the event variable in the input data.

treat

The name of the treatment variable in the input data.

rx

The name of the rx variable in the input data.

censor_time

The name of the censor_time variable in the input data.

base_cov

The vector of names of baseline covariates (excluding treat) in the input data.

low_psi

The lower limit of the causal parameter of RPSFTM.

hi_psi

The upper limit of the causal parameter of RPSFTM.

n_eval_z

The number of points between low_psi and hi_psi at which to evaluate the log-rank Z-statistics.

alpha

The significance level to calculate confidence intervals.

treat_modifier

The optional sensitivity parameter for the constant treatment effect assumption.

recensor

Whether to apply recensoring to counter-factual survival times. Defaults to TRUE.

autoswitch

Whether to exclude recensoring for treatment arms with no switching. Defaults to TRUE.

gridsearch

Whether to use grid search to estimate the causal parameter psi. Defaults to FALSE, in which case, a root finding algorithm will be used.

boot

Whether to use bootstrap to obtain the confidence interval for hazard ratio. Defaults to FALSE, in which case, the confidence interval will be constructed to match the log-rank test p-value.

n_boot

The number of bootstrap samples.

Details

We use the following steps to obtain the hazard ratio estimate and confidence interval had there been no treatment switching:

  • use RPSFTM to estimate the causal parameter psi based on the log-rank test for counter-factual untreated survival times for both arms: U=Toff+ToneψU = T_{off} + T_{on} e^{\psi}.

  • Fit the Cox proportional hazards model to the observed survival times on the treatment arm and the counter-factual untreated survival times on the control arm to obtain the hazard ratio estimate.

  • Use either the log-rank test p-value for the treatment policy strategy or bootstrap to construct the confidence interval for hazard ratio.

Value

A list with the following components:

  • psi: The estimated causal parameter for RPSFTM.

  • psi_CI: The confidence interval for psi.

  • psi_type: The type of psi estimate, either "grid search" or "root finding".

  • Sstar: A data frame containing the counter-factual untreated survival times and the event indicators.

  • kmstar: A data frame containing the Kaplan-Meier estimates based on the counter-factual untreated survival times by treatment arm.

  • eval_z: A data frame containing the log-rank test Z-statistics evaluated at a sequence of psi values. Used to plot and to check if the range of psi values to search for the solution and limits of confidence interval of psi need be modified.

  • pvalue: The p-value of the log-rank test based on the treatment policy strategy.

  • hr: The estimated hazard ratio from the Cox model.

  • hr_CI: The confidence interval for hazard ratio.

  • hr_CI_type: The type of confidence interval for hazard ratio, either "log-rank p-value" or "bootstrap quantile".

Author(s)

Kaifeng Lu, [email protected]

Examples

library(dplyr)

data <- immdef %>% mutate(rx = 1-xoyrs/progyrs)

fit <- rpsft(data, time = "progyrs", event = "prog", treat = "imm",
             rx = "rx", censor_time = "censyrs", boot = 0)

c(fit$hr, fit$hr_CI)

Random number generation function of truncated piecewise exponential distribution

Description

Obtains random samples from a truncated piecewise exponential distribution.

Usage

rtpwexp(n, piecewiseSurvivalTime = 0, lambda = 0.0578, lowerBound = 0)

Arguments

n

The number of observations.

piecewiseSurvivalTime

A vector that specifies the starting time of piecewise exponential survival time intervals. Must start with 0, e.g., c(0, 6) breaks the time axis into 2 event intervals: [0, 6) and [6, Inf). Defaults to 0 for exponential distribution.

lambda

A vector of hazard rates for the event. One for each analysis time interval.

lowerBound

The left truncation time point for the survival time. Defaults to 0 for no truncation.

Value

The random numbers from truncated piecewise exponential distribution.

Author(s)

Kaifeng Lu, [email protected]

Examples

rtpwexp(n = 10, piecewiseSurvivalTime = c(0, 6, 9, 15),
        lambda = c(0.025, 0.04, 0.015, 0.007))

Run Shiny app

Description

Runs the log-rank test power and sample size calculation Shiny app.

Usage

runShinyApp()

Value

No return value, called for side effects.

Author(s)

Kaifeng Lu, [email protected]


Simon's two-stage design

Description

Obtains Simon's two-stage minimax, admissible, and optimal designs.

Usage

simon2stage(
  alpha = NA_real_,
  beta = NA_real_,
  piH0 = NA_real_,
  pi = NA_real_,
  n_max = 110L
)

Arguments

alpha

Type I error rate (one-sided).

beta

Type II error rate (1-power).

piH0

Response probability under the null hypothesis.

pi

Response probability under the alternative hypothesis.

n_max

Upper limit for sample size, defaults to 110.

Value

A data frame containing the following variables:

  • piH0: Response probability under the null hypothesis.

  • pi: Response probability under the alternative hypothesis.

  • alpha: The specified one-sided significance level.

  • beta: The specified type II error.

  • n: Total sample size.

  • n1: Stage 1 sample size.

  • r1: Futility boundary for stage 1.

  • r: Futility boundary for stage 2.

  • EN0: Expected sample size under the null hypothesis.

  • attainedAlpha: Attained type 1 error.

  • power: Attained power.

  • PET0: Probability of early stopping under the null hypothesis.

  • w_lower: Lower bound of the interval for w.

  • w_upper: Upper bound of the interval for w.

  • design: Description of the design, e.g., minimax, admissible, or optimal.

Here w is the weight in the objective function: w*n + (1-w)*EN0.

Author(s)

Kaifeng Lu, [email protected]

Examples

simon2stage(0.05, 0.15, 0.1, 0.3)

Analysis of Simon's Bayesian basket trials

Description

Obtains the prior and posterior probabilities for Simon's Bayesian basket discovery trials.

Usage

simonBayesAnalysis(
  nstrata = NA_integer_,
  r = NA_integer_,
  n = NA_integer_,
  lambda = NA_real_,
  gamma = NA_real_,
  phi = NA_real_,
  plo = NA_real_
)

Arguments

nstrata

The number of strata.

r

The vector of number of responders across strata.

n

The vector of number of subjects across strata.

lambda

The prior probability that the drug activity is homogeneous across strata.

gamma

The prior probability that the drug is active in a stratum.

phi

The response probability for an active drug.

plo

The response probability for an inactive drug.

Value

A list containing the following five components:

  • case: The matrix with each row corresponding to a combination of drug activity over strata represented by the columns.

  • prior_case: The vector of joint prior probabilities for the stratum-specific response rates.

  • prior_stratum: The vector of marginal prior probabilities for the stratum-specific response rates.

  • post_case: The vector of joint posterior probabilities for the stratum-specific response rates.

  • post_stratum: The vector of marginal posterior probabilities for the stratum-specific response rates.

Author(s)

Kaifeng Lu, [email protected]

Examples

a = simonBayesAnalysis(
  nstrata = 10,
  r = c(8,0,1,1,6,2,0,0,3,3),
  n = c(19,10,26,8,14,7,8,5,4,14),
  lambda = 0.5, gamma = 0.33,
  phi = 0.35, plo = 0.15)

a$post_stratum

Simulation of Simon's Bayesian basket trials

Description

Obtains the simulated raw and summary data for Simon's Bayesian basket discovery trials.

Usage

simonBayesSim(
  p = NA_real_,
  accrualTime = 0L,
  accrualIntensity = NA_real_,
  stratumFraction = 1L,
  lambda = NA_real_,
  gamma = NA_real_,
  phi = NA_real_,
  plo = NA_real_,
  T = NA_real_,
  maxSubjects = NA_integer_,
  plannedSubjects = NA_integer_,
  maxNumberOfIterations = 1000L,
  maxNumberOfRawDatasets = 1L,
  seed = NA_integer_
)

Arguments

p

The vector of true response probabilities across strata.

accrualTime

A vector that specifies the starting time of piecewise Poisson enrollment time intervals. Must start with 0, e.g., c(0, 3) breaks the time axis into 2 accrual intervals: [0, 3) and [3, Inf).

accrualIntensity

A vector of accrual intensities. One for each accrual time interval.

stratumFraction

A vector of stratum fractions that sum to 1. Defaults to 1 for no stratification.

lambda

The prior probability that the drug activity is homogeneous across strata.

gamma

The prior probability that the drug is active in a stratum.

phi

The response probability for an active drug.

plo

The response probability for an inactive drug.

T

The threshold for a conclusive posterior probability to stop enrollment.

maxSubjects

The maximum total sample size.

plannedSubjects

The planned cumulative number of subjects at each stage.

maxNumberOfIterations

The number of simulation iterations. Defaults to 1000.

maxNumberOfRawDatasets

The number of raw datasets to extract.

seed

The seed to reproduce the simulation results. The seed from the environment will be used if left unspecified,

Value

A list containing the following four components:

  • rawdata: A data frame for subject-level data, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage number.

    • subjectId: The subject ID.

    • arrivalTime: The enrollment time for the subject.

    • stratum: The stratum for the subject.

    • y: Whether the subject was a responder (1) or nonresponder (0).

  • sumdata1: A data frame for simulation and stratum-level summary data, containing the following variables:

    • iterationNumber: The iteration number.

    • stageNumber: The stage number.

    • stratum: The stratum number.

    • active: Whether the drug is active in the stratum.

    • n: The number of subjects in the stratum.

    • r: The number of responders in the stratum.

    • posterior: The posterior probability that the drug is active in the stratum.

    • open: Whether the stratum is still open for enrollment.

    • positive: Whether the stratum has been determined to be a positive stratum.

    • negative: Whether the stratum has been determined to be a negative stratum.

  • sumdata2: A data frame for the simulation level summary data, containing the following variables:

    • iterationNumber: The iteration number.

    • numberOfStrata: The total number of strata.

    • n_active_strata: The number of active strata.

    • true_positive: The number of true positive strata.

    • false_negative: The number of false negative strata.

    • false_positive: The number of false positive strata.

    • true_negative: The number of true negative strata.

    • n_indet_strata: The number of indeterminate strata.

    • numberOfSubjects: The number of subjects.

  • overview: A data frame for the summary across simulations, containing the following variables:

    • numberOfStrata: The total number of strata.

    • n_active_strata: The average number of active strata.

    • true_positive: The average number of true positive strata.

    • false_negative: The average number of false negative strata.

    • false_positive: The average number of false positive strata.

    • true_negative: The average number of true negative strata.

    • n_indet_strata: The average number of indeterminate strata.

    • numberOfSubjects: The average number of subjects.

Author(s)

Kaifeng Lu, [email protected]

Examples

sim1 = simonBayesSim(
  p = c(0.25, 0.25, 0.05),
  accrualIntensity = 5,
  stratumFraction = c(1/3, 1/3, 1/3),
  lambda = 0.33, gamma = 0.5,
  phi = 0.25, plo = 0.05,
  T = 0.8, maxSubjects = 50,
  plannedSubjects = seq(5, 50, 5),
  maxNumberOfIterations = 1000,
  maxNumberOfRawDatasets = 1,
  seed = 314159)

sim1$overview

Brookmeyer-Crowley confidence interval for quantiles of right-censored time-to-event data

Description

Obtains the Brookmeyer-Crowley confidence interval for quantiles of right-censored time-to-event data.

Usage

survQuantile(
  time = NA_real_,
  event = NA_real_,
  cilevel = 0.95,
  transform = "loglog",
  probs = c(0.25, 0.5, 0.75)
)

Arguments

time

The vector of possibly right-censored survival times.

event

The vector of event indicators.

cilevel

The confidence interval level. Defaults to 0.95.

transform

The transformation of the survival function to use to construct the confidence interval. Options include "linear", "loglog", "log", "asinsqrt", and "logit". Defaults to "loglog".

probs

The vector of probabilities to calculate the quantiles. Defaults to c(0.25, 0.5, 0.75).

Value

A data frame containing the estimated quantile and confidence interval corresponding to each specified probability. It includes the following variables:

  • prob: The probability to calculate the quantile.

  • quantile: The estimated quantile.

  • lower: The lower limit of the confidence interval.

  • upper: The upper limit of the confidence interval.

  • cilevel: The confidence interval level.

  • transform: The transformation of the survival function to use to construct the confidence interval.

Author(s)

Kaifeng Lu, [email protected]

Examples

survQuantile(
  time = c(33.7, 3.9, 10.5, 5.4, 19.5, 23.8, 7.9, 16.9, 16.6,
           33.7, 17.1, 7.9, 10.5, 38),
  event = c(0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1),
  probs = c(0.25, 0.5, 0.75))

Tobin's tobit data from the survival package

Description

Data from Tobin's original paper.

durable

Durable goods purchase

age

Age in years

quant

Liquidity ratio (x 1000)

Usage

tobin

Format

An object of class data.frame with 20 rows and 3 columns.


Update graph for graphical approaches

Description

Updates the weights and transition matrix for graphical approaches.

Usage

updateGraph(w, G, I, j)

Arguments

w

The current vector of weights for elementary hypotheses.

G

The current transition matrix.

I

The set of indices for yet to be rejected hypotheses.

j

The hypothesis to remove from index set I.

Value

A list containing the new vector of weights, the new transition matrix for the graph, and the new set of indices of yet to be rejected hypotheses.

Author(s)

Kaifeng Lu, [email protected]

Examples

updateGraph(w = c(0.5, 0.5, 0, 0),
            G = matrix(c(0, 0.5, 0.5, 0,  0.5, 0, 0, 0.5,
                         0, 1, 0, 0,  1, 0, 0, 0),
                       nrow=4, ncol=4, byrow=TRUE),
            I = c(1, 2, 3, 4),
            j = 1)

Miettinen-Nurminen score test statistic for two-sample odds ratio

Description

Obtains the Miettinen-Nurminen score test statistic for two-sample odds ratio possibly with stratification.

Usage

zstatOddsRatio(
  oddsRatioH0 = 1,
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_
)

Arguments

oddsRatioH0

The odds ratio under the null hypothesis. Defaults to 1.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Details

The Mantel-Haenszel sample size weights are used for stratified samples.

Value

The value of the score test statistic.

Author(s)

Kaifeng Lu, [email protected]

Examples

zstatOddsRatio(oddsRatioH0 = 1, n1 = c(10,10), y1 = c(4,3),
               n2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score test statistic for two-sample rate difference

Description

Obtains the Miettinen-Nurminen score test statistic for two-sample rate difference possibly with stratification.

Usage

zstatRateDiff(
  rateDiffH0 = 0,
  t1 = NA_real_,
  y1 = NA_real_,
  t2 = NA_real_,
  y2 = NA_real_
)

Arguments

rateDiffH0

The rate difference under the null hypothesis. Defaults to 0.

t1

The exposure for the active treatment group.

y1

The number of events for the active treatment group.

t2

The exposure for the control group.

y2

The number of events for the control group.

Details

The Mantel-Haenszel weights are used for stratified samples.

Value

The value of the score test statistic.

Author(s)

Kaifeng Lu, [email protected]

Examples

zstatRateDiff(rateDiffH0 = 0, t1 = c(10,10), y1 = c(4,3),
              t2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score test statistic for two-sample rate ratio

Description

Obtains the Miettinen-Nurminen score test statistic for two-sample rate ratio possibly with stratification.

Usage

zstatRateRatio(
  rateRatioH0 = 1,
  t1 = NA_real_,
  y1 = NA_real_,
  t2 = NA_real_,
  y2 = NA_real_
)

Arguments

rateRatioH0

The rate ratio under the null hypothesis. Defaults to 1.

t1

The exposure for the active treatment group.

y1

The number of events for the active treatment group.

t2

The exposure for the control group.

y2

The number of events for the control group.

Details

The Mantel-Haenszel weights are used for stratified samples.

Value

The value of the score test statistic.

Author(s)

Kaifeng Lu, [email protected]

Examples

zstatRateRatio(rateRatioH0 = 1, t1 = c(10,10), y1 = c(4,3),
               t2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score test statistic for two-sample risk difference

Description

Obtains the Miettinen-Nurminen score test statistic for two-sample risk difference possibly with stratification.

Usage

zstatRiskDiff(
  riskDiffH0 = 0,
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_
)

Arguments

riskDiffH0

The risk difference under the null hypothesis. Defaults to 0.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Details

The Mantel-Haenszel sample size weights are used for stratified samples.

Value

The value of the score test statistic.

Author(s)

Kaifeng Lu, [email protected]

Examples

zstatRiskDiff(riskDiffH0 = 0, n1 = c(10,10), y1 = c(4,3),
              n2 = c(20,10), y2 = c(2,0))

Miettinen-Nurminen score test statistic for two-sample risk ratio

Description

Obtains the Miettinen-Nurminen score test statistic for two-sample risk ratio possibly with stratification.

Usage

zstatRiskRatio(
  riskRatioH0 = 1,
  n1 = NA_real_,
  y1 = NA_real_,
  n2 = NA_real_,
  y2 = NA_real_
)

Arguments

riskRatioH0

The risk ratio under the null hypothesis. Defaults to 1.

n1

The sample size for the active treatment group.

y1

The number of responses for the active treatment group.

n2

The sample size for the control group.

y2

The number of responses for the control group.

Details

The Mantel-Haenszel sample size weights are used for stratified samples.

Value

The value of the score test statistic.

Author(s)

Kaifeng Lu, [email protected]

Examples

zstatRiskRatio(riskRatioH0 = 1, n1 = c(10,10), y1 = c(4,3),
               n2 = c(20,10), y2 = c(2,0))