\HeaderA{getVarCov}{Extract variance-covariance matrix}{getVarCov}
\methaliasA{getVarCov.gls}{getVarCov}{getVarCov.gls}
\methaliasA{getVarCov.lme}{getVarCov}{getVarCov.lme}
\aliasA{print.VarCov}{getVarCov}{print.VarCov}
\keyword{models}{getVarCov}
\begin{Description}\relax
Extract the variance-covariance matrix from a fitted model, such as a
mixed-effects model.
\end{Description}
\begin{Usage}
\begin{verbatim}
getVarCov(obj, ...)
## S3 method for class 'lme':
getVarCov(obj, individuals,
    type = c("random.effects", "conditional", "marginal"), ...)
## S3 method for class 'gls':
getVarCov(obj, individual = 1, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{obj}] A fitted model.  Methods are available for models fit by
\code{\LinkA{lme}{lme}} and by \code{\LinkA{gls}{gls}}
\item[\code{individuals}] For models fit by \code{\LinkA{lme}{lme}} a vector of
levels of the grouping factor can be specified for the conditional
or marginal variance-covariance matrices.
\item[\code{individual}] For models fit by \code{\LinkA{gls}{gls}} the only type of
variance-covariance matrix provided is the marginal
variance-covariance of the responses by group.  The
optional argument \code{individual} specifies the group of responses.
\item[\code{type}] For models fit by \code{\LinkA{lme}{lme}} the \code{type}
argument specifies the type of variance-covariance matrix, either
\code{"random.effects"} for the random-effects variance-covariance
(the default), or \code{"conditional"} for the conditional.
variance-covariance of the responses or \code{"marginal"} for the
the marginal variance-covariance of the responses.
\item[\code{...}] Optional arguments for some methods, as described above
\end{ldescription}
\end{Arguments}
\begin{Value}
A variance-covariance matrix or a list of variance-covariance matrices.
\end{Value}
\begin{Author}\relax
Mary Lindstrom \email{lindstro@biostat.wisc.edu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{lme}{lme}}, \code{\LinkA{gls}{gls}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
fm1 <- lme(distance ~ age, data = Orthodont, subset = Sex == "Female")
getVarCov(fm1)
getVarCov(fm1, individual = "F01", type = "marginal")
getVarCov(fm1, type = "conditional")
fm2 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
           correlation = corAR1(form = ~ 1 | Mare))
getVarCov(fm2)
\end{ExampleCode}
\end{Examples}

