lme4 (version 1.1-10)

lmList: Fit List of lm Objects with a Common Model

Description

Fit a list of lm objects with a common model for different subgroups of the data.

Usage

lmList(formula, data, family, subset, weights, na.action,
       offset, pool = TRUE, ...)

Arguments

formula
a linear formula object of the form y ~ x1+...+xn | g. In the formula object, y represents the response, x1,...,xn the covariates, and g the
family
an optional family specification for a generalized linear model.
pool
logical scalar, should the variance estimate pool the residual sums of squares
...
additional, optional arguments to be passed to the model function or family evaluation.
data
an optional data frame containing the variables named in formula. By default the variables are taken from the environment from which lmer is called. See Details.
subset
an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector
weights
an optional vector of prior weights to be used in the fitting process. Should be NULL or a numeric vector.
na.action
a function that indicates what should happen when the data contain NAs. The default action (na.omit, inherited from the factory fresh value of getOption("na.action")) strips any obse
offset
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. One or more

Value

  • an object of class lmList4 (see there, notably for the methods defined).

Details

  • datashould be a data frame (not, e.g. agroupedDataobject from thenlmepackage); useas.data.framefirst to convert the data.
  • Whiledatais optional, the package authorsstronglyrecommend its use, especially when later applying methods such asupdateanddrop1to the fitted model (such methods are not guaranteed to work properly if data is omitted). Ifdatais omitted, variables will be taken from the environment offormula(if specified as a formula) or from the parent frame (if specified as a character vector).

See Also

lmList4

Examples

Run this code
fm.plm  <- lmList(Reaction ~ Days | Subject, sleepstudy)
coef(fm.plm)
fm.2  <- update(fm.plm, pool = FALSE)
## coefficients are the same, "pooled or unpooled":
stopifnot( all.equal(coef(fm.2), coef(fm.plm)) )

(ci <- confint(fm.plm)) # print and rather *see* :
plot(ci)                # how widely they vary for the individuals

Run the code above in your browser using DataCamp Workspace