Package 'EventPredInCure'

Title: Event Prediction Including Cured Population
Description: Predicts enrollment and events assumed enrollment and treatment-specific time-to-event models, and calculates test statistics for time-to-event data with cured population based on the simulation.Methods for prediction event in the existence of cured population are as described in : Chen, Tai-Tsang(2016) <doi:10.1186/s12874-016-0117-3>.
Authors: Bo Wei [aut, cre] , Kaifeng Lu [aut] , Brent McHenry [aut]
Maintainer: Bo Wei <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2025-03-09 03:57:15 UTC
Source: https://github.com/cran/EventPredInCure

Help Index


Event Prediction Including Cured Population

Description

Predicts enrollment and events using assumed enrollment and/or treatment-specific time-to-event models in the existence of the cured population. Calculate test statistics based on the simulated data sets from the assumed enrollment and/or treatment-specific time-to-event models in the existence of the cured population.

Details

Accurately predicting the date at which a target number of subjects or events will be achieved is critical for the planning, monitoring, and execution of clinical trials in the existence of the cured population. The EventPredInCure package provides enrollment and event prediction capabilities using assumed enrollment and treatment-specific time-to-event models and calculate test statistics based on the simulated data sets from the assumed enrollment and/or treatment-specific time-to-event models in the existence of the cured population.

At the design stage, enrollment is often specified using a piecewise Poisson process with a constant enrollment rate during each specified time interval. At the analysis stage, before enrollment completion, the EventPredInCure package considers several models, including the homogeneous Poisson model, the time-decay model with an enrollment rate function lambda(t) = mu/delta*(1 - exp(-delta*t)), the B-spline model with the daily enrollment rate lambda(t) = exp(B(t)*theta), and the piecewise Poisson model. If prior information exists on the model parameters, it can be combined with the likelihood to yield the posterior distribution.

The EventPredInCure package offers several time-to-event models without cured-population,including exponential, Weibull, log-logistic, log-normal, piecewise exponential, model averaging of Weibull and log-normal, and spline. The models including exponential, Weibull, log-logistic, log-normal, piecewise exponential are extended to account cured-population. In the design stage, the models including exponential, Weibull, log-logistic, log-normal, piecewise exponential are also extended for delayed treatment effect setting (only for generating simulated data sets in the design stage). For time to dropout, the same set of model without cured-population and delayed treatment effect options are considered. If enrollment is complete, ongoing subjects who have not had the event of interest or dropped out of the study before the data cut contribute additional events in the future. Their event times are generated from the conditional distribution given that they have survived at the data cut. For new subjects that need to be enrolled, their enrollment time and event time can be generated from the specified enrollment and time-to-event models with parameters drawn from the posterior distribution. Time-to-dropout can be generated in a similar fashion.

The EventPredInCure package displays the Akaike Information Criterion (AIC), the Bayesian Information Criterion (BIC) and a fitted curve overlaid with observed data to help users select the most appropriate model for enrollment and event prediction. Prediction intervals in the prediction plot can be used to measure prediction uncertainty, and the simulated enrollment and event data can be used for further data exploration.

The most useful function in the EventPredInCure package is getPrediction, which combines model fitting, data simulation, and a summary of simulation results. Other functions perform individual tasks and can be used to select an appropriate prediction model.

The EventPredInCure package implements a model parameterization that enhances the asymptotic normality of parameter estimates. Specifically, the package utilizes the following parameterization to achieve this goal:

  • Enrollment models

    • Poisson: theta = log(rate)

    • Time-decay: theta = c(log(mu), log(delta))

    • B-spline: no reparametrization is needed. The knots as considered fixed.

    • Piecewise Poisson: theta = log(rates). The left endpoints of time intervals, denoted as accrualTime, are considered fixed.

  • Event or dropout models

    • Exponential: theta = log(rate)

    • Weibull: theta = c(log(scale), -log(shape))

    • Log-logistic: theta = c(log(scale), -log(shape))

    • Log-normal: theta = c(meanlog, log(sdlog))

    • Piecewise exponential: theta = log(rates). The left endpoints of time intervals, denoted as piecewiseSurvivalTime for event model and piecewiseDropoutTime for dropout model, are considered fixed.

    • Model averaging: theta = c(log(weibull$scale), -log(weibull$shape), lnorm$meanlog, log(lnorm$sdlog)). The covariance matrix for theta is structured as a block diagonal matrix, with the upper-left block corresponding to the Weibull component and the lower-right block corresponding to the log-normal component. In other words, the covariance matrix is partitioned into two distinct blocks, with no off-diagonal elements connecting the two components. The weight assigned to the Weibull component, denoted as w1, is considered fixed.

    • Spline: theta corresponds to the coefficients of basis vectors. The knots and scale are considered fixed. The scale can be hazard, odds, or normal, corresponding to extensions of Weibull, log-logistic, and log-normal distributions, respectively.

The EventPredInCure package uses days as its primary time unit. If you need to convert enrollment or event rates per month to rates per day, simply divide by 30.4375.

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.

  • Royston, Patrick, and Mahesh KB Parmar. "Flexible parametric proportional‐hazards and proportional‐odds models for censored survival data, with application to prognostic modelling and estimation of treatment effects." Statistics in medicine 21.15 (2002): 2175-2197.

  • Bagiella, Emilia, and Daniel F. Heitjan. "Predicting analysis times in randomized clinical trials." Statistics in medicine 20.14 (2001): 2055-2063.

  • Ying, Gui‐shuang, and Daniel F. Heitjan. "Weibull prediction of event times in clinical trials." Pharmaceutical Statistics: The Journal of Applied Statistics in the Pharmaceutical Industry 7.2 (2008): 107-120.

  • Zhang, Xiaoxi, and Qi Long. "Stochastic modeling and prediction for accrual in clinical trials." Statistics in Medicine 29.6 (2010): 649-658.


Function to calculate survival time and censor variables before and post a time lag (delay treatment effect time)

Description

calculate survival time and censor variables before and post a time lag.

Usage

b4pst(os, osc, lag)

Arguments

os

a vector to denote the observed times

osc

a vector to denote censor variables

lag

a scalar to denote the time lag

Value

A list including the following variables:

  • b4os: overall survival time before the time lag

  • b4osc: censor variable before the time lag

  • pstos: overall survival time post the time lag

  • pstosc: censor variable post the time log lag

Examples

n <- 500
event <- runif(n,1, 5)
osc<-1*(event<=4)
os <- pmin(event,4)
b4pst(os,osc,3.5)

