

\documentclass{chapman}

%%% copy Sweave.sty definitions

%%% keeps `sweave' from adding `\usepackage{Sweave}': DO NOT REMOVE
%\usepackage{Sweave} 


\RequirePackage[T1]{fontenc}
\RequirePackage{graphicx,ae,fancyvrb}
\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}
\usepackage{relsize}

\DefineVerbatimEnvironment{Sinput}{Verbatim}{}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{fontfamily=courier,
                                              fontshape=it,
                                              fontsize=\relsize{-1}}
\DefineVerbatimEnvironment{Scode}{Verbatim}{}
\newenvironment{Schunk}{}{}

%%% environment for raw output
\newcommand{\SchunkRaw}{\renewenvironment{Schunk}{}{}
    \DefineVerbatimEnvironment{Soutput}{Verbatim}{fontfamily=courier,
                                                  fontshape=it,
                                                  fontsize=\small}
    \rawSinput
}

%%% environment for labeled output
\newcommand{\nextcaption}{}
\newcommand{\SchunkLabel}{
  \renewenvironment{Schunk}{\begin{figure}[ht] }{\caption{\nextcaption}
  \end{figure} }
  \DefineVerbatimEnvironment{Sinput}{Verbatim}{frame = topline}
  \DefineVerbatimEnvironment{Soutput}{Verbatim}{frame = bottomline, 
                                                samepage = true,
                                                fontfamily=courier,
                                                fontshape=it,
                                                fontsize=\relsize{-1}}
}


%%% S code with line numbers
\DefineVerbatimEnvironment{Sinput}
{Verbatim}
{
%%  numbers=left
}

\newcommand{\numberSinput}{
    \DefineVerbatimEnvironment{Sinput}{Verbatim}{numbers=left}
}
\newcommand{\rawSinput}{
    \DefineVerbatimEnvironment{Sinput}{Verbatim}{}
}


