Switch to unified view

a b/vignettes/PredictFromParameters.Rnw
1
\documentclass[a4paper]{article}
2
\usepackage[utf8]{inputenc}
3
\usepackage{amsmath}
4
\usepackage{amssymb}
5
\usepackage{fullpage}
6
\title{Predict from Parameters}
7
\author{Daniel Dalevi, Nik Burkoff and Helen Mann}
8
% \VignetteIndexEntry{Predict from Parameters}
9
%\VignetteEngine{knitr::knitr} 
10
11
\begin{document}
12
%\SweaveOpts{concordance=TRUE}
13
14
<<l1,include=FALSE>>=
15
library(knitr)
16
opts_chunk$set(
17
concordance=TRUE
18
)
19
@
20
21
\maketitle
22
23
\section{Introduction}
24
This is a tutorial describing how to use the \emph{predict from parameters} part of the eventPrediction package.  
25
The user enters the expected properties of a two (or possibly one) arm survival study and the package can calculate:
26
\begin{itemize}
27
\item The time when a given number of events is expected to occur.
28
\item The expected number of events that will have occurred at a given time.
29
\item For two arm studies: calculate the required number of events for testing $H_0: \ln(HR)=0$ for a given study power and significance level and output the time at which this `critical' number of events is expected to occur.  
30
\end{itemize}
31
32
The package handles studies with either exponential or Weibull survival functions and a lag can be included (i.e. a piecewise proportional hazard model with two `pieces'). Subjects can be followed for a fixed period or until study closure. A competing-risks model further allows subjects to drop out before having events. A parameter $k$ controls the non-linearity of subject accrual with $k=1$ uniform accrual, $k<1$ factor recruitment at start then slower and $k>1$ slow recruitment at start then faster. There will be a distinction made between Oncology and CRGI studies. The latter is an abbreviation for Cardio Renal and GastroIntestinal but in general these refer to larger studies with lower events rates. 
33
34
\section{Preliminary steps}
35
Before starting this tutorial you need to install the eventPrediction package and its dependencies. For all examples below, ensure you load the library first. 
36
<<load,message=FALSE>>=
37
library(eventPrediction)
38
@ 
39
40
\section{A Simple Example}
41
42
The following sequence of commands are used for all analyses: 
43
\begin{enumerate}
44
\item Define a study object containing the study parameter values you wish to use.
45
There are two different ways to create the study object. The first, \texttt{Study}, is used for oncology trials and the second, \texttt{CRGIStudy}, is used for CRGI trials. The main difference between the two is the way the event rates are specified. Median survival has little meaning for trials with low event rates.
46
<<>>=
47
#oncology trial 
48
study <- Study( 
49
            alpha = 0.05, 
50
            power = 0.89, 
51
            HR = 0.75, 
52
            r = 1, 
53
            N = 800, 
54
            study.duration = 36,
55
            ctrl.median = 3, 
56
            k = 2,
57
            acc.period = 20,
58
            two.sided = TRUE)
59
@
60
61
62
The parameters are explained in Table~\ref{table:studyparams}.
63
64
\begin{table}
65
\caption{Parameters required for the study object.}
66
\centering
67
\begin{tabular}{|l|p{9cm}|}
68
\hline
69
Parameter & Description \\
70
\hline
71
HR & The assumed (i.e.\ targeted) hazard ratio between the subjects on the Experimental and Control arms.\\
72
alpha & Significance level of the test for calculating the critical number of events
73
$\alpha\in(0,1)$ (see also two.sided). \\
74
power & Power, $(1-\beta)\in(0,1)$ the power we would like the study to have, this is used when calculating 
75
the critical number of events.\\
76
r & Experimental/Control randomization balance is given by 1:r, i.e.\ nE/nC=r; for example r=1 gives a balanced study and
77
r = 0.5 implies twice as many subjects on the control arm etc. Specifically \texttt{floor(N*(r/(r+1)))} subjects are 
78
allocated to the experimental arm and all other subjects are allocated to the control arm.\\
79
N & Total number of subjects to be recruited. \\
80
study.duration & Length of the study [months] $=S$ in this tutorial. \\
81
ctrl.median  & Oncology only: Median survival time, i.e.\ the time by which half of the subjects in the control arm are expected to have had an event. \\
82
ctrl.time  & CRGI only: At time=ctrl.time, ctrl.proportion of subjects have had an event.\\
83
ctrl.proportion  & CRGI only: At time=ctrl.time, ctrl.proportion of subjects have had an event.\\
84
follow up  & CRGI only: The length of time [months] a subject is followed after randomization. If subjects are followed until they have an event (or are censored at the end of study) then set this to \texttt{Inf}. \\ 
85
k & Non-uniformity of accrual (integer, 1=uniform). We 
86
    use the following distribution for the probability of a patient entering the trial at time $b$ 
