This R Markdown document illustrates the sample size calculation for a delayed effect model using the lrsamplesize function from lrstat and verifies the result using the simulation tool.

Suppose that the survival distribution of the control group is exponential with a median survival time of 13 months. The survival distribution of the active treatment group is piecewise exponential with the same hazard rate as the control group for the first 6 months and with a hazard ratio of 0.58 afterwards. The accrual has a ramp-up period of 9 months to reach 26 patients per months thereafter, and the total duration of the enrollment is 22 months. In addition, the annual drop rate is 5% for each treatment group.

We would like to know the total number of events needed to achieve 80% power for a two-stage group sequential trial with O’Brien-Fleming spending function and with the interim analysis to be conducted after observing 80% of the target total number of events. First we load the lrstat package:

`library(lrstat)`

We use the lrsamplesize function to obtain the follow-up time and the target number of events.

```
lrsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
alpha = 0.025, typeAlphaSpending = "sfOF",
accrualTime = seq(0, 9),
accrualIntensity = c(26/9*seq(1, 9), 26),
piecewiseSurvivalTime = c(0, 6),
lambda2 = rep(log(2)/13, 2),
lambda1 = c(log(2)/13, 0.58*log(2)/13),
gamma1 = -log(1-0.05)/12, gamma2 = -log(1-0.05)/12,
accrualDuration = 22, followupTime = NA)
```

```
##
## Group-sequential trial with 2 stages
## Overall power: 0.8, overall significance level (1-sided): 0.025
## Maximum # events: 315.2, expected # events: 286.8
## Maximum # dropouts: 29.8, expected # dropouts: 26.8
## Maximum # subjects: 468, expected # subjects: 468
## Total study duration: 41.5, expected study duration: 37
## Accrual duration: 22, follow-up duration: 19.5, fixed follow-up: FALSE
##
## Stage 1 Stage 2
## Information rate 0.800 1.000
## Efficacy boundary (Z-scale) 2.250 2.025
## Cumulative rejection 0.450 0.800
## Cumulative alpha spent 0.0122 0.0250
## Number of events 252.2 315.2
## Number of dropouts 23.1 29.8
## Number of subjects 468.0 468.0
## Analysis time 31.4 41.5
## Efficacy boundary (HR-scale) 0.752 0.795
## Efficacy boundary (p-scale) 0.0122 0.0214
## Information 62.81 78.02
## HR 0.765 0.723
```

Thus we need to observe 315 events with 468 subjects, and the maximum study duration is 41.5 months with an expected study duration of 37 months.

To verify this requirement, we resort to the lrsim function.

```
lrsim(kMax = 2, criticalValues = c(2.250, 2.025),
accrualTime = seq(0, 9),
accrualIntensity = c(26/9*seq(1, 9), 26),
piecewiseSurvivalTime = c(0, 6),
lambda2 = rep(log(2)/13, 2),
lambda1 = c(log(2)/13, 0.58*log(2)/13),
gamma1 = -log(1-0.05)/12, gamma2 = -log(1-0.05)/12,
accrualDuration = 22,
plannedEvents = c(252, 315),
maxNumberOfIterations = 10000, seed = 314159)
```

```
##
## Group-sequential trial with 2 stages
## Overall power: 0.797
## Expected # events: 286.6
## Expected # dropouts: 26.7
## Expected # subjects: 468
## Expected study duration: 36.8
## Accrual duration: 22, fixed follow-up: FALSE
##
## Stage 1 Stage 2
## Cumulative rejection 0.451 0.797
## Cumulative futility 0.000 0.203
## Number of events 252.0 315.0
## Number of dropouts 23.0 29.8
## Number of subjects 468.0 468.0
## Analysis time 31.3 41.4
```

The simulation results confirm the analytic calculations.