\HeaderA{fitted.lme}{Extract lme Fitted Values}{fitted.lme}
\keyword{models}{fitted.lme}
\begin{Description}\relax
The fitted values at level \eqn{i}{} are obtained by adding together the
population fitted values (based only on the fixed effects estimates)
and the estimated contributions of the random effects to the fitted
values at grouping levels less or equal to \eqn{i}{}. The resulting
values estimate the best linear unbiased predictions (BLUPs) at level
\eqn{i}{}.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'lme':
fitted(object, level, asList, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] an object inheriting from class \code{lme}, representing
a fitted linear mixed-effects model.
\item[\code{level}] an optional integer vector giving the level(s) of grouping
to be used in extracting the fitted values from \code{object}. Level
values increase from outermost to innermost grouping, with
level zero corresponding to the population fitted values. Defaults to
the highest or innermost level of grouping.
\item[\code{asList}] an optional logical value. If \code{TRUE} and a single
value is given in \code{level}, the returned object is a list with
the fitted values split by groups; else the returned value is
either a vector or a data frame, according to the length of
\code{level}. Defaults to \code{FALSE}.
\item[\code{...}] some methods for this generic require additional
arguments.  None are used in this method.
\end{ldescription}
\end{Arguments}
\begin{Value}
If a single level of grouping is specified in \code{level}, the
returned value is either a list with the fitted values split by groups
(\code{asList = TRUE}) or a vector with the fitted values
(\code{asList = FALSE}); else, when multiple grouping levels are
specified in \code{level}, the returned object is a data frame with
columns given by the fitted values at different levels and the
grouping factors.
\end{Value}
\begin{Author}\relax
Jose Pinheiro \email{Jose.Pinheiro@pharma.novartis.com} and Douglas Bates \email{bates@stat.wisc.edu}
\end{Author}
\begin{References}\relax
Bates, D.M. and Pinheiro, J.C. (1998) "Computational methods for
multilevel models" available in PostScript or PDF formats at
http://nlme.stat.wisc.edu/pub/NLME/

Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models
in S and S-PLUS", Springer, esp. pp. 235, 397.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{lme}{lme}}, \code{\LinkA{residuals.lme}{residuals.lme}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
fm1 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
fitted(fm1, level = 0:1)
\end{ExampleCode}
\end{Examples}