Function to generate event time in the existence of cured population

Description

generate event time under the delay-treatment effect and cured population setting

Usage

Chen_2016_event_time(u, hr, distribution, p, lag, a, b, mu, sd)

Arguments

u

a scalar with between 0 and 1

hr

hazard ratio if this subject in the corresponding arm vs control arm

distribution

the distribution for the control arm, valid values of inputs include: exponential, weibull, log-normal, log-logistic

p

the proportion of cured population in the control arm

lag

delayed treatment effect time after treatment initialization, when the hr between treatment arm and control =1 until lag time

a

the shape parameter in the Weibull or the log-logistic distribution

b

the scale parameter in the exponential, Weibull or the log-logistic distribution

mu

the mean in the log-normal distribution

sd

the standard deviation in the log-normal distribution

Value

the event time

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Function to generate event time based on Chen 2016 method for ongoing subject

Description

generate event time under the delay-treatment effect and cured population setting given T>time0

Usage

Chen_2016_event_time_abovetime0(u, distribution, p, time0, a, b, mu, sd)

Arguments

u

a scalar with between 0 and 1

distribution

the distribution for the control arm, valid values of inputs include: exponential, weibull, log-normal, log-logistic

p

the proportion of cured population in the control arm

time0

the observed ongoing survival time

a

the shape parameter in the Weibull or the log-logistic distribution

b

the scale parameter in the exponential, Weibull or the log-logistic distribution

mu

the mean in the log-normal distribution

sd

the standard deviation in the log-normal distribution

Value

the event time

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Function to generate event time with piecewise exponential distribution for ongoing subject in the existence of cured population

Description

generate event time under the delay-treatment effect and cured population setting

Usage

Chen_2016_event_time_piecewise_exp_abovetime0(
  u,
  p,
  time0 = 0,
  piecewiseSurvivalTime = 0,
  piecewisehazard
)

Arguments

u

a scalar with between 0 and 1, which is the conditional survival probability at the event time.

p

the proportion of cured population in the control arm

time0

the observed ongoing survival time

piecewiseSurvivalTime

A vector that specifies the time intervals for the piecewise exponential survival distribution. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

piecewisehazard

A vector that specifies the hazard rate in intervals for the piecewise exponential survival distribution.

Value

the event time

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Fleming-Harrington weighted log-rank tests

Description

Calculating the Fleming-Harrington weighted log-rank tests

Usage

FH_test(survival, delta, trt, rho, gamma, test = c("Futility"))

Arguments

survival

Time to event or censoring.

delta

Event indicators.

trt

Treatment assignment indicator with 1 denoting the treated group, and 0 denoting the placebo group.

rho

First power parameter for the Fleming-Harrington weight which weighs on the early departures: S(t)ρ(1S(t))γS(t^-)^\rho(1-S(t^-))^\gamma.

gamma

Second power parameter for the Fleming-Harrington weight which weighs on the late departures: S(t)ρ(1S(t))γS(t^-)^\rho(1-S(t^-))^\gamma.

test

a character denotes the test type, include "Superiority","Futility","Two-sided"

Value

A list 3 different components

O1

Observed number of weighted events (with a multiplication of corresponding weights) in the treatment arm.

E1

Expected number of weighted events (with a multiplication of corresponding weights) in the treatment arm.

Z

Weighted log-rank test statistic.

pvalue

Weighted log-rank test statistic pvalue

Examples

n <- 500
event <- runif(n,1, 5)
osc<-1*(event<=4)
os <- pmin(event,4)
trt<-c(rep(0,n/2),rep(1,n/2))
FH_test(os,osc,trt,rho=1,gamma=0)

Final enrollment and event data after achieving the target number of events

Description

A data frame with 300 rows and 7 columns:

trialsdt

The trial start date

usubjid

The unique subject ID

randdt

The randomization date

treatment

The treatment group number

treatment_description

Description of the treatment group

time

The day of event or censoring since randomization

event

The event indicator: 1 for event, 0 for non-event

dropout

The dropout indicator: 1 for dropout, 0 for non-dropout

cutoffdt

The cutoff date

For ongoing subjects, both event and dropout are equal to 0.

Usage

finalData

Format

An object of class tbl_df (inherits from tbl, data.frame) with 300 rows and 9 columns.


Fit time-to-dropout model

Description

Fits a specified time-to-dropout model to the dropout data.

Usage

fitDropout(
  df,
  dropout_model = "exponential",
  piecewiseDropoutTime = 0,
  by_treatment = FALSE,
  criterion = "both"
)

Arguments

df

The subject-level dropout data, including time and dropout. The data should also include treatment coded as 1, 2, and so on, and treatment_description for fitting the dropout model by treatment.

dropout_model

The dropout model used to analyze the dropout data which can be set to one of the following options: "exponential", "Weibull", "log-logistic", "log-normal", or "piecewise exponential". By default, it is set to "exponential".

piecewiseDropoutTime

A vector that specifies the time intervals for the piecewise exponential dropout distribution. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

by_treatment

A Boolean variable to control whether or not to fit the time-to-dropout data by treatment group. By default, it is set to FALSE.

criterion

A character variable to denote the criterion in model selection to shown in the figure, which can be set to one of the following options: "aic","bic" or "both". By default,it is set to both.

Value

A list of results from the model fit including key information such as the dropout model, model, the estimated model parameters, theta, the covariance matrix, vtheta, as well as the Bayesian Information Criterion, bic, and Akaike Information Criterion, aic.

If the piecewise exponential model is used, the location of knots used in the model, piecewiseDropoutTime, will be included in the list of results.

When fitting the dropout model by treatment, the outcome is presented as a list of lists, where each list element corresponds to a specific treatment group.

The fitted time-to-dropout survival curve is also returned.

References

  • Royston, Patrick, and Mahesh KB Parmar. "Flexible parametric proportional‐hazards and proportional‐odds models for censored survival data, with application to prognostic modelling and estimation of treatment effects." Statistics in medicine 21.15 (2002): 2175-2197.

Examples

dropout_fit <- fitDropout(df = interimData2,
                          dropout_model = "exponential")

Fit enrollment model

Description

Fits a specified enrollment model to the enrollment data.

Usage

fitEnrollment(
  df,
  enroll_model = "b-spline",
  nknots = 0,
  accrualTime = 0,
  criterion = "both"
)

Arguments

df

The subject-level enrollment data, including trialsdt, randdt and cutoffdt.

enroll_model

