\HeaderA{qda}{Quadratic Discriminant Analysis}{qda}
\aliasA{model.frame.qda}{qda}{model.frame.qda}
\aliasA{print.qda}{qda}{print.qda}
\methaliasA{qda.data.frame}{qda}{qda.data.frame}
\methaliasA{qda.default}{qda}{qda.default}
\methaliasA{qda.formula}{qda}{qda.formula}
\methaliasA{qda.matrix}{qda}{qda.matrix}
\keyword{multivariate}{qda}
\begin{Description}\relax
Quadratic discriminant analysis.
\end{Description}
\begin{Usage}
\begin{verbatim}
qda(x, ...)

## S3 method for class 'formula':
qda(formula, data, ..., subset, na.action)

## Default S3 method:
qda(x, grouping, prior = proportions,
    method, CV = FALSE, nu, ...)

## S3 method for class 'data.frame':
qda(x, ...)

## S3 method for class 'matrix':
qda(x, grouping, ..., subset, na.action)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{formula}] A formula of the form \code{groups \textasciitilde{} x1 + x2 + ...}  That is, the
response is the grouping factor and the right hand side specifies
the (non-factor) discriminators.

\item[\code{data}] Data frame from which variables specified in \code{formula} are
preferentially to be taken.

\item[\code{x}] (required if no formula is given as the principal argument.)
a matrix or data frame or Matrix containing the explanatory variables.

\item[\code{grouping}] (required if no formula principal argument is given.)
a factor specifying the class for each observation.

\item[\code{prior}] the prior probabilities of class membership.  If unspecified, the class
proportions for the training set are used.  If specified, the
probabilities should be specified in the order of the factor levels.

\item[\code{subset}] An index vector specifying the cases to be used in the training
sample.  (NOTE: If given, this argument must be named.)

\item[\code{na.action}] A function to specify the action to be taken if \code{NA}s are found.
The default action is for the procedure to fail.  An alternative is
na.omit, which leads to rejection of cases with missing values on
any required variable.  (NOTE: If given, this argument must be named.)

\item[\code{method}] \code{"moment"} for standard estimators of the mean and variance,
\code{"mle"} for MLEs, \code{"mve"} to use \code{cov.mve}, or \code{"t"} for robust
estimates based on a t distribution.

\item[\code{CV}] If true, returns results (classes and posterior probabilities) for
leave-out-out cross-validation. Note that if the prior is estimated,
the proportions in the whole dataset are used.

\item[\code{nu}] degrees of freedom for \code{method = "t"}.

\item[\code{...}] arguments passed to or from other methods.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Uses a QR decomposition which will give an error message if the
within-group variance is singular for any group.
\end{Details}
\begin{Value}
an object of class \code{"qda"} containing the following components:

\begin{ldescription}
\item[\code{prior}] the prior probabilities used.

\item[\code{means}] the group means.

\item[\code{scaling}] for each group \code{i}, \code{scaling[,{},i]} is an array which transforms observations
so that within-groups covariance matrix is spherical.

\item[\code{ldet}] a vector of half log determinants of the dispersion matrix.

\item[\code{lev}] the levels of the grouping factor.

\item[\code{terms}] (if formula is a formula)
an object of mode expression and class term summarizing
the  formula.

\item[\code{call}] the (matched) function call.

\item[\code{class}] The MAP classification (a factor)

\item[\code{posterior}] posterior probabilities for the classes

\end{ldescription}
\end{Value}
\begin{References}\relax
Venables, W. N. and Ripley, B. D. (2002)
\emph{Modern Applied Statistics with S.} Fourth edition.  Springer.

Ripley, B. D. (1996)
\emph{Pattern Recognition and Neural Networks}. Cambridge University Press.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{predict.qda}{predict.qda}}, \code{\LinkA{lda}{lda}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
tr <- sample(1:50, 25)
train <- rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3])
test <- rbind(iris3[-tr,,1], iris3[-tr,,2], iris3[-tr,,3])
cl <- factor(c(rep("s",25), rep("c",25), rep("v",25)))
z <- qda(train, cl)
predict(z,test)$class
\end{ExampleCode}
\end{Examples}

