\subsection*{Some handwritten material was inserted}


\subsection*{Some examples, from Venables and Ripley}

Look at the leukaemia data, which is the survival times and white
blood counts for a group of leukaemia patients.  The data has
33 leukaemia patients, and variables.
\begin{verbatim}
wbc:   white blood count
ag:    a test result, present or absent
time:     survival time in weeks
\end{verbatim}
The Sources are
D.R.~Cox and D.~Oakes (1984) {\em Analysis  of  Survival  Data},
Chapman \& Hall, p. 9, who themselves took the data from
P.~Feigl \& M.~Zelen (1965)  {\em Estimation  of  exponential
survival   probabilities   with  concomitant  information}.
Biometrics, 21, 826-838.

The data are, 
\begin{verbatim}
> leuk
      wbc      ag time 
 1   2300 present   65
 2    750 present  156
 3   4300 present  100
 4   2600 present  134
 5   6000 present   16
 6  10500 present  108
 7  10000 present  121
 8  17000 present    4
 9   5400 present   39
10   7000 present  143
11   9400 present   56
12  32000 present   26
13  35000 present   22
14 100000 present    1
15 100000 present    1
16  52000 present    5
17 100000 present   65
18   4400  absent   56
19   3000  absent   65
20   4000  absent   17
21   1500  absent    7
22   9000  absent   16
23   5300  absent   22
24  10000  absent    3
25  19000  absent    4
26  27000  absent    2
27  28000  absent    3
28  31000  absent    8
29  26000  absent    4
30  21000  absent    3
31  79000  absent   30
32 100000  absent    4
33 100000  absent   43
\end{verbatim}

The first thing one might wish to do with these data is plot the two
survival curves,  via
\begin{verbatim}
> attach(leuk)
> plot(survfit(Surv(time) ~ ag), lty=c(2,3))
\end{verbatim}
where the {\tt survfit} function, omputes an estimate of a survival
curve for censored data using either the Kaplan-Meier or the
Fleming-Herrington method or computes the predicted survivor function
for a Cox proportional hazards model.  In our case the model is just
the two levels of {\tt ag}.  The picture looks like,

\centerline{\psfig{figure=surv3.1.eps,angle=-90,width=6in}}

There are clearly differences in the curves, but if they are
significant or not is not obvious.  See V \& R (page 269) for some
suggestions on how to test this.  

There are now many ways we could proceed with these data, including
\begin{itemize}
\item Parametric models based on Gamma errors and the {\tt glm}
  function,
\item Parametric models, based on the exponential and Weibull
  distributions using {\tt survreg}, and
\item The family of Cox models.
\end{itemize}

We will {\bf not} do a lot of the theory, but will attempt to push the
example through with just enough to make sense of what we are doing.


\subsection*{The next example}

\begin{verbatim}
       lwbc <- log(wbc)
       par(mfrow=c(2,1))
       plot(log(time) ~ ag + log(wbc))
       options(contrasts=c("contr.treatment","contr.poly"))
       leuk.glm <- glm(time ~ ag*lwbc, Gamma(log))
        print("## summary(leuk.glm, dispersion=1)")
       print(summary(leuk.glm, dispersion=1)) # force exponential data summary
       print("## anova(leuk.glm))")
       print(anova(leuk.glm))
       # drop interaction term
       leuk.glm <- update(leuk.glm,  ~ .-ag:lwbc)
       print("## summary(leuk.glm, dispersion=1))")
       print(summary(leuk.glm, dispersion=1))
       # compare with natural link
       leuk.glmi <- glm(time ~ ag*wbc, Gamma(inverse))
       print("## summary(leuk.glmi, dispersion=1))")
       print(summary(leuk.glmi, dispersion=1))
       print("## anova(leuk.glmi))")
       print(anova(leuk.glmi))
\end{verbatim}

\centerline{\psfig{figure=surv3.2.eps,angle=-90,width=6in}}
\begin{verbatim}
[1] "## summary(leuk.glm, dispersion=1)"

Call: glm(formula = time ~ ag * lwbc, family = Gamma(log))
Deviance Residuals:
       Min       1Q     Median        3Q      Max 
 -1.992227 -1.21155 -0.3270025 0.2160396 1.564344

Coefficients:
                 Value Std. Error   t value 
(Intercept)  4.3291270  1.9661806  2.201795
         ag  4.1481711  2.5702903  1.613892
       lwbc -0.1525468  0.2026831 -0.752637
    ag:lwbc -0.3291857  0.2668885 -1.233420

(Dispersion Parameter for Gamma family taken to be 1 )

    Null Deviance: 58.13839 on 32 degrees of freedom

Residual Deviance: 38.55468 on 29 degrees of freedom

Number of Fisher Scoring Iterations: 6 

Correlation of Coefficients:
        (Intercept)         ag       lwbc 
     ag -0.7649644                       
   lwbc -0.9918835   0.7587556           
ag:lwbc  0.7532658  -0.9907268 -0.7594297
[1] "## anova(leuk.glm))"
Analysis of Deviance Table

Gamma model

Response: time

Terms added sequentially (first to last)
        Df Deviance Resid. Df Resid. Dev 
   NULL                    32   58.13839
     ag  1 11.94009        31   46.19829
   lwbc  1  5.87920        30   40.31909
ag:lwbc  1  1.76441        29   38.55468
[1] "## summary(leuk.glm, dispersion=1))"

Call: glm(formula = time ~ ag + lwbc, family = Gamma(log))
Deviance Residuals:
       Min        1Q     Median        3Q      Max 
 -2.174855 -1.266119 -0.4246385 0.4961872 1.904819

Coefficients:
                 Value Std. Error   t value 
(Intercept)  5.8134506  1.2931888  4.495438
         ag  1.0182978  0.3492227  2.915898
       lwbc -0.3042296  0.1318634 -2.307157

(Dispersion Parameter for Gamma family taken to be 1 )

    Null Deviance: 58.13839 on 32 degrees of freedom

Residual Deviance: 40.31909 on 30 degrees of freedom

Number of Fisher Scoring Iterations: 6 

Correlation of Coefficients:
     (Intercept)         ag 
  ag -0.2090766            
lwbc -0.9811356   0.0720421
[1] "## summary(leuk.glmi, dispersion=1))"

Call: glm(formula = time ~ ag * wbc, family = Gamma(inverse))
Deviance Residuals:
       Min        1Q     Median        3Q      Max 
 -1.890629 -1.299155 -0.4143898 0.3559901 1.909283

Coefficients:
                    Value   Std. Error     t value 
(Intercept)  5.635111e-02 1.887885e-02  2.98488018
         ag -4.780969e-02 1.932473e-02 -2.47401586
        wbc -2.030302e-08 4.239835e-07 -0.04788634
     ag:wbc  5.926747e-07 5.232047e-07  1.13277789

(Dispersion Parameter for Gamma family taken to be 1 )

    Null Deviance: 58.13839 on 32 degrees of freedom

Residual Deviance: 39.73216 on 29 degrees of freedom

Number of Fisher Scoring Iterations: 6 

Correlation of Coefficients:
       (Intercept)         ag        wbc 
    ag -0.9769269                       
   wbc -0.6746535   0.6590872           
ag:wbc  0.5467114  -0.6022141 -0.8103588
[1] "## anova(leuk.glmi))"
Analysis of Deviance Table

Gamma model

Response: time

Terms added sequentially (first to last)
       Df Deviance Resid. Df Resid. Dev 
  NULL                    32   58.13839
    ag  1 11.94009        31   46.19829
   wbc  1  5.31608        30   40.88221
ag:wbc  1  1.15005        29   39.73216
\end{verbatim}