The enrollment model which can be specified as "Poisson", "Time-decay", "B-spline", or "Piecewise Poisson". By default, it is set to "B-spline".

nknots

The number of inner knots for the B-spline enrollment model. By default, it is set to 0.

accrualTime

The accrual time intervals for the piecewise Poisson model. Must start with 0, e.g., c(0, 30) breaks the time axis into 2 accrual intervals: [0, 30) and [30, Inf). By default, it is set to 0.

criterion

A character variable to denote the criterion in model selection to shown in the figure, which can be set to one of the following options: "aic","bic" or "both". By default,it is set to both.

Details

For the time-decay model, the mean function is mu(t) = mu/delta*(t - 1/delta*(1 - exp(-delta*t))) and the rate function is lambda(t) = mu/delta*(1 - exp(-delta*t)). For the B-spline model, the daily enrollment rate is approximated as lambda(t) = exp(B(t)*theta), where B(t) represents the B-spline basis functions.

Value

A list of results from the model fit including key information such as the enrollment model, model, the estimated model parameters, theta, the covariance matrix, vtheta, and the Bayesian Information Criterion, bic, and Akaike Information Criterion, aic, as well as the design matrix x for the B-spline enrollment model, and accrualTime for the piecewise Poisson enrollment model.

The fitted enrollment curve is also returned.

References

  • Zhang, Xiaoxi, and Qi Long. "Stochastic modeling and prediction for accrual in clinical trials." Statistics in Medicine 29.6 (2010): 649-658.

Examples

enroll_fit <- fitEnrollment(df = interimData1, enroll_model = "b-spline",
                            nknots = 1)

Fit time-to-event model

Description

Fits a specified time-to-event model to the event data.

Usage

fitEvent(
  df,
  event_model = "model averaging",
  piecewiseSurvivalTime = 0,
  k = 0,
  scale = "hazard",
  by_treatment = FALSE,
  criterion = "both"
)

Arguments

df

The subject-level event data, including time and event. The data should also include treatment coded as 1, 2, and so on, and treatment_description for fitting the event model by treatment.

event_model

The event model used to analyze the event data which can be set to one of the following options: "exponential", "Weibull", "log-logistic", "log-normal", "piecewise exponential", "model averaging", "spline","exponential with cured population","weibull with cured population", "log-normal with cured population","log-logistic with cured population" or "piecewise exponential with cured population". The model averaging uses the exp(-bic/2) weighting and combines Weibull and log-normal models. The spline model of Royston and Parmar (2002) assumes that a transformation of the survival function is modeled as a natural cubic spline function of log time. By default, it is set to "model averaging".

piecewiseSurvivalTime

A vector that specifies the time intervals for the piecewise exponential survival distribution or piecewise exponential with cured population. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

k

The number of inner knots of the spline. The default k=0 gives a Weibull, log-logistic or log-normal model, if scale is "hazard", "odds", or "normal", respectively. The knots are chosen as equally-spaced quantiles of the log uncensored survival times. The boundary knots are chosen as the minimum and maximum log uncensored survival times.

scale

If "hazard", the log cumulative hazard is modeled as a spline function. If "odds", the log cumulative odds is modeled as a spline function. If "normal", -qnorm(S(t)) is modeled as a spline function.

by_treatment

A Boolean variable to control whether or not to fit the time-to-event data by treatment group. By default, it is set to FALSE.

criterion

A character variable to denote the criterion in model selection to shown in the figure, which can be set to one of the following options: "aic","bic" or "both". By default,it is set to both.

Value

A list of results from the model fit including key information such as the event model, model, the estimated model parameters, theta, the covariance matrix, vtheta, as well as the Bayesian Information Criterion, bic, and Akaike Information Criterion, aic.

If the piecewise exponential model is used, the location of knots used in the model, piecewiseSurvivalTime, will be included in the list of results.

If the model averaging option is chosen, the weight assigned to the Weibull component is indicated by the w1 variable.

If the spline option is chosen, the knots and scale will be included in the list of results.

When fitting the event model by treatment, the outcome is presented as a list of lists, where each list element corresponds to a specific treatment group.

The fitted time-to-event survival curve is also returned.

References

  • Royston, Patrick, and Mahesh KB Parmar. "Flexible parametric proportional‐hazards and proportional‐odds models for censored survival data, with application to prognostic modelling and estimation of treatment effects." Statistics in medicine 21.15 (2002): 2175-2197.

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.

Examples

event_fit <- fitEvent(df = interimData2,
                      event_model = "piecewise exponential",
                      piecewiseSurvivalTime = c(0, 180))

Enrollment and event prediction

Description

Performs enrollment and event prediction by utilizing observed data and specified enrollment and event models.

Usage

getPrediction(
  df = NULL,
  to_predict = "enrollment and event",
  target_n = NA,
  target_d = NA,
  enroll_model = "b-spline",
  nknots = 0,
  lags = 30,
  accrualTime = 0,
  enroll_prior = NULL,
  event_model = "exponential",
  piecewiseSurvivalTime = 0,
  k = 0,
  scale = "hazard",
  event_prior = NULL,
  dropout_model = "exponential",
  piecewiseDropoutTime = 0,
  dropout_prior = NULL,
  fixedFollowup = FALSE,
  followupTime = 365,
  pilevel = 0.9,
  nyears = 4,
  nreps = 500,
  showEnrollment = TRUE,
  showEvent = TRUE,
  showDropout = FALSE,
  showOngoing = FALSE,
  by_treatment = FALSE,
  ngroups = 1,
  alloc = NULL,
  treatment_label = NULL,
  criterion = "both",
  seed.num = NULL
)

Arguments

df

The subject-level enrollment and event data, including trialsdt, usubjid, randdt, and cutoffdt for enrollment prediction, and, additionally, time, event, and dropout for event prediction. The data should also include treatment coded as 1, 2, and so on, and treatment_description for enrollment and event prediction by treatment. By default, it is set to NULL for enrollment and event prediction at the design stage.

to_predict

Specifies what to predict: "enrollment only", "event only", or "enrollment and event". By default, it is set to "enrollment and event".

target_n

The target number of subjects to enroll in the study.

target_d

The target number of events to reach in the study.

enroll_model

The enrollment model which can be specified as "Poisson", "Time-decay", "B-spline", "Piecewise Poisson" or "Piecewise Uniform". By default, it is set to "B-spline".

nknots

The number of inner knots for the B-spline enrollment model. By default, it is set to 0.

lags

