3.4: Time-to-event sample size calculation (Lachin-Foulkes)

nSurvival() is used to calculate the sample size for a clinical trial with a time-to-event endpoint. The Lachin and Foulkes (1986) method is used. nEvents uses the Schoenfeld (1981) approximation to provide sample size and power in terms of the underlying hazard ratio and the number of events observed in a survival analysis. The functions hrz2n(), hrn2z() and zn2hr() also use the Schoenfeld approximation to provide simple translations between hazard ratios, z-values and the number of events in an analysis; input variables can be given as vectors.

nSurvival(lambda1=1/12, lambda2=1/24, Ts=24, Tr=12, eta = 0, ratio = 1,
      alpha = 0.025, beta = 0.10, sided = 1, approx = FALSE,
      type = c("rr", "rd"), entry = c("unif", "expo"), gamma = NA)
## S3 method for class 'nSurvival':
nEvents(hr = .6, alpha = .025, beta = .1, ratio = 1, sided = 1, 
        hr0 =  1, n = 0, tbl = FALSE)
hrn2z(hr, n, ratio=1, hr0=1, hr1=.7)
hrz2n(hr, z, ratio=1, hr0=1)
zn2hr(z, n, ratio=1, hr0=1, hr1=.7)
lambda1, lambda2
event hazard rate for placebo and treatment group respectively.
equal dropout hazard rate for both groups.
randomization ratio between placebo and treatment group. Default is balanced design, i.e., randomization ratio is 1.
maximum study duration.
accrual (recruitment) duration.
type I error rate. Default is 0.025 since 1-sided testing is default.
type II error rate. Default is 0.10 (90% power). Not needed for nEvents() if n is provided.
one or two-sided test? Default is one-sided test.
logical. If TRUE, the approximation sample size formula for risk difference is used.
type of sample size calculation: risk ratio (rr) or risk difference (rd).
patient entry type: uniform entry ("unif") or exponential entry ("expo").
rate parameter for exponential entry. NA if entry type is "unif" (uniform). A non-zero value is supplied if entry type is "expo" (exponential).
An object of class "nSurvival" returned by nSurvival() (optional: used for output; "months" or "years" would be the 'usual' choices).
Hazard ratio. For nEvents, this is the hazard ratio under the alternative hypothesis (>0).
Hazard ratio under the null hypothesis (>0, for nEvents, != hr).
Hazard ratio under the alternate hypothesis for hrn2z, zn2hr (>0, != hr0)
Number of events. For nEvents may be input to compute power rather than sample size.
Indicator of whether or not scalar (vector) or tabular output is desired for nEvents().
A z-statistic.
Allows additional arguments for print.nSurvival().

