Rev 1583 | Blame | Last modification | View Log | Download | RSS feed
\name{lmer}\docType{genericFunction}\alias{lmer}\alias{lmer,formula-method}\concept{GLMM}% << so it's found\title{Fit (Generalized) Linear Mixed-Effects Models}\description{This generic function fits a linear mixed-effects model with nested orcrossed grouping factors for the random effects.}\synopsis{lmer(formula, data, family, method = c("REML", "ML", "PQL", "Laplace", "AGQ"),control = list(), subset, weights, na.action, offset,model = TRUE, x = FALSE, y = FALSE, \dots)}\usage{lmer(formula, data, family,method = c("REML", "ML", "PQL", "Laplace", "AGQ"),\dots)}\arguments{\item{formula}{a two-sided linear formula object describing thefixed-effects part of the model, with the response on the left of a\code{~} operator and the terms, separated by \code{+} operators, onthe right. The vertical bar character \code{"|"} separates anexpression for a model matrix and a grouping factor.}\item{data}{an optional data frame containing the variables named in\code{formula}. By default the variables are taken from theenvironment from which \code{lmer} is called.}\item{family}{a GLM family, see \code{\link[stats]{glm}}. If \code{family} ismissing then a linear mixed model is fit; otherwise a generalizedlinear mixed model is fit.}\item{method}{a character string. For a linear mixed model thedefault is \code{"REML"} indicating that the model should be fit bymaximizing the restricted log-likelihood. The alternative is\code{"ML"} indicating that the log-likelihood should bemaximized. (This method is sometimes called "full" maximumlikelihood.) For a generalized linear mixed model the criterionis always the log-likelihood but this criterion does not have aclosed form expression and must be approximated. The default approximation is\code{"PQL"} or penalized quasi-likelihood. Alternatives are\code{"Laplace"} or \code{"AGQ"} indicating the Laplacian andadaptive Gaussian quadrature approximations respectively. The\code{"PQL"} method is fastest but least accurate. The\code{"Laplace"} method is intermediate in speed and accuracy.The \code{"AGQ"} method is the most accurate but can beconsiderably slower than the others.}\item{\dots}{Optional arguments for methods. Currently none are used.}}}\details{This is a revised version of the \code{\link[nlme]{lme}} function from the\pkg{nlme} package. This version uses a different method ofspecifying random-effects terms and allows for fitting generalizedlinear mixed models as well as linear mixed models.Additional standard arguments to model-fitting functions can be passedto \code{lmer}.\describe{\item{subset}{an optional expression indicating the subset of the rows of\code{data} that should be used in the fit. This can be a logicalvector, or a numeric vector indicating which observation numbers areto be included, or a character vector of the row names to beincluded. All observations are included by default.}\item{na.action}{a function that indicates what should happen when thedata contain \code{NA}s. The default action (\code{na.fail}) causes\code{lme} to print an error message and terminate if there are anyincomplete observations.}\item{control}{a named list of control values for the estimationalgorithm. Possible control options and their values are:\describe{\item{maxIter}{maximum number of iterations for the \code{lme}optimization algorithm. Default is 50.}\item{msMaxIter}{maximum number of iterationsfor the \code{nlminb} optimization step inside the \code{lme}optimization. Default is 200.}\item{niterEM}{number of iterations for the EM algorithm used to refinethe initial estimates of the random effects variance-covariancecoefficients. Default is 15.}\item{msVerbose}{a logical value passed as the \code{trace} argument to\code{nlminb} (see documentation on that function). Default is\code{getOption("verbose")}.}\item{PQLmaxIt}{maximum number of iterations for the PQLalgorithm when fitting generalized linear mixed models.Default is 30.}\item{EMverbose}{a logical value indicating if verbose outputshould be produced during the EM iterations. Default is\code{getOption("verbose"}.}\item{analyticGradient}{a logical value indicating if theanalytic gradient of the objective should be used. Thisoption is for testing purposes and would not normally bechanged from the default. Default is \code{TRUE}.}\item{analyticHessian}{a logical value indicating if theanalytic Hessian of the objective should be calculated. Thisis an experimental feature and at present the default is\code{FALSE}. In the future we may use the analytic Hessian inthe optimization.}}Defaults to an empty list.}\item{model, x}{logicals. If \code{TRUE} the correspondingcomponents of the fit (the model frame, the model matrices)are returned.}}}\value{An \code{\link[Matrix]{lmer-class}{lmer}} object.}%\references{ ~put references to the literature/web site here ~ }%\author{}%\note{}\seealso{\code{\link[Matrix]{lmer-class}}, \code{\link[stats]{lm}}}\examples{(fm1 <- lmer(decrease ~ treatment + (1|rowpos) + (1|colpos),OrchardSprays))}\keyword{models}\keyword{methods}