The day lags to compute the average enrollment rate to carry forward for the B-spline enrollment model. By default, it is set to 30.

accrualTime

The accrual time intervals for the piecewise Poisson model. Must start with 0, e.g., c(0, 30) breaks the time axis into 2 accrual intervals: [0, 30) and [30, Inf). By default, it is set to 0.

enroll_prior

The prior of enrollment model parameters.

event_model

The event model used to analyze the event data which can be set to one of the following options: "exponential", "Weibull", "log-logistic", "log-normal", "piecewise exponential", "model averaging","exponential with cured population","weibull with cured population", "log-normal with cured population","log-logistic with cured population", or "piecewise exponential with cured population". For the design stage analysis, there are additional options:"exponential with cured population and delayed treatment", "weibull with cured population and delayed treatment", "log-normal with cured population and delayed treatment","log-logistic with cured population and delayed treatment" The model averaging uses the exp(-bic/2) weighting and combines Weibull and log-normal models. By default, it is set to "exponential".

piecewiseSurvivalTime

A vector that specifies the time intervals for the piecewise exponential survival distribution, or piecewise exponential with cured population. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

k

The number of inner knots of the spline event model of Royston and Parmar (2002). The default k=0 gives a Weibull, log-logistic or log-normal model, if scale is "hazard", "odds", or "normal", respectively. The knots are chosen as equally-spaced quantiles of the log uncensored survival times. The boundary knots are chosen as the minimum and maximum log uncensored survival times.

scale

If "hazard", the log cumulative hazard is modeled as a spline function. If "odds", the log cumulative odds is modeled as a spline function. If "normal", -qnorm(S(t)) is modeled as a spline function.

event_prior

The prior of event model parameters.

dropout_model

The dropout model used to analyze the dropout data which can be set to one of the following options: "exponential", "Weibull", "log-logistic", "log-normal", or "piecewise exponential". By default, it is set to "exponential".

piecewiseDropoutTime

A vector that specifies the time intervals for the piecewise exponential dropout distribution. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

dropout_prior

The prior of dropout model parameters.

fixedFollowup

A Boolean variable indicating whether a fixed follow-up design is used. By default, it is set to FALSE for a variable follow-up design.

followupTime

The follow-up time for a fixed follow-up design, in days. By default, it is set to 365.

pilevel

The prediction interval level. By default, it is set to 0.90.

nyears

The number of years after the data cut for prediction. By default, it is set to 4.

nreps

The number of replications for simulation. By default, it is set to 500.

showEnrollment

A Boolean variable to control whether or not to show the number of enrolled subjects. By default, it is set to TRUE.

showEvent

A Boolean variable to control whether or not to show the number of events. By default, it is set to TRUE.

showDropout

A Boolean variable to control whether or not to show the number of dropouts. By default, it is set to FALSE.

showOngoing

A Boolean variable to control whether or not to show the number of ongoing subjects. By default, it is set to FALSE.

by_treatment

A Boolean variable to control whether or not to predict by treatment group. By default, it is set to FALSE.

ngroups

The number of treatment groups for enrollment prediction at the design stage. By default, it is set to 1. It is replaced with the actual number of treatment groups in the observed data if df is not NULL.

alloc

The treatment allocation in a randomization block. By default, it is set to NULL, which yields equal allocation among the treatment groups.

treatment_label

The treatment labels for treatments in a randomization block for design stage prediction.

criterion

A character variable to denote the criterion in model selection to shown in the figure, which can be set to one of the following options: "aic","bic" or "both". By default,it is set to both.

seed.num

The number of the random seed. The default is NULL.

Details

For the time-decay model, the mean function is mu(t) = mu/delta*(t - 1/delta*(1 - exp(-delta*t))) and the rate function is lambda(t) = mu/delta*(1 - exp(-delta*t)). For the B-spline model, the daily enrollment rate is approximated as lambda(t) = exp(B(t)*theta), where B(t) represents the B-spline basis functions.

The enroll_prior variable should be a list that includes model to specify the enrollment model (poisson, time-decay, piecewise poisson, or piecewise uniform), theta and vtheta to indicate the parameter values and the covariance matrix. One can use a very small value of vtheta to fix the parameter values. For the piecewise Poisson enrollment or piecewise uniform rate model, the list should also include accrualTime. It should be noted that the B-spline model is not appropriate for use as prior.

For event prediction by treatment with prior information, the event_prior variable should be a list with one element per treatment. For each treatment, the element should include model to specify the event (dropout) model (exponential, weibull, log-logistic, log-normal, or piecewise exponential, weibull with cured population,exponential with cured population,log-normal with cured population, log-logistic with cured population,piecewise exponential with cured population, exponential with cured population and delayed treatment,weibull with cured population and delayed treatment, log-normal with cured population and delayed treatment,log-logistic with cured population and delayed treatment), theta and vtheta to indicate the parameter values and the covariance matrix. For the piecewise exponential or piecewise exponential with cured population or piecewise exponential with cured population and delayed treatment event model, the list should also include piecewiseSurvivalTime to indicate the location of knots. It should be noted that the model averaging and spline options are not appropriate for use as prior.

The dropout_prior should be a list with one element per treatment. For each treatment, the element should include w to specify the weight of the treatment in a randomization block, model to specify the dropout model (exponential, weibull, log-logistic, log-normal, or piecewise exponential), theta and vtheta to indicate the parameter values and the covariance matrix. For the piecewise exponential dropout model, the list should also include piecewiseDropoutTime to indicate the location of knots.

If the event prediction is not by treatment while the prior information is given by treatment, then each element of event_prior (dropout_prior) should also include w to specify the weight of the treatment in a randomization block. This method can only be used in the event prior with exponential, weibull, log-logistic, log-normal, or piecewise exponential.

If the prediction is not by treatment and the prior is given for the overall study, then event_prior (dropout_prior) is a flat list with model, theta, and vtheta. For the piecewise exponential event (dropout) model, it should also include piecewiseSurvivalTime (piecewiseDropoutTime) to indicate the location of knots.

For analysis-stage enrollment and event prediction, the enroll_prior, event_prior, and dropout_prior are either set to NULL to use the observed data only, or specify the prior distribution of model parameters to be combined with observed data likelihood for enhanced modeling flexibility.

Value

A list that includes the fits of observed data models, as well as simulated enrollment data for new subjects and simulated event data for ongoing and new subjects.

Examples

fit1 <- list(model = "piecewise uniform",
             theta = -0.58, 
             vtheta=0, accrualTime =0)
             