%%% R / System symbols
\newcommand{\R}{\textsf{R}}
\newcommand{\rR}{{R}}
\renewcommand{\S}{\textsf{S}}
\newcommand{\SPLUS}{\textsf{S-PLUS}}
\newcommand{\rSPLUS}{{S-PLUS}}
\newcommand{\SPSS}{\textsf{SPSS}}
\newcommand{\EXCEL}{\textsf{Excel}}
\newcommand{\ACCESS}{\textsf{Access}}
\newcommand{\SQL}{\textsf{SQL}}
%%\newcommand{\Rpackage}[1]{\hbox{\rm\textit{#1}}}
%%\newcommand{\Robject}[1]{\hbox{\rm\texttt{#1}}}
%%\newcommand{\Rclass}[1]{\hbox{\rm\textit{#1}}}
%%\newcommand{\Rcmd}[1]{\hbox{\rm\texttt{#1}}}
\newcommand{\Rpackage}[1]{\index{#1 package@\textit{#1} package}\textit{#1}}
\newcommand{\Robject}[1]{\texttt{#1}}
\newcommand{\Rclass}[1]{\index{#1 class@\textit{#1} class}\textit{#1}}
\newcommand{\Rcmd}[1]{\index{#1 function@\texttt{#1} function}\texttt{#1}}
\newcommand{\Roperator}[1]{\texttt{#1}}
\newcommand{\Rarg}[1]{\texttt{#1}}
\newcommand{\Rlevel}[1]{\texttt{#1}}


%%% other symbols
\newcommand{\file}[1]{\hbox{\rm\texttt{#1}}}
%%\newcommand{\stress}[1]{\index{#1}\textit{#1}} 
\newcommand{\stress}[1]{\textit{#1}} 
\newcommand{\booktitle}[1]{`#1'} %%'

%%% Math symbols
\newcommand{\E}{\mathsf{E}}   
\newcommand{\Var}{\mathsf{Var}}   
\newcommand{\Cov}{\mathsf{Cov}}   
\newcommand{\Cor}{\mathsf{Cor}}   
\newcommand{\x}{\mathbf{x}}   
\newcommand{\y}{\mathbf{y}}   
\renewcommand{\a}{\mathbf{a}}
\newcommand{\W}{\mathbf{W}}   
\newcommand{\C}{\mathbf{C}}   
\renewcommand{\H}{\mathbf{H}}   
\newcommand{\X}{\mathbf{X}}   
\newcommand{\B}{\mathbf{B}}   
\newcommand{\V}{\mathbf{V}}   
\newcommand{\I}{\mathbf{I}}   
\newcommand{\D}{\mathbf{D}}   
\newcommand{\bS}{\mathbf{S}}   
\newcommand{\N}{\mathcal{N}}   
\renewcommand{\P}{\mathsf{P}}   
\usepackage{amstext}

%%% links
\usepackage{hyperref}

\hypersetup{%
  pdftitle = {A Handbook of Statistical Analyses Using R},
  pdfsubject = {Book},
  pdfauthor = {Brian S. Everitt and Torsten Hothorn},
  colorlinks = {true},
  linkcolor = {blue},
  citecolor = {blue},
  urlcolor = {red},
  hyperindex = {true},
  linktocpage = {true},
}


%%% captions & tables
%% <FIXME>: conflics with figure definition in chapman.cls
%%\usepackage[format=hang,margin=10pt,labelfont=bf]{caption}
%% </FIMXE>
\usepackage{longtable}
\usepackage{rotating}

%%% R symbol in chapter 1
\usepackage{wrapfig}

%%% Bibliography
\usepackage[round,comma]{natbib}
\renewcommand{\refname}{References \addcontentsline{toc}{chapter}{References}}
\citeindexfalse

%%% texi2dvi complains that \newblock is undefined, hm...
\def\newblock{\hskip .11em plus .33em minus .07em}

%%% Example sections
\newcounter{exercise}[chapter]
\setcounter{exercise}{0}
\newcommand{\exercise}{\item{\stepcounter{exercise} Ex.
                       \arabic{chapter}.\arabic{exercise} }}


%% URLs
\newcommand{\curl}[1]{\begin{center} \url{#1} \end{center}}

%%% for manual corrections
%\renewcommand{\baselinestretch}{2}

%%% plot sizes
\setkeys{Gin}{width=0.95\textwidth}

%%% color
\usepackage{color}

%%% hyphenations
\hyphenation{drop-out}

%%% new bidirectional quotes need 
\usepackage[utf8]{inputenc}
\begin{document}

%% Title page

\title{A Handbook of Statistical Analyses Using \R}

\author{Brian S. Everitt and Torsten Hothorn}

\maketitle
%%\VignetteIndexEntry{Chapter Preface}


\SweaveOpts{prefix.string=figures/HSAUR,eps=FALSE,keep.source=TRUE} 

<<setup, echo = FALSE, results = hide>>=
rm(list = ls())
if (!file.exists("tables")) dir.create("tables")
if (!file.exists("figures")) dir.create("figures")
set.seed(290875)
options(prompt = "R> ", continue = "+  ",
    width = 63, # digits = 4, 
    SweaveHooks = list(leftpar = function() 
        par(mai = par("mai") * c(1, 1.05, 1, 1))))
HSAURpkg <- require("HSAUR")
if (!HSAURpkg) stop("cannot load package ", sQuote("HSAUR"))
rm(HSAURpkg)
a <- Sys.setlocale("LC_ALL", "C")
book <- TRUE
refs <- cbind(c("AItR", "SI", "CI", "ANOVA", "MLR", "GLM", 
                "DE", "RP", "SA", "ALDI", "ALDII", "MA", "PCA", 
                "MDS", "CA"), 1:15)
ch <- function(x, book = TRUE) {
    ch <- refs[which(refs[,1] == x),]
    if (book) {
        return(paste("Chapter~\\\\ref{", ch[1], "}", sep = ""))
    } else {
        return(paste("Chapter~\\\\ref{", ch[2], "}", sep = ""))
    }
}
@

\pagestyle{headings}


\pagestyle{empty}

\chapter*{Preface}

This book is intended as a guide to data analysis with the \R{} system for
statistical computing. \R{} is an environment incorporating an implementation 
of the \S{} programming language, which is powerful, flexible and has excellent 
graphical facilities \citep{HSAUR:R}. In the Handbook we aim to give   
relatively brief and straightforward descriptions of how to conduct
a range of statistical analyses using \R{}. Each chapter deals with
the analysis appropriate for one or several data sets. A brief
account of the relevant statistical background is included in
each chapter along with appropriate references, but our prime    
focus is on how to use \R{} and how to interpret results. We hope 
the book will provide students and researchers in many disciplines
with a self-contained means of using \R{} to analyse their data.

\R{} is an open-source project developed by dozens of volunteers for more
than ten years now and is available from the Internet under the General 
Public Licence. \R{} has become the \stress{lingua franca} of statistical
computing. Increasingly, implementations of new statistical methodology 
first appear as \R{} add-on packages. In some communities, such as in bioinformatics, 
\R{} already is the primary workhorse for statistical analyses. 
Because the sources
of the \R{} system are open and available to everyone without restrictions
and because of its powerful language and graphical capabilities,
\R{} has started to become the main computing engine for reproducible
statistical research
\citep{HSAUR:Leisch2002b,HSAUR:Leisch2002a,HSAUR:Leisch2003,HSAUR:LeischRossini2003,
HSAUR:Gentleman2005}. For a reproducible piece of research, the original 
observations, all data preprocessing steps, the statistical analysis as well
as the scientific report form a unity and all need to be available for 
inspection, reproduction and modification by the readers.

Reproducibility is a natural requirement for textbooks such as the
\booktitle{Handbook of Statistical Analyses Using \R{}}
and therefore this book is fully reproducible using an \R{} version 
greater or equal to \Sexpr{paste(version$major, version$minor, sep = ".")}. 
All analyses and results, including figures and tables, can be reproduced 
by the reader
without having to retype a single line of \R{} code.
The data sets presented in this book are collected in a dedicated add-on package called 
\Rpackage{HSAUR} accompanying this book. The package can be installed
from the Comprehensive \R{} Archive Network (CRAN) via 
<<pre-HSAUR-install, eval = FALSE>>=
install.packages("HSAUR")
@
and its functionality is attached by 
<<pre-HSAUR, echo = TRUE>>=
library("HSAUR")
@
The relevant parts of each chapter are available as a \stress{vignette},
basically a document including both the \R{} sources and the rendered output 
of every analysis contained in the book. For example, the first chapter can 
be inspected by
<<pre-vignette, echo = TRUE, eval = FALSE>>= 
vignette("Ch_introduction_to_R", package = "HSAUR")
@
and the \R{} sources are available for reproducing our analyses by
<<pre-vignette-source, echo = TRUE, eval = FALSE>>= 
edit(vignette("Ch_introduction_to_R", package = "HSAUR"))
@
An overview on all chapter vignettes included in the package can be obtained
from
<<pre-vignette-source, echo = TRUE, eval = FALSE>>=
vignette(package = "HSAUR")
@
We welcome comments on the \R{} package \Rpackage{HSAUR}, and
where we think these add to or improve our analysis of a data set 
we will incorporate them into the package and, hopefully at a later stage, 
into a revised or second edition of the book.

Plots and tables of results obtained from \R{} are all 
labelled as `Figures' in the %%'
text. For the graphical material, the corresponding figure also contains
the `essence' of the \R{} code used to produce the figure, although this %%'
code may differ a little from that given in the \Rpackage{HSAUR} package,
since the latter may include some features, for example thicker line widths,
designed to make a basic plot more suitable for publication. 

We would like to thank the \R{} Development Core Team for the \R{} system,
and authors of contributed add-on packages, particularly Uwe Ligges and Vince Carey
for helpful advice on \Rpackage{scatterplot3d} and \Rpackage{gee}. Kurt
Hornik, Ludwig A. Hothorn, Fritz Leisch and Rafael Wei{\ss}bach provided
good advice with some statistical and technical problems. We are 
also very grateful to Achim Zeileis for reading the entire manuscript,
pointing out inconsistencies or even bugs and for 
making many suggestions which have led to improvements. Lastly we
would like to thank the CRC Press staff, in particular Rob Calver, for
their support during the preparation of the book. 
Any errors in the book are, of course, the joint
responsibility of the two authors.

\vspace*{1cm}

\begin{flushright}
\textbf{Brian S. Everitt and Torsten Hothorn} \\ London and Erlangen, December 2005
\end{flushright}

\bibliographystyle{LaTeXBibTeX/refstyle}
\bibliography{LaTeXBibTeX/HSAUR}   
\end{document}