87
    within the accrual period $[0,B]$: $F(b)=b^k/B^k$; $f(b)=k b^{k-1}/B^k$ where $k>0$. $k=1$ indicates uniform accrual. This implies that during 
88
    the first half of the accrual period, $1/2^k$ of the patients will be recruited. Half of the patients 
89
    will be recruited by time $B/2^{1/k}$. \\
90
acc.period & Accrual period [months] $=B$ in this tutorial. \\
91
two.sided & If TRUE, two sided test will be used (i.e.\ alpha/2). \\
92
shape & The Weibull shape parameter, default = 1 i.e.\ exponential survival function $=a$ in this tutorial; see examples below for further details. \\
93
dropout & If \texttt{NULL} then no subjects drop out. Otherwise there is a competing risk model with the risks being event and drop out. The dropout argument should be a list with time, proportion (and optionally shape) as elements. For example \texttt{dropout=list(time=12,proportion=c(0.05,0.01), 
94
shape=1.2))} would imply [in the absence of events] it is expected that 5\% of control arm subjects and 1\% of active arm subjects would drop out within 12 months and the drop out hazard function is Weibull with shape=1.2. If shape argument is not included then an exponential drop out rate is used.  \\ 
95
lag.settings & A \texttt{LaggedEffect} object which captures any lag in treatment effect. See below for further details. \\
96
\hline
97
\end{tabular}
98
\label{table:studyparams}
99
\end{table}
100
101
<<>>=
102
#CRGI trial
103
crgistudy <- CRGIStudy(
104
            alpha = 0.05, 
105
            power = 0.89, 
106
            HR = 0.75, 
107
            r = 1, 
108
            N = 800, 
109
            study.duration = 36,
110
            ctrl.time = 12,
111
            ctrl.proportion = 0.33,
112
            followup = 24,
113
            k = 2,
114
            acc.period = 20,
115
            two.sided = TRUE,
116
            dropout=list(time=12,proportion=c(0.05,0.01)))
117
@
118
119
\item Use the predict function to execute the computations.
120
In this example we would like to predict the expected number of events to have occurred at 15 months and the times at which 100 and 400 events are expected to occur. The \texttt{time.pred} and \texttt{event.pred} optional arguments are used to perform the prediction: 
121
<<>>=
122
prediction <- predict(study, time.pred=15, event.pred=c(100,400)) 
123
@
124
125
\item Output the results. The object returned contains the results and a summary can be output:
126
<<>>=
127
summary(prediction)
128
@
129
The \texttt{options} argument can be used to format the output (for example \texttt{summary(prediction, options=DisplayOptions(text.width=100))} see the Appendix for further details). 
130
131
132
\item You may visualise the results using the plot command. The expected time of the critical number of events is marked with a solid vertical line and the predicted times and number of events are shown with dotted vertical lines (and coloured horizontal lines for each arm at these times).
133
<<>>=
134
plot(prediction, options = DisplayOptions(StartDate="15/01/2010"), 
135
     show.title=FALSE)