fit2<-list()
fit2[[1]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(-2.2,0,6.5,0,1), 
                  vtheta = matrix(0,5,5))
fit2[[2]] <- list(model = "weibull with cured population and delayed treatment", 
                 theta = c(-2.2,0,6.5,46,0.65), 
                 vtheta = matrix(0,5,5))

fit3 <- list()

fit3[[1]] <- list(model = "exponential", 
                   theta =log(0.0003), 
                   vtheta=0)
fit3[[2]] <- list(model = "exponential", 
                   theta =log(0.0003), 
                   vtheta=0)
                   
getPrediction(target_n=200,target_d=60,lags=46,enroll_prior=fit1,
              event_prior=fit2,
              dropout_prior=fit3,ngroups=2)

Interim enrollment and event data before enrollment completion

Description

A data frame with 225 rows and 9 columns:

trialsdt

The trial start date

usubjid

The unique subject ID

randdt

The randomization date

treatment

The treatment group number

treatment_description

Description of the treatment group

time

The day of event or censoring since randomization

event

The event indicator: 1 for event, 0 for non-event

dropout

The dropout indicator: 1 for dropout, 0 for non-dropout

cutoffdt

The cutoff date

For ongoing subjects, both event and dropout are equal to 0.

Usage

interimData1

Format

An object of class tbl_df (inherits from tbl, data.frame) with 224 rows and 9 columns.


Interim enrollment and event data after enrollment completion

Description

A data frame with 300 rows and 7 columns:

trialsdt

The trial start date

usubjid

The unique subject ID

randdt

The randomization date

treatment

The treatment group number

treatment_description

Description of the treatment group

time

The day of event or censoring since randomization

event

The event indicator: 1 for event, 0 for non-event

dropout

The dropout indicator: 1 for dropout, 0 for non-dropout

cutoffdt

The cutoff date

For ongoing subjects, both event and dropout are equal to 0.

Usage

interimData2

Format

An object of class tbl_df (inherits from tbl, data.frame) with 300 rows and 9 columns.


Log-likelihood function for exponential distribution with cured population

Description

Provide log-likelihood function for exponential distribution with cured population

Usage

loglik_Chen_exponential(par, df)

Arguments

par

a vector with two elements, where the first element denotes the logistic of the proportion of the cured population, and the second element denotes the log of the hazard rate.

df

The subject-level event data, including time and event.

Value

The negative value of the log-likelihood function given parameter par and the dataset df

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Log-likelihood function for log-logistic distribution with cured population

Description

Provide log-likelihood function for log-logistic distribution with cured population

Usage

loglik_Chen_log_logistic(par, df)

Arguments

par

a vector with three elements, where the first element denotes the logistic of the proportion of the cured population, and the second element and the third element denote the log of shape and the log of the scale parameter of the log-logistic distribution.

df

The subject-level event data, including time and event.

Value

The negative value of the log-likelihood function given parameter par and the dataset df

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Log-likelihood function for log-normal distribution with cured population

Description

Provide log-likelihood function for log-normal distribution with cured population

Usage

loglik_Chen_log_normal(par, df)

Arguments

par

a vector with three elements, where the first element denotes the logistic of the proportion of the cured population, and the second element and the third element denote the mean and the log of standard deviation parameter of the log-normal distribution.

df

The subject-level event data, including time and event.

Value

The negative value of the log-likelihood function given parameter par and the dataset df

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Log-likelihood function for piecewise-exponential distribution with cured population

Description

Provide log-likelihood function for piecewise-exponential distribution with cured population

Usage

loglik_Chen_piecewise_exponential(par = NULL, df, piecewiseSurvivalTime)

Arguments

par

a vector with m+1 elements, where the first element denotes the logistic of the proportion of the cured population, and the rest element denotes the log of the hazard rate in intervals

df

The subject-level event data, including time and event.

piecewiseSurvivalTime

A vector with length m that specifies the time intervals for the piecewise exponential survival distribution. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

Value

The negative value of the log-likelihood function given parameter par and the dataset df

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Log-likelihood function for Weibull distribution with cured population

Description

Provide log-likelihood function for Weibull distribution with cured population

Usage

loglik_Chen_weibull(par, df)

Arguments

par

a vector with three elements, where the first element denotes the logistic of the proportion of the cured population, and the second element and the third element denote the log of the shape and log of the scale parameter of the Weibull distribution.

df

The subject-level event data, including time and event.

Value

The negative value of the log-likelihood function given parameter par and the dataset df

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Predict enrollment

Description

Utilizes a pre-fitted enrollment model to generate enrollment times for new subjects and provide a prediction interval for the expected time to reach the enrollment target.

Usage

predictEnrollment(
  df = NULL,
  target_n,
  enroll_fit,
  lags = 1,
  pilevel = 0.9,
  nyears = 4,
  nreps = 500,
  by_treatment = FALSE,
  ngroups = 1,
  alloc = NULL,
  treatment_label = NULL,
  seed.num = NULL
)

Arguments

df

The subject-level enrollment data, including trialsdt, randdt and cutoffdt. The data should also include treatment coded as 1, 2, and so on, and treatment_description for prediction by treatment group. By default, it is set to NULL for enrollment prediction at the design stage.

target_n

The target number of subjects to enroll in the study.

enroll_fit

The pre-fitted enrollment model used to generate predictions.

lags

The day lags to compute the average enrollment rate to carry forward for the B-spline enrollment model. By default, it is set to 1.

pilevel

The prediction interval level. By default, it is set to 0.90.

nyears

The number of years after the data cut for prediction. By default, it is set to 4.

nreps

The number of replications for simulation. By default, it is set to 500.

by_treatment

A Boolean variable to control whether or not to predict enrollment by treatment group. By default, it is set to FALSE.

ngroups

The number of treatment groups for enrollment prediction at the design stage. By default, it is set to 1. It is replaced with the actual number of treatment groups in the observed data if df is not NULL.

alloc

The treatment allocation in a randomization block. By default, it is set to NULL, which yields equal allocation among the treatment groups.

treatment_label

The treatment labels for treatments in a randomization block for design stage prediction.

seed.num

The number of the random seed. The default is NULL.

Details

The enroll_fit variable can be used for enrollment prediction at the design stage. A piecewise uniform can be parameterized through the time intervals, accrualTime, which is treated as fixed, and the enrollment rates in the intervals, accrualrate, the number of patients in each intervals. A piecewise Poisson model can be parameterized through the time intervals, accrualTime, which is treated as fixed, and the enrollment rates in the intervals, accrualIntensity, the log of which is used as the model parameter. For the homogeneous Poisson, time-decay, and piecewise Poisson models, enroll_fit is used to specify the prior distribution of model parameters, with a very small variance being used to fix the parameter values. It should be noted that the B-spline model is not appropriate for use during the design stage.

