The data in the following table summarises the results from
an experiment that investigated the mortality rates of mice 
exposed to nitrous dioxide ($\mbox{NO}_2$).
We wish to investigate how the probability of death is related 
to two explanatory variables: degree of exposure ({\sf dose}) 
and exposure time ({\sf time}).
For each combination of {\sf dose} and {\sf time} listed 
in the table, the number of deaths ({\sf s}) and the total 
number of mice exposed ({\sf n}) is recorded.

\begin{center}
\begin{tabular}{rrrrcrrrr}
\multicolumn{1}{c}{{\sf dose}} & \multicolumn{1}{c}{{\sf time}} &  
\multicolumn{1}{c}{{\sf s}} &  \multicolumn{1}{c}{{\sf n}} & \phantom{xxx}
& \multicolumn{1}{c}{{\sf dose}} &  \multicolumn{1}{c}{{\sf time}} &  
\multicolumn{1}{c}{{\sf s}} &  \multicolumn{1}{c}{{\sf n}} \\ \cline{1-4} \cline{6-9}
low &  96.0 & 44 & 120  & & med  &  7.0 & 152 & 280 \\
low & 168.0 & 37 &  80  & & med  & 14.0 & 55 & 80 \\
low & 336.0 & 43 &  80  & & med  & 24.0 & 98 & 140 \\
low & 504.0 & 35 &  60  & & med  & 48.0 & 121 & 160 \\
med &  0.5 & 29 &    100 & & high & 0.5 & 52 & 120 \\
med &   1.0 & 53 &  200 & & high &  1.0 & 62 & 120 \\
med &   2.0 & 13 &   40 & & high & 1.5 & 61 & 120 \\
med &   3.0 & 75 &  200 & & high & 2.0 &  86 & 120 \\
med &   5.0 & 23 & 40 \\
\end{tabular}
\end{center}

The output from R for the fitted logistic model that 
uses {\sf dose} and {\sf time} as regressors is:
\begin{verbatim}
     > m.fit1<-glm(s/n~dose+time,family=binomial, weights=n)
     > summary(m.fit1)
                   Estimate Std. Error z value Pr(>|z|)    
     (Intercept) -0.9936347  0.2110191  -4.709 2.49e-06 ***
     dosemed      0.9464771  0.2111414   4.483 7.37e-06 ***
     dosehigh     1.1646165  0.2293377   5.078 3.81e-07 ***
     time         0.0035737  0.0007436   4.806 1.54e-06 ***
     ---
         Null deviance: 200.09  on 16  degrees of freedom
     Residual deviance: 170.65  on 13  degrees of freedom
\end{verbatim}

\begin{enumerate}
\item
There are two chi-square tests that are based on 
the values of the Null deviance and the Residual deviance 
given in this output. 
\begin{description}
\item{\bf Test 1:} This test uses the difference between the Null 
deviance and the Residual deviance as the test statistic.  
The P-value of this test is given by: 
\begin{verbatim}
   > 1-pchisq(29.44,3)
   [1] 1.809917e-06
\end{verbatim}

\item{\bf Test 2:}  This test uses the Residual deviance as the test statistic.
The P-value of this test is given by:
\begin{verbatim}
   > 1-pchisq(170.65,13)
   [1] 0
\end{verbatim}
\end{description}

\begin{enumerate}
\item{}
State the null hypothesis that is being tested in each case.
\item{}
What do you conclude about the fitted model from the results of 
these two tests?
\end{enumerate}

\marks{5}

\newpage

\item{}
It was thought that using log(time) instead of time 
might produce a better model. The output for this model 
(along with the P-values for the two  chi-square tests)
is:
\begin{verbatim}
   > m.fit2<-glm(s/n~dose+log(time),family=binomial,weights=n)
   > summary(m.fit2)
               Estimate Std. Error z value Pr(>|z|)    
   (Intercept) -3.03858    0.25613  -11.86   <2e-16 ***
   dosemed      2.11992    0.20238   10.47   <2e-16 ***
   dosehigh     3.16095    0.26889   11.76   <2e-16 ***
   log(time)    0.54995    0.04365   12.60   <2e-16 ***
   ---
       Null deviance: 200.090  on 16  degrees of freedom
   Residual deviance:  16.017  on 13  degrees of freedom

   > 1-pchisq(184.073,3)
   [1] 0

   > 1-pchisq(16.017,13)
   [1] 0.2482131
\end{verbatim}

Does this output support using log(time) instead 
of time in the model? Justify your response.

\marks{5}

\vspace{8mm}

\item{}
Use the following output to produce a 95\% confidence 
interval for the probability of death when dose is at 
the medium level and exposure time is 20.
Note that if $Z\sim\mbox{N}(0,\,1)$, then $\mbox{Pr}(-1.96\le Z \le 1.96)=0.95$.
\begin{verbatim}
   > new.df<-data.frame(list(dose="med",time=20))
   > predict(m.fit2,new.df,se=T)
   $fit
   [1] 0.7288546
   $se.fit
   [1] 0.08396623
\end{verbatim}

\marks{5}

\vspace{8mm}


\item
The output from {\tt dummy.coef} for the model in (b) is:
\begin{verbatim}
   (Intercept):    -3.038579                  
   dose:                 low      med     high
                    0.000000 2.119920 3.160955
   log(time):          0.5499537                  

\end{verbatim}
Use this output to estimate the odds ratio that compares the odds of death for $\mbox{\sf dose}=\mbox{\sf high}$ with the 
odds of death for $\mbox{\sf dose}=\mbox{\sf med}$. Over what range of values for time is this 
comparison valid?
\marks{5}

\end{enumerate}