136
@
137
138
The summary text can be output onto the graph by setting \texttt{show.title=TRUE}. The optional \texttt{options} argument can once again be used to format the output of both the summary text and the graph itself. See the Appendix for further details.
139
140
The resolution of the plots (interval between the x co-ordinates of consecutive plotted data points) is set by the \texttt{step.size} argument to the predict function, by default it is set at 0.1.
141
142
Finally the \texttt{show.separate.arms} argument to the \texttt{plot} function can be set to \texttt{FALSE}, in which case the blue and red lines of each arm are not displayed.
143
144
\end{enumerate}            
145
146
\section{Further Details}
147
148
More details concerning the results can be viewed using the \texttt{print} function:
149
<<print>>=
150
print(prediction)
151
@
152
The study definition is first output followed by two data frames containing data for the requested predictions (\texttt{prediction@predict.data}) and the critical number of events (\texttt{prediction@critical.data})\footnote{A third data frame (\texttt{prediction@grid}) is not shown but contains the data for plotting the results and does not contain the at risk columns.}.
153
154
The data frames contain the following columns:
155
\begin{itemize}
156
\item \texttt{time} the time since study start for this row of the data frame
157
\item \texttt{events1} the expected number of events on the control arm at this time
158
\item \texttt{events2}  the expected number of events on the experimental arm at this time
159
\item \texttt{events.tot} sum of columns \texttt{events1} and \texttt{events2}
160
\item \texttt{recruit.tot} the expected number of subjects recruited onto the study by this time
161
\item \texttt{rounded.events.tot} contains the result of \texttt{floor(events1)+floor(events2)} 
162
\item \texttt{time.pred} TRUE if this row refers to a time.pred user input or FALSE if it refers to an event.pred user input 
163
\item \texttt{at.risk1} the amount of time control arm subjects have been at risk on the study by this time
164
\item \texttt{at.risk2} the amount of time experimental arm subjects have been at risk on the study by this time
165
\item \texttt{atrisk.tot} sum of columns \texttt{atrisk1} and \texttt{atrisk2} 
166
\end{itemize}
167
168
169
The critical number of events to reject the null hypothesis $H_0: \ln(HR)=0$, is defined as $$E =\left[\frac{(r+1)(z_{1-\alpha} + z_{1-\beta})}{\sqrt r \ln(HR)}\right]^2 $$ where $r$ is the allocation ratio (study@r), $1-\beta=$ study@power, $\alpha =$ study@alpha if study is one tailed or study@alpha/2 if two tailed, HR=study@HR and $z$ is the quantile function for the standard normal distribution.  
170
171
Many assumptions are used in order to derive this formula and we strongly recommend consulting the non-proportional hazards package documentation and the literature (e.g.\ Sample Sizes for Clinical Trials, Steven A.\ Julious p248-252 and references therein) when using this formula.
172
173
The critical hazard ratio is then defined as the HR with 50\% power when $E$ events occur\footnote{equivalently the HR with upper CI limit equal to 1}. By rearranging the above formula (and assuming we are interested in the case HR $<$ 1) the critical hazard ratio is defined as $$\exp\left(\frac{-(r+1)(z_{1-\alpha} + z_{0.5})}{\sqrt{rE}}\right).$$ 
174
175
176
\subsection{\LaTeX\ Survival Function}
177
178
It is possible to output the survival functions in \LaTeX\ which could then be incorporated into a report:
179
<<latex>>=
180
myLatexString <- LatexSurvivalFn(prediction)
181
182
cat(myLatexString)
183
@
184
185
Note that the backslash character has been escaped in order for the latex to be correctly output when using \texttt{cat} or rendered using mathjax in the Shiny App. The \texttt{decimalplaces} argument (default 3) rounds the numeric values to the desired number of decimal places.
186
187
\section{Single Arm Trial}
188
189
The same procedure can be used for single arm trials, although it no longer makes sense to consider HR, randomization balance, the critical number of events etc. We use the \texttt{SingleArmStudy} function to create the Study object and a subset of the arguments to \texttt{Study} are required.
190
<<singlearm>>=
191
#Note drop out can be used in single arm studies as well
192
singleArmStudy <- SingleArmStudy(N=800, 
193
                                 study.duration=36,
194
                                 ctrl.median=3,
195
                                 k=1,
196
                                 acc.period=20,
197
                                 dropout=list(time=12,proportion=0.05,shape=1.2)) 