During the enrollment stage, enroll_fit is the enrollment model fit based on the observed data. The fitted enrollment model is used to generate enrollment times for new subjects.

Value

A list of prediction results, which includes important information such as the median, lower and upper percentiles for the estimated time to reach the target number of subjects, as well as simulated enrollment data for new subjects. The data for the prediction plot is also included within the list.

References

Xiaoxi Zhang and Qi Long. Stochastic modeling and prediction for accrual in clinical trials. Stat in Med. 2010; 29:649-658.

Examples

# Enrollment prediction at the design stage
fit1 <- list(model = "piecewise uniform",
             theta = -0.58, 
             vtheta=0, accrualTime =0)
                  
 predictEnrollment(df = NULL, target_n=200, enroll_fit = fit1,lags=46,
                                  pilevel=0.9, nyears=4, nreps=100,by_treatment=TRUE,
                                  ngroups=2, alloc=c(1,1), treatment_label=c('a','b'))

Predict event time for ongoing subjects with or without cured population.

Description

Utilizes pre-fitted time-to-event and time-to-dropout models to generate event and dropout times for ongoing subjects and new subjects. It also provides a prediction interval for the expected time to reach the target number of events.

Usage

predictEvent(
  df = NULL,
  target_d,
  newSubjects = NULL,
  event_fit,
  dropout_fit = NULL,
  fixedFollowup = FALSE,
  followupTime = 365,
  pilevel = 0.9,
  nyears = 4,
  nreps = 500,
  showEnrollment = TRUE,
  showEvent = TRUE,
  showDropout = FALSE,
  showOngoing = FALSE,
  by_treatment = FALSE,
  seed.num = NULL
)

Arguments

df

The subject-level enrollment and event data, including randdt, cutoffdt, time, event, and dropout. By default, it is set to NULL for event prediction at the design stage.

target_d

The target number of events to reach in the study.

newSubjects

The enrollment data for new subjects including draw and arrivalTime. By default, it is set to NULL, indicating the completion of subject enrollment.

event_fit

The pre-fitted event model used to generate predictions.

dropout_fit

The pre-fitted dropout model used to generate predictions. By default, it is set to NULL, indicating no dropout.

fixedFollowup

A Boolean variable indicating whether a fixed follow-up design is used. By default, it is set to FALSE for a variable follow-up design.

followupTime

The follow-up time for a fixed follow-up design, in days. By default, it is set to 365.

pilevel

The prediction interval level. By default, it is set to 0.90.

nyears

The number of years after the data cut for prediction. By default, it is set to 4.

nreps

The number of replications for simulation. By default, it is set to 500. If newSubjects is not NULL, the number of draws in newSubjects should be nreps.

showEnrollment

A Boolean variable to control whether or not to show the number of enrolled subjects. By default, it is set to TRUE.

showEvent

A Boolean variable to control whether or not to show the number of events. By default, it is set to TRUE.

showDropout

A Boolean variable to control whether or not to show the number of dropouts. By default, it is set to FALSE.

showOngoing

A Boolean variable to control whether or not to show the number of ongoing subjects. By default, it is set to FALSE.

by_treatment

A Boolean variable to control whether or not to predict event by treatment group. By default, it is set to FALSE.

seed.num

The number of the random seed. The default is NULL.

Details

To ensure successful event prediction at the design stage, it is important to provide the newSubjects data set.

To specify the event model used during the design-stage event prediction, the event_fit be a list with one element per treatment. For each treatment, the element should include w to specify the weight of the treatment in a randomization block, model to specify the event model (exponential, weibull, log-logistic, log-normal, or piecewise exponential, weibull with cured population,exponential with cured population,log-normal with cured population, log-logistic with cured population,piecewise exponential with cured population, exponential with cured population and delayed treatment,weibull with cured population and delayed treatment, log-normal with cured population and delayed treatment,log-logistic with cured population and delayed treatment), theta and vtheta to indicate the parameter values and the covariance matrix. For the piecewise exponential or piecewise exponential with cured population or piecewise exponential with cured population and delayed treatment event model, the list should also include piecewiseSurvivalTime to indicate the location of knots. It should be noted that the model averaging and spline options are not appropriate for use as prior.

To specify the dropout model used during the design stage event prediction, the dropout_fit should be a list with one element per treatment. For each treatment, the element should include w to specify the weight of the treatment in a randomization block, model to specify the dropout model (exponential, weibull, log-logistic, log-normal, or piecewise exponential), theta and vtheta to indicate the parameter values and the covariance matrix. For the piecewise exponential dropout model, the list should also include piecewiseDropoutTime to indicate the location of knots.

Following the commencement of the trial, we obtain the event model fit and the dropout model fit based on the observed data, denoted as event_fit and dropout_fit, respectively. These fitted models are subsequently utilized to generate event and dropout times for both ongoing and new subjects in the trial.

Value

A list of prediction results which includes important information such as the median, lower and upper percentiles for the estimated day and date to reach the target number of events, as well as simulated event data for both ongoing and new subjects. The data for the prediction plot is also included within this list.

References

  • Bagiella, Emilia, and Daniel F. Heitjan. "Predicting analysis times in randomized clinical trials." Statistics in medicine 20.14 (2001): 2055-2063.

  • Ying, Gui‐shuang, and Daniel F. Heitjan. "Weibull prediction of event times in clinical trials." Pharmaceutical Statistics: The Journal of Applied Statistics in the Pharmaceutical Industry 7.2 (2008): 107-120.

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.

Examples

fit1 <- list(model = "piecewise uniform",
             theta = -0.58, 
             vtheta=0, accrualTime =0)
fit2<-list()
fit2[[1]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(-2.2,0,6.5,0,1), 
                  vtheta = matrix(0,5,5))
fit2[[2]] <- list(model = "weibull with cured population and delayed treatment", 
                 theta = c(-2.2,0,6.5,46,0.65), 
                 vtheta = matrix(0,5,5))
                  
 enroll_pred <- predictEnrollment(df = NULL, target_n=200, enroll_fit = fit1,lags=46,
                                  pilevel=0.9, nyears=4, nreps=100,by_treatment=TRUE,
                                  ngroups=2, alloc=c(1,1), treatment_label=c('a','b'))

 event_pred <- predictEvent(df = NULL, target_d=60,
                            newSubjects = enroll_pred$newSubjects,
                            event_fit = fit2,dropout_fit = NULL,
                            pilevel=0.9, 
                            nyears=4, 
                            nreps=100,
                            by_treatment=TRUE)

