Menu

Inputs

Calculate Sample Size Needed to Test Time-To-Event Data: Cox PH, 2-Sided Equality

You can use this calculator to perform power and sample size calculations for a time-to-event analysis, sometimes called survival analysis. A two-group time-to-event analysis involves comparing the time it takes for a certain event to occur between two groups. For example, we may be interested in whether there is a difference in recovery time following two different medical treatments. Or, in a marketing analysis we may be interested in whether there is a difference between two marketing campaigns with regards to the time between impression and action, where the action may be, for example, buying a product. Since 'time-to-event' methods were originally developed as 'survival' methods, the primary parameter of interest is called the hazard ratio. The hazard is the probability of the event occurring in the next instant given that it hasn't yet occurred. The hazard ratio is then the ratio of the hazards between two groups. Letting θ\theta represent the hazard ratio, the hypotheses of interest are
H0:θ=θ0H_0:\theta=\theta_0
H1:θθ0H_1:\theta\ne \theta_0
where θ0\theta_0 is the hazard ratio hypothesized under the null hypothesis. The calculator above and the formulas below use the notation that θ\theta is the hazard ratio ln(θ)\ln(\theta) is the natural logarithm of the hazard ratio, or the log-hazard ratio pEp_E is the overall probability of the event occurring within the study period pAp_A and pBp_B are the proportions of the sample size allotted to the two groups, named 'A' and 'B' nn is the total sample size Notice that pB=1pAp_B=1-p_A.

Formulas

This calculator uses the following formulas to compute sample size and power, respectively:
n=1pA  pB  pE(z1α/2+z1βln(θ)ln(θ0))2n=\frac{1}{p_A\;p_B\;p_E}\left(\frac{z_{1-\alpha/2}+z_{1-\beta}}{\ln(\theta)-\ln(\theta_0)}\right)^2
1β=Φ(zz1α/2)+Φ(zz1α/2),z=(ln(θ)ln(θ0))n  pA  pB  pE1-\beta= \Phi\left( z-z_{1-\alpha/2}\right)+ \Phi\left(-z-z_{1-\alpha/2}\right)\quad ,\quad z=\left(\ln(\theta)-\ln(\theta_0)\right)\sqrt{n\;p_A\;p_B\;p_E}
where nn is sample size Φ\Phi is the standard Normal distribution function Φ1\Phi^{-1} is the standard Normal quantile function α\alpha is Type I error β\beta is Type II error, meaning 1β1-\beta is power

R Code

1hr=2
2hr0=1
3pE=0.8
4pA=0.5
5alpha=0.05
6beta=0.20
7(n=((qnorm(1-alpha/2)+qnorm(1-beta))/(log(hr)-log(hr0)))^2/(pA*(1-pA)*pE))
8ceiling(n) # 82
9(Power=pnorm((log(hr)-log(hr0))*sqrt(n*pA*(1-pA)*pE)-qnorm(1-alpha/2)))

References

Chow S, Shao J, Wang H. 2008. Sample Size Calculations in Clinical Research. 2nd Ed. Chapman & Hall/CRC Biostatistics Series. page 177.