\Header{var}{Covariance Matrices}
\keyword{univar}{var}
\keyword{multivariate}{var}
\begin{Usage}
\begin{verbatim}
var(x, y=x, na.rm=FALSE, use)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] a matrix or vector.
\item[\texttt{y}] a matrix or vector.
\item[\texttt{na.rm}] logical.
\item[\texttt{use}] an optional character string giving a
method for computing covariances in the presence
of missing values.  This must be one of \texttt{"all.obs"},
\texttt{"complete.obs"} or \texttt{"pairwise.complete.obs"},
with abbreviation being permitted.
\end{ldescription}
\end{Arguments}
\begin{Description}
\texttt{var} computes the variance of \texttt{x} and the
covariance of \texttt{x} and \texttt{y} if \texttt{x} and \texttt{y}
are vectors. If \texttt{x} and \texttt{y} are matrices then
the covariance between the columns of \texttt{x} and the
the columns of \texttt{y} are computed.

If \texttt{na.rm} is \texttt{TRUE} then the complete observations (rows)
are use to compute the variance.  If \texttt{na.rm} is \texttt{FALSE}
and there are missing values, then \texttt{var} will fail.

The argument \texttt{use} can also be used for describing how
to handle missing values.
Specifying \texttt{use="all"} is equivalent to specifying
\texttt{na.rm=FALSE} and specifying \texttt{use="pair"} is equivalent to
\texttt{na.rm=TRUE}.
If \texttt{use="pair"}, then all the observations which are
complete for a pair of variables is used to compute the
covariance for that pair of variables.
This can result in covariance matrices which are not
positive semidefinite.\end{Description}
\begin{Examples}
\begin{ExampleCode}
var(1:10)
# 9.166667

var(1:5,1:5)
# 2.5
\end{ExampleCode}
\end{Examples}