nSurvival() produces an object of class "nSurvival" with the number of subjects and events for a set of pre-specified trial parameters, such as accrual duration and follow-up period. The calculation is based on Lachin and Foulkes (1986) method and can be used for risk ratio or risk difference. The function also consider non-uniform (exponential) entry as well as uniform entry. If the logical approx is TRUE, the variance under alternative hypothesis is used to replace the variance under null hypothesis. For non-uniform entry, a non-zero value of gamma for exponential entry must be supplied. For positive gamma, the entry distribution is convex, whereas for negative gamma, the entry distribution is concave. nEvents() uses the Schoenfeld (1981) method to approximate the number of events n (given beta) or the power (given n). Arguments may be vectors or scalars, but any vectors must have the same length. The functions hrz2n, hrn2z and zn2hr also all apply the Schoenfeld approximation for proportional hazards modelling. This approximation is based on the asymptotic normal distribtuion of the logrank statistic as well as related statistics are asymptotically normal. Let $\lambda$ denote the underlying hazard ratio (lambda1/lambda2 in terms of the arguments to nSurvival). Further, let $n$ denote the number of events observed when computing the statistic of interest and $r$ the ratio of the sample size in an experimental group relative to a control. The estimated natural logarithm of the hazard ratio from a proportional hazards ratio is approximately normal with a mean of $log{\lambda}$ and variance $(1+r)^2/nr$. Let $z$ denote a logrank statistic (or a Wald statistic or score statistic from a proportional hazards regression model). The same asymptotic theory implies $z$ is asymptotically equivalent to a normalized estimate of the hazard ratio $\lambda$ and thus $z$ is asymptotically normal with variance 1 and mean $$\frac{log{\lambda}r}{(1+r)^2}.$$ Plugging the estimated hazard ratio into the above equation allows approximating any one of the following based on the other two: the estimate hazard ratio, the number of events and the z-statistic. That is, $$\hat{\lambda}= \exp(z(1+r)/\sqrt{rn})$$ $$z=log(\hat{\lambda})\sqrt{nr}/(1+r)$$ $$n= (z(1+r)/log(\hat{\lambda}))^2/r.$$ hrz2n() translates an observed interim hazard ratio and interim z-value into the number of events required for the Z-value and hazard ratio to correspond to each other. hrn2z() translates a hazard ratio and number of events into an approximate corresponding Z-value. zn2hr() translates a Z-value and number of events into an approximate corresponding hazard ratio. Each of these functions has a default assumption of an underlying hazard ratio of 1 which can be changed using the argument hr0. hrn2z() and zn2hr() also have an argument hr1 which is only used to compute the sign of the computed Z-value in the case of hrn2z() and whether or not a z-value > 0 corresponds to a hazard ratio > or < the null hazard ratio hr0.


  • nSurvival produces a list with the following component returned:
  • typeAs input.
  • entryAs input.
  • nSample size required (computed).
  • nEventsNumber of events required (computed).
  • lambda1As input.
  • lambda2As input.
  • etaAs input.
  • ratioAs input.
  • gammaAs input.
  • alphaAs input.
  • betaAs input.
  • sidedAs input.
  • TsAs input.
  • TrAs input.
  • nEvents produces a scalar or vector of sample sizes (or powers) when tbl=FALSE or, when tbl=TRUE a data frame of values with the following columns:
  • hrAs input.
  • nIf n[1]=0 on input (default), output contains the number of events need to obtain the input Type I and II error. If n[1]>0 on input, the input value is returned.
  • alphaAs input.
  • betaIf n[1]=0 on input (default), beta is output as input. Otherwise, this is the computed Type II error based on the input n.
  • PowerOne minus the output beta. When tbl=FALSE, n[1]>0, this is the value or vector of values returned.
  • deltaStandardized effect size represented by input difference between null and alternative hypothesis hazard ratios.
  • ratioRatio of experimental to control sample size where 'experimental' is the same as the group with hazard represented in the numerator of the hazard ratio.
  • seEstimated standard error for the observed log(hazard ratio) with the given sample size.
  • hrz2n outputs a number of events required to approximately have the input hazard ratio, z-statistic and sample size correspond. hrn2z outputs an approximate z-statistic corresponding to an input hazard ratio and number of events. zn2hr outputs an approximate hazard ratio corresponding to an input z-statistic and number of events.


Lachin JM and Foulkes MA (1986), Evaluation of Sample Size and Power for Analyses of Survival with Allowance for Nonuniform Patient Entry, Losses to Follow-Up, Noncompliance, and Stratification. Biometrics, 42, 507-519. Schoenfeld D (1981), The Asymptotic Properties of Nonparametric Tests for Comparing Survival Distributions. Biometrika, 68, 316-319.

See Also

gsDesign package overview, Plots for group sequential designs, gsDesign, gsHR

  • nSurvival
  • nEvents
  • zn2hr
  • hrn2z
  • hrz2n
  • print.nSurvival
  • Survival sample size
# consider a trial with 
# 2 year maximum follow-up
# 6 month uniform enrollment
# Treatment/placebo hazards = 0.1/0.2 per 1 person-year
# drop out hazard 0.1 per 1 person-year
# alpha = 0.025 (1-sided)
# power = 0.9 (default beta=.1)

ss <- nSurvival(lambda1=.2 , lambda2=.1, eta = .1, Ts = 2, Tr = .5,
                sided=1, alpha=.025)

#  group sequential translation with default bounds
#  note that delta1 is log hazard ratio; used later in gsBoundSummary summary
	x<-gsDesign(k = 5, test.type = 2, n.fix=ss$nEvents, nFixSurv=ss$n, 
# boundary plot
# effect size plot
	plot(x, plottype = "hr")
# total sample size
# number of events at analyses
# print the design
# overall design summary
# tabular summary of bounds

# approximate number of events required using Schoenfeld's method
# for 2 different hazard ratios
nEvents(hr=c(.5, .6), tbl=TRUE)
# vector output
nEvents(hr=c(.5, .6))

# approximate power using Schoenfeld's method
# given 2 sample sizes and hr=.6
nEvents(hr=.6, n=c(50, 100), tbl=TRUE)
# vector output
nEvents(hr=.6, n=c(50, 100))

# approximate hazard ratio corresponding to 100 events and z-statistic of 2
# same when hr0 is 1.1
# same when hr0 is .9 and hr1 is greater than hr0

# approximate number of events corresponding to z-statistic of 2 and 
# estimated hazard ratio of .5 (or 2)

# approximate z statistic corresponding to 75 events
# and estimated hazard ratio of .6 (or 1/.6)
# assuming 2-to-1 randomization of experimental to control
Documentation reproduced from package gsDesign, version 3.0-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.