nphsim: Simulate a Clinical Trial with Piecewise Exponential...

Description Usage Arguments Details Value Examples

View source: R/nphSim.R

Description

Simulate two-arm time-to-event data using the piecewise exponential distribution rpwexp(). User can specify enrollment speed as well as drop out rate separately for each arm. Additionaly if user has created a gsSurv object from gsDesign it can be used as input to supply simulation parameters. The only censoring mechanism is from dropout of the study and no administrative censoring is implemented. The administrative censoring (such as interim or final analysis) are implemented in the simtest() function.

Usage

1
2
3
nphsim(nsim = 100, lambdaC = NULL, lambdaE = NULL, intervals = NULL,
  ssC = NULL, ssE = NULL, gamma = NULL, R = NULL,
  fixEnrollTime = TRUE, eta = NULL, etaE = NULL, d = NULL)

Arguments

nsim

Number of simulations

lambdaC

Hazard rate of control arm. Specify a vector for piecewise hazard with duration specified in "intervals"

lambdaE

Hazard rate of experimental arm. Specify a vector for piecewise hazard with duration specified in "intervals"

intervals

Duration of period in which hazard is constant as specified in lambdaC. A vector with length(lambdaC)-1

ssC

Sample size of control arm

ssE

Sample size of experimental arm

gamma

A vector of rate of enrollment per unit of time

R

A vector of duration of time periods for recruitment with rates specified in gamma; should be same length as gamma or 1 less.

fixEnrollTime

if TRUE the enrollment period R is fixed and enrollment rate is adjusted proportionally to meet the sample size; otherwise the last interval of R is adjusted to meet the sample size without adjustment to the enrollment rate.

eta

A vector for dropout rate per unit time for control arm

etaE

A vector for dropout rate per unit time for experimental arm. If left NULL, it uses the same dropout rate as eta.

d

A gsSurv object as input. The other inputs overwrite the corresponding parameters if not NULL

Details

All the simulation parameters: sample size, hazard rate in each interval and the interval duration, enrollment time period and enrollment speed, and the piecewise dropout rate for the same interval duration need to be provided unless a gsSurv object is provided, in which case the individual parameter can be left as NULL. If not NULL the value will overwrite the corresponding value from the gsSurv object.

Value

The function return a list with the follow components

nsim, lambdaC, lambdaE, ssC, ssE, intervals

as Input

gamma

actual enrollment rate per enrollment period. If fixEnrollTime is not TRUE this is the same as the input gamma

R

actual enrollment period. If fixEnrollTime is TRUE this is the same as input R, otherwise the last interval of the input R will be adjusted to meet the specified sample size while keeping gamma fixed.

etaC

same as eta

etaE

as Input or equal to etaC if Input is NULL

simd

data table object that stores the simulated data

  • sim: simulation sequence number

  • treatment: "control" or "experimental"

  • enterT: calendar time a subject enters the study

  • ct: calendar time of event/censoring. Equals to enterT + survival

  • survival: simulated time-to-event value

  • cnsr: censoring status. 1 = censored, 0 = event

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Simulate a two-arm study with overall survival endpint using proportional harzard of 0.7 
# and median survival of 6 months. The number of subjects in each arm is 300.
library(survival)
medC = 6 
hr <- 0.7
intervals <- NULL 
gamma <- c(2.5, 5,  7.5,  10) ## a ramp-up enrollment
R     <- c(2  , 2,  2  ,  6 ) ## enrollment period: total of 12 months
eta <- -log(0.99) ## 1% monthly dropout rate
sim1<-nphsim(nsim=10,lambdaC=log(2)/medC,lambdaE=log(2)/medC*hr, ssC=300,ssE=300,
             intervals=intervals,gamma=gamma, R=R,eta=eta)
km<-survfit(Surv(survival,1-cnsr)~treatment,data=sim1$simd[sim==1])
plot(km,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36),mark.time=TRUE)
ll <- gsub("x=","",names(km$strata))  ## legend labels
legend("top",legend=ll,lty=1:2,horiz=FALSE,bty='n')
 

# Simulate survival endpoint with delayed separation of KM curve: HR=1 for the 
# first 3 months and 0.65 afterwards 
hr <- c(1,0.65)
intervals <- 3 
sim2<-nphsim(nsim=10,lambdaC=log(2)/medC,lambdaE=log(2)/medC*hr, ssC=300,ssE=300,
             intervals=intervals,gamma=gamma, R=R,eta=eta)
km<-survfit(Surv(survival,1-cnsr)~treatment,data=sim1$simd[sim<=10])
plot(km,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
ll <- gsub("x=","",names(km$strata))  ## legend labels
legend("top",legend=ll,lty=1:2,horiz=FALSE,bty='n')


# Use gsSurv as input
library(gsDesign)
gs <- gsSurv ( k = 3, test.type = 4, alpha = 0.025, beta = 0.05, timing = c( 0.5,0.75 ), 
               sfu = sfHSD , sfupar = c( -4 ), sfl = sfHSD, sflpar = c( -12 ), 
               lambdaC = log(2) / 6, hr = 0.65, hr0 = 1, eta = 0.01, gamma = c( 2.5,5,7.5,10 ), 
               R = c( 2,2,2,6 ) , S = NULL , T = 15 , minfup = 3 , ratio = 1) 
sim3 <- nphsim(nsim=10,d=gs) 

keaven/nphsim documentation built on July 2, 2018, 1:10 a.m.