Function to output summary statistics from survfit function output

Description

Provide summary statistics from survfit function output

Usage

smed(x)

Arguments

x

an object returned by "survfit"

Value

"smed" returns a matrix of 5 columns of

Examples

n <- 500
event <- runif(n,1, 5)
osc<-1*(event<=4)
os <- pmin(event,4)

fit1<-survival::survfit(survival::Surv(os,osc)~1)
smed(fit1)

Survival probability function of the exponential distribution with cured population

Description

Calculate survival probability of the exponential distribution with cured population

Usage

SP_Chen_exponential(par, t)

Arguments

par

a vector with two elements, where the first element denotes the logistic of the proportion of the cured population, and the second element denotes the log of the hazard rate.

t

a vector with non-negative elements.

Value

Survival probability of the exponential distribution with cured population given parameters par at times t.

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Survival probability function of the log-logistic distribution with cured population

Description

Calculate survival probability of the log-logistic distribution with cured population

Usage

SP_Chen_log_logistic(par, t)

Arguments

par

a vector with three elements, wwhere the first element denotes the logistic of the proportion of the cured population, and the second element and the third element denote the log of shape and the log of the scale parameter of the log-logistic distribution.

t

a vector with non-negative elements.

Value

Survival probability of the log-logistic distribution with cured population given parameters par at times t.

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Survival probability function of the log-normal distribution with cured population

Description

Calculate survival probability of the log-normal distribution with cured population

Usage

SP_Chen_log_normal(par, t)

Arguments

par

a vector with three elements, where the first element denotes the logistic of the proportion of the cured population, and the second element and the third element denote the mean and the log of standard deviation parameter of the log-normal distribution.

t

a vector with non-negative elements.

Value

Survival probability of the log-normal distribution with cured population given parameters par at times t.

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Survival probability function of the piecewise exponential distribution with cured population

Description

Calculate survival probability of the piecewise exponential distribution with cured population

Usage

SP_Chen_piecewise_exponential(par, t, piecewiseSurvivalTime)

Arguments

par

a vector with m+1 elements, where the first element denotes the logistic of the proportion of the cured population, and the rest element denotes the log of the hazard rate in intervals

t

a vector with non-negative elements.

piecewiseSurvivalTime

A vector that specifies the time intervals for the piecewise exponential survival distribution. Must start with 0, e.g., c(0, 60) breaks the time axis into 2 event intervals: [0, 60) and [60, Inf). By default, it is set to 0.

Value

Survival probability of the piecewise-exponential distribution with cured population given parameters par at times t.

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Survival probability function of the Weibull distribution with cured population

Description

Calculate survival probability of the Weibull distribution with cured population

Usage

SP_Chen_weibull(par, t)

Arguments

par

a vector with three elements, where the first element denotes the logistic of the proportion of the cured population, and the second element and the third element denote the log of the shape and log of the scale parameter of the Weibull distribution.

t

a vector with non-negative elements.

Value

Survival probability of the Weibull distribution with cured population given parameters par at times t.

References

  • Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." BMC medical research methodology 16.1 (2016): 1-10.


Summarize observed data

Description

Provides an overview of the observed data, including the trial start date, data cutoff date, enrollment duration, number of subjects enrolled, number of events and dropouts, number of subjects at risk, cumulative enrollment and event data, daily enrollment rates, and Kaplan-Meier plots for time to event and time to dropout.

Usage

summarizeObserved(
  df,
  to_predict = "event only",
  showplot = TRUE,
  by_treatment = FALSE
)

Arguments

df

The subject-level data, including trialsdt, usubjid, randdt, and cutoffdt for enrollment prediction, as well as time, event and dropout for event prediction, and treatment coded as 1, 2, and so on, and treatment_description for prediction by treatment group.

to_predict

Specifies what to predict: "enrollment only", "event only", or "enrollment and event". By default, it is set to "event only".

showplot

A Boolean variable to control whether or not to show the observed data plots. By default, it is set to TRUE.

by_treatment

A Boolean variable to control whether or not to summarize observed data by treatment group. By default, it is set to FALSE.

Value

A list that includes a range of summary statistics, data sets, and plots depending on the value of to_predict.

Examples

observed1 <- summarizeObserved(df = interimData1,
                               to_predict = "enrollment and event")

Function to plot KM plot for time-to-event data in simulation

Description

Plot KM plot for each arm at one realization

Usage

test_plot(test0, plot.index = 1)

Arguments

test0

an object obtained from test_procedure

plot.index

the index of simulation

Value

A KM plot for events in each arm

Examples

fit1 <- list(model = "piecewise uniform",
             theta = -0.58, 
             vtheta=0, accrualTime =0)
fit2<-list()
fit2[[1]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(0.5,0,6.5,0,1), 
                  vtheta = matrix(0,5,5))
fit2[[2]] <- list(model = "weibull with cured population and delayed treatment", 
                 theta = c(0.5,0,6.5,46,0.65), 
                 vtheta = matrix(0,5,5))
fit3<-list()
fit3[[1]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(0.5,0,6.5,0,1), 
                  vtheta = matrix(0,5,5))
fit3[[2]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(0.5,0,6.5,0,1),
                  vtheta = matrix(0,5,5))
fit4 <- list(model = "exponential", 
                   theta =log(0.0003), 
                   vtheta=0)
                   
test1<-test_procedure(pilevel=0.9,nyears=4,enroll_fit=fit1,
                      dropout_fit=fit4,enroll_prior=fit1,event_prior_h0=fit3,
                      event_prior_ha=fit2,dropout_prior=NULL,
                      target_n=200,target_IA_d=40,
                      target_d=60,ialpha=0.016,falpha=0.0450,
                      lag=46,by_fitted_enroll=FALSE,
                      by_fitted_dropout=FALSE,treatment_label=c('a','b'),
                      ngroups=2,alloc=c(1,1),nreps=10, IA_included=TRUE)
test_plot(test1)

Function to provide summary and test statistics based on simulation.

Description

Provides summary and test statistics based on simulation.

Usage