198
199
ans <- predict(singleArmStudy,event.pred=c(100,200,400))
200
@
201
202
Similarly we can create a CRGI single arm study using the \texttt{SingleArmCRGIStudy} function:
203
<<singlearmCRGI>>=
204
crgisingleArm <- SingleArmCRGIStudy(N=800,
205
                                    study.duration=45,
206
                                    ctrl.time=12,
207
                                    ctrl.proportion=0.3,
208
                                    k=1,
209
                                    acc.period=20,
210
                                    followup=24)
211
212
predict(crgisingleArm,event.pred=c(100,200,300))
213
@
214
215
Note that there are no events in the experimental arm (`events2' column). The \texttt{summary} and \texttt{plot} functions can also be used for single arm studies.
216
217
\section{Example: NSCLC trial with PFS endpoint and Weibull survival function}
218
219
Until now all studies have assumed exponential survival functions (i.e.\ $S(t) = \exp(-\lambda t)$ for some $\lambda$). The package also allows Weibull survival functions($S(t) = \exp(-(\lambda t)^a)$ for some $\lambda,a$) and these are used in the example below. 
220
221
An NSCLC trial with primary endpoint progression free survival (PFS). This will be assessed in the total population and also the female subgroup. The control median PFS is estimated to be 3 months and the study will be designed to have 90\% power to detect a hazard ratio of 0.8, using a two-sided significance level of 2.44\%. Non-uniform recruitment will be assumed ($k=2$) with a recruitment period of 19 months. The shape parameter of the survival functions ($a$) will be set\footnote{In later versions the shape parameter will be able to be calculated from survival quantile data similarly to the non-proportional hazards package.} at 1.2.
222
223
First you need to define a Study object with the above settings.
224
<<>>=
225
study <- Study( 
226
            alpha = 0.0244, 
227
            power = 0.9, 
228
            HR = 0.8, 
229
            r = 1, 
230
            N = 1240, 
231
            study.duration = 23,
232
            ctrl.median = 3, 
233
            k = 2,
234
            acc.period = 19,
235
            two.sided = TRUE,
236
            shape=1.2) #Note the shape parameter
237
@
238
 
239
240
Run the following:
241
<<>>=
242
prediction <- predict(study)
243
@
244
245
The output for the total population:
246
<<>>=
247
summary(prediction)
248
@
249
250
With $1240$ patients the trial needs to be $21.5$ months to get the required number of events. The hazard ratio closest to $1$ that can be detected significantly is $0.86$. Plotting the results.
251
<<>>=
252
plot(prediction, show.title=FALSE)
253
@ 
254
255
Looking at the female only subgroup can be done by repeating the procedure with different parameters. The female subgroup is predicted to have a larger treatment difference, a hazard ratio of 1/1.375. Assuming a $1:1$ ratio of male:female subjects, the following settings can be made:
256
<<>>=
257
study <- Study( 
258
            alpha = 0.0244, 
259
            power = 0.9, 
260
            HR = 1/1.375, 
261
            r = 1, 
262
            N = 620, 
263
            study.duration = 23,
264
            ctrl.median = 3, 
265
            k = 2,
266
            acc.period = 19,
267
            two.sided = TRUE)
268
@
269
 
270
Then run:
271
<<>>=
272
prediction <- predict(study)
273
text <- summary(prediction)
274
@
275
276
Finally we plot the results: 
277
<<>>=
278
plot(prediction, options=DisplayOptions(text.width=80))
279
@ 
280
281
282
\section{Including a lag time}
283
\label{Sec:Lag}
284
For trials which do not include a fixed follow up period, it is possible to include a lag time in the analysis using a piecewise proportional hazards model. Here some additional parameters are required (see Table~\ref{table:lagparams}): The lag time ($T$) and the hazard ratio and control median for the time period $[0,T]$. The hazard ratio and control median for time ($>T$) is taken from the \texttt{Study} object. 
285
286
A lagEffect object is passed as the \texttt{lagged} argument into the \texttt{Study} object. Here is an example for illustrative purposes where we have a lag time of $3$ months during which the hazard is one, then it changes to $0.5$.
287
<<lags>>=
288
lagged <- LagEffect( 
289
              Lag.T = 3, 
290
              L.Ctr.median = 3,  
291
              L.HazardRatio = 1)
292
293
study <- Study(
294
             alpha = 0.05,
295
             power = 0.8,
296
             HR = 0.5,
297
             r = 1,
298
             N = 800,
299
             study.duration = 30,
300
             ctrl.median = 3,
301
             k = 2,
302
             acc.period = 20,
303
             two.sided = TRUE,
304
             lag.settings=lagged)
305
306
prediction <- predict(study)
307
308
summary(prediction)
309
@
310
311
\begin{table}[!h]
312
\centering
313
\caption{Parameters required for running a simulation with lag. Note the hazard ratio and
314
control median for after time T are taken from the study object. }
315
\begin{tabular}{|l|p{9cm}|}
316
\hline
317
Parameter & Description \\
318
\hline
319
Lag.T & Lag time (months)\\
320
L.Ctr.median & Control median for the time period $[0,T]$ \\
321
L.HazardRatio & Hazard ratio for the time period $[0,T]$ \\
322
study@ctrl.median & Control median for the time period $>T$ \\
323
study@HR & Hazard ratio for the time period $>T$ \\
324
\hline
325
\end{tabular}
326
\label{table:lagparams}
327
\end{table}
328
329
The formula for the average hazard ratio is described in the Appendix. Note that the critical number of events is calculated as if there was a study without lag which has this calculated average hazard ratio throughout.
330
331
\section*{Appendix}
332
333
\subsection*{Display Options}
334
Here are some of the parameters that can be changed in the DisplayOptions object (default values in brackets):
335
\begin{itemize}
336
\item \texttt{Time} String displaying time units (``months").
337
\item \texttt{Title} Title to be displayed in plot (``Expected Recruitment and Events").
338
\item \texttt{StartDate} String, if ``0" integers will be enumerated (1,2,3,4...), if a date, e.g. ``15/01/2010", dates will be enumerated (``0").
339
\item \texttt{Control} Plot legend text for control arm (``Control").
340
\item \texttt{Exp} Plot legend text for experimental arm (``Experimental").
341
\item \texttt{text.width} The text width for the summary text -- only used if the default title is used (75).
342
\item \texttt{ShowRec} Add expected recruitment numbers to the summary text (FALSE).
343
\end{itemize}
344
345
\subsection*{Some notes on the event prediction using exponential survival and the R implementation}
346
The survival time of an individual has cdf $F(t)$, survival function $S(t)=1-F(t)$ with the recruitment time $r$ having cdf $G(R)$ where $r \in [0,B]$. The probability of having an event by time $t$ is:
347
\begin{equation}
348
\label{eq:1}
349
P(t) = \int^{\min(t,B)}_0 g(s) F(t-s) ds = G(\min(t,B)) - \int^{\min(t,B)}_0 g(s) S(t-s) ds
350
\end{equation}
351
352
The accrual model we implement is:
353
\begin{equation}
354
G(t) = \frac{t^k}{B^k}
355
\end{equation}
356
where $k$ determines the degree of uniformity. $k=1$ corresponds to uniform accrual $G(t)=t/B$. If, $t=0.5B$, half the recruitment time has passed and we have recruited $50\%$ of the patients $G(t)=0.5$. On the other hand, if $k=2$ then we have $G(t)=t^2/B^2$ and at half time we only have $G(t)=0.25$, i.e. $25\%$. 
357
358
<<echo=FALSE,fig.height=5,fig.width=4>>=
359
k=1
360
B = 100
361
t=1:B
362
plot( t, 100*t^k/B^k, 'l', xlab="time [days]", ylab="G(t) [%]")
363
text( 30, 35, "k=1" )
364
k=2
365
lines( t, 100*t^k/B^k,  col="red" )
366
text( 40, 20, "k=2" )
367
k=3
368
lines( t, 100*t^k/B^k,  col="blue" )
369
text( 47, 15, "k=3" )
370
k=4
371
lines( t, 100*t^k/B^k,  col="brown" )
372
text( 54, 12, "k=4" )
373
k=1/2
374
lines( t, 100*t^k/B^k,  col="green" )
375
text( 20, 50, "k=0.5" )
376
abline( v=50 )
377
abline( h=50, lty=2)
378
abline( h=25, lty=2)
379
abline( h=707, lty=2)
380
abline( h=12.5, lty=2 )
381
abline( h=6.25, lty=2 )
382
@
383
384
The survival function is assumed to be Weibull of the form:
385
\begin{equation}
386
S(t) = \exp(-(\lambda t)^a)
387
\end{equation}
388
with shape parameter $a$ and rate parameter $\lambda$ which differs between the experimental and placebo arms. A shape parameter $a=1$ implies an exponential survival function.
389
390
Currently the user specifies $a$, the control median $ctrl.median$ ($M$) and the hazard ratio $HR$ ($\Delta$) in the study object. The conversion to rate parameters $\lambda$ is done using the relationships:
391
392
\begin{equation}
393
\lambda= 
394
\begin{cases}
395
    \log(2)^{1/a}/M, & \text{if control} \\ 
396
    \log(2)^{1/a}/(M/\Delta^{1/a}), & \text{if experimental}
397
\end{cases}
398
\end{equation}
399
(see function \texttt{eventPrediction::lambda.calc}).
400
401
In order to calculate the probability of having an event at time $t$, we use Equation \ref{eq:1}:
402
\begin{equation}
403
\label{eq:2}
404
P(t)=\frac{m^k}{B^k} - \frac{k}{B^k}\int^{m}_0 s^{k-1} S(t-s)ds
405
\end{equation}
406
where $m=\min(t,B)$. This integral is calculated using the \texttt{stats::integrate} R function within in the function \texttt{eventPrediction::events.integ}.
407
408
In the integral, $S(t) = 1 -\mathbb{P}(\text{had event by time} \: t)$ which in the simple case of no fixed follow up period or competing risks is precisely the survival function. If subjects drop out then the function we are integrating  is no longer the survival function it is given by $$ 1 - \int_0^t J(u)h_e(u)du $$ where $h_e$ is the time dependent hazard function of having an event and $J$ is the survival function, i.e. the probability of still being in the trial as oppose to the probability of not having had an event \cite{Putter:2007}
409
410
Similarly, if the study has a fixed follow up period of $\eta$ then the function used in the integral in Equation \ref{eq:2} ($S(.)$)  is unchanged for $t < \eta$ and $S(t)=S(\eta)$ for $t \ge \eta$ as after $\eta$ subject events are not included in the study. 
411
412
\subsection*{Calculation of total time at risk}
413
414
The expected total time at risk at time $t$ per subject, $R(t)$, is given as the sum of three terms (see end of vignette for derivations):
415
416
$$ R(t) = I_1(t) + I_2(t) + I_3(t)$$
417
418
where $I_1(t)$ is the total time spent at at risk for subjects still on the trial at time $t$, $I_2(t)$ is the total time spent at risk of subjects who have had an event/dropped out before time $t$ and $I_3(t)$ is the total time spent at risk for subjects completed, i.e. those who were censored at the end of the follow up period. If there is no fixed follow up period then $I_3(t) = 0$.
419
420
We find
421
$$I_1(t) = \int_0^{\min(t,B)} (t-s)J(t-s)g(s)ds,$$
422
423
$$I_2(t) = \int_0^t \int_0^{\min(\tau,B)} (\tau -s)f(\tau - s)g(s)dsd\tau$$
424
425
$$I_3(t) = J(\mathcal{F})G(\min(B,t-\mathcal{F},0))\mathcal{F}$$
426
427
where $f(.)$ is the probability density function of having an event or dropping out, $J(.)$ is the survival function and $\mathcal{F}$ is the fixed follow up time.
428
429
430
\subsection*{A note about the implementation of lag times}
431
If there is a delay in response to treatment it is possible to include a lag time ($T$). This is achieved by using two models with different hazards in the time before and after $T$. That is, let interval $[0,T]$ have hazard $\Delta_{0T}$ and let $[T,S]$ have $\Delta_{TTS}$. The pieces are joined at $T$ 
432
433
The predicted number of events curve is calculated using equation \ref{eq:1} with the appropriate survival functions, of the form:
434
$$ S(t) = \begin{cases} \exp(-( \lambda_{ot} t)^ a ) & \quad \text{if } t \le T \\
435
          \exp(-( \lambda_{tts} t)^ a )-( \lambda_{ot} ^ a - \lambda_{tts} ^ a )T^ a )  & \quad \text{if }  t > T\ \end{cases} $$ 
436
437
438
For calculating the critical number of events an average hazard is computed. We follow the non-proportional hazard package\footnote{there are minor differences due differences in rounding when calculating $w_1$ and $w_2$} and define the average hazard ratio as:
439
$$
440
\hat{HR} = \exp \left( \frac{w_1\ln(\Delta_{ot}) + w_2\ln(\Delta_{tts})}{w_1+w_2}\right) 
441
$$
442
where $w_1$ is the number of subjects (both arms) who have an event within time T of being randomized on the trial and $w_2$ is the number of subjects (both arms) who have an event after being on the trial for time T and before the study concludes. 
443
444
In earlier versions of the package an alternative definition of the average hazard ratio was used:
445
\begin{equation}
446
\hat{\lambda}_1 = \frac{p^1_{ot}+p^1_{tts}}{(p^1_{ot}/(\lambda^1_{ot})^a)+(p^1_{tts}/(\lambda^1_{tts})^a)} 
447
\end{equation}
448
\begin{equation}
449
\hat{\lambda}_2 = \frac{p^2_{ot}+p^2_{tts}}{(p^2_{ot}/(\lambda^2_{ot})^a)+(p^2_{tts}/(\lambda^2_{tts})^a)} 
450
\end{equation}
451
\begin{equation}
452
\hat{HR}          = \frac{ \hat{\lambda}_2 }{ \hat{\lambda}_1 }
453
\end{equation}
454
where $p^i_{ot}$ and $p^i_{tts}$ are the probabilities of having events between $[0,T]$ and $[T,S]$ in arm $i$, $a$ is the Weibull shape parameter ($=1$ in exponential case) and the $\lambda^i$ are the rate parameters before ($ot$) and after ($tts$) time T for arm $i$.
455
456
\subsection*{Derivation of time at risk}
457
458
\begin{eqnarray*}
459
I_1(t) &=& \text{time at risk for subjects still on the trial at time} \; t \\
460
      &=& \int_0^{\min(B,t)} \mathbb{P}(\text{still on trial at time} \; t | \text{recruited at time} \; s )\mathbb{P}(\text{recruited at time} \; s) \\
461
      && \qquad \qquad \; (\text{time at risk}) dt \\
462
       &=& \int_0^{\min(B,t)} J(t-s)g(s)(t-s)dt     
463
\end{eqnarray*}       
464
465
\begin{eqnarray*}
466
I_2(t) &=& \text{time spent at risk for subjects who dropped out/had event before time} \; t \\
467
&=& \int_0^t (\text{time spent at risk for subjects who dropped out/had event at time} \; \tau)   d\tau \\
468
&=& \int_0^t \int_0^{\min(B,\tau)} \mathbb{P}(\text{event at time} \; \tau | \text{recruited at time} \; s) \\
469
&& \qquad \qquad \qquad \; \mathbb{P}(\text{recruited at time}\; s)(\text{time at risk}) dsd\tau \\
470
&=& \int_0^t \int_0^{\min(B,\tau)} f(\tau-s)g(s)(\tau -s ) dsd\tau
471
\end{eqnarray*}
472
473
If no followup then $I_3(t)=0$ otherwise:
474
475
\begin{eqnarray*}
476
I_3(t) &=& \text{time at risk for subjects censored at follow up before time} \; t\\
477
&=& G(\min(B,t-\mathcal{F},0))J(\mathcal{F})\mathcal{F},
478
\end{eqnarray*}
479
480
where the first term is the probability of recruitment before time $t-\mathcal{F}$, the second term the probability of being censored at $\mathcal{F}$ and the third term ($\mathcal{F}$) is the time spent at risk on the study.
481
482
\subsection*{References}
483
\bibliographystyle{plain}
484
\bibliography{eventPred}
485
486
\end{document}
487