# Get boundaries for O'Brien-Fleming spending function, 5 looks, alpha=.05
b <- ldBands(5, pr=FALSE)
plot(b)
# Same but times are irregular, and information times are different than
# test times. Use Pocock spending function.
b <- ldBands(times= c(.4, .6, .8, .9, .95),
information=c(.42,.65,.83,.89,.94), spending='Pocock')
# Get power calculations
u <- ldBands(times=c(.4, .6, .8, .9, .95), power=.9)
u$drift # standardize difference * sqrt(n per arm)
# needed to provide power=.9
summary(u, n=50) # obtain detectable standardized difference
summary(u, p1=.4, p2=.5) # get sample size per arm, two-sample binomial
summary(u, hr=1.5) # get number of events per arm needed
# to detect a hazard ratio of 1.5
# Asymmetric boundaries with different spending functions, truncate
b <- ldBands(5, sided=3, spending='alpha*t^phi', phi=1, phi2=1.5,
alphaLower=.01, alphaUpper=.04, truncate=4)
b
plot(b)
# Compute differences in proportions and odds ratios needed to cross
# the boundaries, given a mean probability in two treatment arms of 0.1
# and given a vector of sample sizes per arm corresponding to the looks
s <- summary(b, n=seq(200,1000,by=200), pbar=.1)
s
d <- s$data
plot(d$n, d$or.lower, xlab='N Per Arm',
ylab='Critical Odds Ratio', type='b',
ylim=range(d$or.lower, d$or.upper), log='y')
lines(d$n, d$or.upper, type='b')
abline(h=1, lty=2)
Run the code above in your browser using DataCamp Workspace