Rev 6563 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File nlme/man/predict.nlme.Rd% Part of the nlme package for R% Distributed under GPL 2 or later: see nlme/LICENCE.note\name{predict.nlme}\title{Predictions from an nlme Object}\usage{\method{predict}{nlme}(object, newdata, level = Q, asList = FALSE,na.action = na.fail, naPattern = NULL, \dots)}\alias{predict.nlme}\arguments{\item{object}{an object inheriting from class \code{"\link{nlme}"},representing a fitted nonlinear mixed-effects model.}\item{newdata}{an optional data frame to be used for obtaining thepredictions. All variables used in the nonlinear model, the fixed andthe random effects models, as well as the grouping factors, must bepresent in the data frame. If missing, the fitted values arereturned.}\item{level}{an optional integer vector giving the level(s) of groupingto be used in obtaining the predictions. Level values increase fromoutermost to innermost grouping, with level zero corresponding to thepopulation predictions. Defaults to the highest or innermost level ofgrouping (and is \code{object$dims$Q}).}\item{asList}{an optional logical value. If \code{TRUE} and a singlevalue is given in \code{level}, the returned object is a list withthe predictions split by groups; else the returned value iseither a vector or a data frame, according to the length of\code{level}.}\item{na.action}{a function that indicates what should happen when\code{newdata} contains \code{NA}s. The default action(\code{na.fail}) causes the function to print an error message andterminate if there are any incomplete observations.}\item{naPattern}{an expression or formula object, specifying which returnedvalues are to be regarded as missing.}\item{\dots}{some methods for this generic require additionalarguments. None are used in this method.}}\description{The predictions at level \eqn{i} are obtained by adding together thecontributions from the estimated fixed effects and the estimatedrandom effects at levels less or equal to \eqn{i} and evaluating themodel function at the resulting estimated parameters. If group valuesnot included in the original grouping factors are present in\code{newdata}, the corresponding predictions will be set to\code{NA} for levels greater or equal to the level at which theunknown groups occur.}\value{if a single level of grouping is specified in \code{level}, thereturned value is either a list with the predictions split by groups(\code{asList = TRUE}) or a vector with the predictions(\code{asList = FALSE}); else, when multiple grouping levels arespecified in \code{level}, the returned object is a data frame withcolumns given by the predictions at different levels and the groupingfactors.}\author{José Pinheiro and Douglas Bates \email{bates@stat.wisc.edu}}\seealso{\code{\link{nlme}}, \code{\link{fitted.lme}}}\examples{head(Loblolly) # groupedData w/ 'Seed' is grouping variable :## Grouped Data: height ~ age | Seed## height age Seed## 1 4.51 3 301## 15 10.89 5 301## .. ..... . ...fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc), data = Loblolly,fixed = Asym + R0 + lrc ~ 1,random = Asym ~ 1, ## <---grouping---> Asym ~ 1 | Seedstart = c(Asym = 103, R0 = -8.5, lrc = -3.3))fm1age. <- seq(from = 2, to = 30, by = 2)newLL.301 <- data.frame(age = age., Seed = 301)newLL.329 <- data.frame(age = age., Seed = 329)(p301 <- predict(fm1, newLL.301, level = 0:1))(p329 <- predict(fm1, newLL.329, level = 0:1))## Prediction are the same at level 0 :all.equal(p301[,"predict.fixed"],p329[,"predict.fixed"])## and differ by the 'Seed' effect at level 1 :p301[,"predict.Seed"] -p329[,"predict.Seed"]}\keyword{models}