test_procedure(
  pilevel = 0.9,
  nyears = 4,
  enroll_fit = enroll_fit,
  dropout_fit = dropout_fit,
  enroll_prior = NULL,
  event_prior_h0 = NULL,
  event_prior_ha = NULL,
  dropout_prior = NULL,
  target_n,
  target_IA_d,
  target_d,
  ialpha = 0.025,
  falpha,
  lag,
  by_fitted_enroll = FALSE,
  by_fitted_dropout = FALSE,
  treatment_label,
  ngroups = 2,
  alloc = NULL,
  nreps = 500,
  IA_included,
  test = "Superiority",
  test_IA = "Superiority",
  Futility_boundary = 1,
  seed.num = NULL
)

Arguments

pilevel

the confidence interval, the default is 0.95.

nyears

the year after data cutoff or follow-up.

enroll_fit

an object generated from fitEnrollment.

dropout_fit

an object generated from fitDropout.

enroll_prior

The prior of enrollment model parameters.

event_prior_h0

The prior of event model parameters under null hypothesis

event_prior_ha

The prior of event model parameters under alternative hypothesis

dropout_prior

The prior of dropout model parameters.

target_n

The target number of subjects to enroll in the study.

target_IA_d

number of events needed for interim analysis

target_d

number of events needed for primary analysis

ialpha

interim analysis alpha nominal value (only one interim allowed)

falpha

primary analysis alpha nominal value

lag

a scalar to denote time (days). Hazard ratio before and after this time would be calculated.

by_fitted_enroll

A Boolean variable to control whether or not to predict enrollment time with fitted model. By default, it is set to FALSE.

by_fitted_dropout

A Boolean variable to control whether or not to predict dropout time with fitted model. By default, it is set to FALSE.

treatment_label

The treatment labels for treatments in a randomization block for design stage prediction.

ngroups

The number of treatment groups for enrollment prediction at the design stage. By default, it is set to 2. It is replaced with the actual number of treatment groups in the observed data if df is not NULL.

alloc

The treatment allocation in a randomization block. By default, it is set to NULL, which yields equal allocation among the treatment groups.

nreps

The number of replications for simulation. By default, it is set to 500.

IA_included

A Boolean variable to control whether or not to include one interim analysis. By default, it is set to FALSE.

test

a character denotes the test type, includes "Superiority","Futility","Two-sided"

test_IA

a character denotes the test type in interim analysis, includes "Efficacy","Futility",or "Efficacy and Futility"

Futility_boundary

a positive number denotes the boundary of the Futility in the scale of hazard ratio

seed.num

The number of the random seed. The default is NULL.

Value

A list with following components

  • iteration0 - the number of simulations that achieved target number of events in interim analysis and primary analysis under null hypothesis.

  • iteration1 - the number of simulations that achieved target number of events in interim analysis and primary analysis under alternative hypothesis.

  • simu_summary - the summary table of number of simulations that achieved or do not achieve target number of events in each analysis under null hypothesis and alternative hypothesis.

  • power - the alpha and powers from log-rank test and Fleming&Harrington test

  • samplesize - the counts per arm and total, includes the number of patients, events at interim analysis and primary analysis, events at interim analysis before delay, events at primary analysis before delay

  • hzratio - average hazard ratio at primary analysis and interim analysis

  • hzrc - Frequencies of hazard ratios in specific zones

  • hzratio2 - HR before and after delay

  • median - Medians of survival time at interim analysis and primary analysis

  • osrate - survival rate at milestones (1, 2 and 4 years)

  • duration - Study duration for enrollment, interim analysis and primary analysis

  • duration1 - Durations for interim analysis and primary analysis with 95% CI

  • textH0 - the summary text of number of simulations that achieved or do not achieve target number of events in primary analysis under null hypothesis.

  • textHA - the summary text of number of simulations that achieved or do not achieve target number of events in primary analysis under alternative hypothesis.

Examples

fit1 <- list(model = "piecewise uniform",
             theta = -0.58, 
             vtheta=0, accrualTime =0)
fit2<-list()
fit2[[1]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(-2.2,0,6.5,0,1), 
                  vtheta = matrix(0,5,5))
fit2[[2]] <- list(model = "weibull with cured population and delayed treatment", 
                 theta = c(-2.2,0,6.5,46,0.65), 
                 vtheta = matrix(0,5,5))
fit3 <-list()
fit3[[1]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(-2.2,0,6.5,0,1), 
                  vtheta = matrix(0,5,5))
fit3[[2]] <- list(model = "weibull with cured population and delayed treatment", 
                  theta = c(-2.2,0,6.5,0,1),
                  vtheta = matrix(0,5,5))
fit4 <-list()

fit4[[1]] <- list(model = "exponential", 
                   theta =log(0.0003), 
                   vtheta=0)
fit4[[2]] <- list(model = "exponential", 
                   theta =log(0.0003), 

                   vtheta=0)
test1<-test_procedure(pilevel=0.9,nyears=4,enroll_fit=fit1,
                      dropout_fit=fit4,enroll_prior=fit1,event_prior_h0=fit3,
                      event_prior_ha=fit2,dropout_prior=NULL,
                      target_n=200,target_IA_d=40,target_d=60,
                      ialpha=0.016,falpha=0.0450,
                      lag=46,by_fitted_enroll=FALSE,
                      by_fitted_dropout=FALSE,treatment_label=c('a','b'),
                      ngroups=2,alloc=c(1,1),nreps=100, IA_included=TRUE)

Calculating log-rank test p-value, median time from each arm, hazard ratio between two arms, number of subjects and events in time-to-event outcomes.

Description

Calculate log-rank test p-value, median time from each arm, HR between arms, number of subjects and events

Usage

tte(os, osc, grp, type, test = "Futility")

Arguments

os

Time to event variable

osc

Time to event censoring variable

grp

Treatment assignment indicator with 1 denoting the treated group, and 0 denoting the placebo group.

type

either "all" or "logrank" or "hr"

test

a character denotes the test type, include "Superiority","Futility","Two-sided"

Details

The control arm

Value

If type='all', return a list that includes the log-rank p-value, median time from each arm, hazard ratio between arms, and 95% confidence interval of hazard ratio, number of subjects and events; and events If type='logrank', return a list that includes the log-rank p-value, number of subjects and events; If type='hr', return a list that includes hazard ratio between arms, and 95% confidence interval of hazard ratio

Examples

n <- 500
event <- runif(n,1, 5)
osc<-1*(event<=4)
os <- pmin(event,4)
trt<-c(rep(0,n/2),rep(1,n/2))
tte(os,osc,trt,type='all')