\section*{Another Example of a contrast}
The following data are drawn from Box, Hunter, and Hunter, {\em
  Statistics for Experimenters}.  The data are from an experiment
about blood coagulation times in animals.  A group of 24 animals are
given 4 different diets.  The base question is ``Is the coagulation
time effected by diet''.  The researchers believe, a-priori, that
diets B and C are similar and (different to) diets A and D.  
Here are the data
\begin{verbatim}
A       B       C       D
62      63      68      56
60      67      66      62
63      71      71      60
59      64      67      61
        65      68      63
        66      68      63
                        59
\end{verbatim}
Here are the first few lines of the reformated file, {\tt blood.dat}
\begin{verbatim}
Time   Type
62      A
60      A
.....
\end{verbatim}
Here is the start of an analysis.
\begin{verbatim}
> blood <- read.table("blood.dat", header=T)
> blood 
   Time Type 
 1   62    A
 2   60    A
......
> motif()
\end{verbatim}
\newpage
\begin{verbatim}
> plot.factor(blood)
\end{verbatim}

\psfig{figure=blood.eps,angle=-90,width=4in}


It seems reasonable to assume that groups B and C are similar and that
groups A and D are also similar (but different to B and C).  A
contrast which would check that is 
$$
   -A + B + C - D $$

Lets do the simple anova with contrast.
\begin{verbatim}
> anova(aov( Time ~ Type) )
Analysis of Variance Table

Response: Time

Terms added sequentially (first to last)
          Df Sum of Sq  Mean Sq  F Value        Pr(F) 
Type       3  238.2857 79.42857 14.83708 3.238591e-05
Residuals 19  101.7143  5.35338                      
> 
\end{verbatim}
This analysis shows us that there is certainly a Type effect (very
large F value).
The next analysis does the 1 degree of freedom contrast to test the
specific question.
\begin{verbatim}
> mymod <- aov( Time ~ C(Type, c(-1,1,1,-1),1) + Type)
> anova(mymod)
Analysis of Variance Table

Response: Time

Terms added sequentially (first to last)
                            Df Sum of Sq  Mean Sq  F Value     Pr(F) 
C(Type, c(-1, 1, 1, -1), 1)  1  225.8182 225.8182 42.18233 0.0000032
Type                         2   12.4675   6.2338  1.16445 0.3333938
Residuals                   19  101.7143   5.3534                   
\end{verbatim}

This shows a very compelling answer.  Almost all of the Sum of Squares
for the treatments is due to that one contrast (226 out of 238), and
the F-test for the ``rest'' of the treatment effect is far from
significant.

Finally, at the very least we should do some residual plots.  Plotting
residuals against fitted values is always a good idea, but in this
case, there are only 4 fitted values.  The following plots (which are
automatically generated by one command) pretty much capture the
situation.
\begin{verbatim}
> plot(mymod)
\end{verbatim}

\psfig{figure=blood1.eps,angle=-90,width=7in}

\newpage
\begin{verbatim}
> plot.factor(data.frame(resid(mymod), Type)) 
\end{verbatim}

\psfig{figure=blood2.eps,angle=-90,width=4in}

Thats it for simple contrasts.  We now need to worry about how
multiple comparisons get in the way of reasonable inference.


% Local Variables: 
% mode: latex
% TeX-master: t
% TeX-master: t
% End: 
