simtest: Testing for a time-to-event study simulation

Description Usage Arguments Details Value Examples

View source: R/simtest.R

Description

Generate additional simulated data at user specified analysis sequences (either driven by calendar time or number of events). Create simulation level summary of analysis timing and number of events, as well as testing results and boundary crossing

Usage

1
2
simtest(x, anaT = NULL, anaD = NULL, anatype = "event", method = NULL,
  stratum = NULL, fparam = NULL, d = NULL)

Arguments

x

list genearted by simulation

anaT

A vector or matrix of calendar time for reporting, testing, and boundary crossing probability when a gsDesign object is specified.

anaD

A vector of number of events for reporting, testing, and boundary crossing probability when a gsDesign object is specified.

anatype

use specified timing ('anaT') if 'calendar'; use specified number of events ('anaD') if 'event'; use the maximum of the two if 'both'

method

statistical testing method to be applied to simulated data.

stratum

the variable name in the simulated data for the stratified analysis

fparam

additional parameters needed in the user defined testing functions. This has to match the parameters in the testing function.

d

A 'gsDesign' object. Timing/Events and the boundary will be updated upon output.

Details

simtest() takes the returned list from nphsim() and creates and analyzes the simulated data at various analysis time points depending on user input:

Different statistical testing and summarizing procedures can be specified in the method parameter. User defined statistical procedures can be used so long as it follows certain order of parameter setup in function definition. Similar to nphsim(), simtest() can also take a gsDesign object as input, same or different from the one used in nphsim. If used, boundary crossing is checked against the boundaries in the gsDesign object at each analysis (either specified time points or events). The boundaries are re-calculated if the number of events at an analysis is different from the design.

Value

The function return a list with the follow components

anaT, anaD, anatype, method

as Input

gsobj

same as d, the gsDesign input

simd

data table object that stores the simulated data by analysis sequence

result

data table object that stores the simulation level summaries

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
37
38
# Use a gsSurv object as both input for simulation and testing. 
# A logrank p-value and HR from cox model is reported.
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) 
sim1 <- nphsim(nsim=10,d=gs)
test1 <- simtest(x=sim1,anatype='event',method='LR', d=gs)
test1$result
plotsim(test1$result,y=c("hr"),dg=2,yt="Hazard Ratio",b=1,v=c(2,0.8))


# specify fixed analysis time
test2 <- simtest(x=sim1,anatype='calendar',anaT=c(10, 13, 16), method='LR', d=gs)
plotsim(test2$result,y=c("hr"),dg=2,yt="Hazard Ratio",b=1,v=c(2,0.8))

# specify by-simulation analysis time
anaT<-matrix(c(9,11,15,10,12,16),byrow=TRUE,nrow=00,ncol=3)
test3 <- simtest(x=sim1,anatype='calendar',anaT=anaT, method='LR', d=gs)


# specify number of events
test4 <- simtest(x=sim1,anatype='event',anaD=c(140, 200, 290), method='LR', d=gs)

# A user defined testing function. Additional information needed for the testing function 
# can be included in the fparam. 
# and provided in the \code{simtest() fparam} parameter.
library(survRM2)
test.usr1<-function (survival,cnsr,trt,stra=NULL,fparam=NULL) {
a<-rmst2(time=survival,status=1-cnsr,arm=(trt=='experiment'),tau=fparam)
b<-a$unadjusted.result
pval <- b[1,4]
y<-list(pval=round(pval,4), est=b[1,1], estlb=b[1,2],estub=b[1,3])
return(y)
}
test5 <- simtest(x=sim1,anatype='event',anaD=c(200, 290), method=test.usr1, fparam=9)
plotsim(test5$result,y=c("estlb","estub"),dg=2,yt="Estimate",v=c(2,0.8))

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