The lme4 Package

The lme4 Package
July 27, 2006
Version 0.995-2
Date 2006-01-17
Title Linear mixed-effects models using S4 classes
Author Douglas Bates <[email protected]> and Deepayan Sarkar <[email protected]>
Maintainer Douglas Bates <[email protected]>
Description Fit linear and generalized linear mixed-effects models.
Depends methods, R(>= 2.2.0), Matrix(>= 0.995-2), lattice
Imports graphics, stats
Suggests mlmRev
SaveImage no
LazyLoad yes
License GPL version 2 or later
R topics documented:
gsummary .
lmList-class
lmList . . .
pooledSD .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Index
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
3
4
5
6
1
2
gsummary
gsummary
Summarize a data frame by group
Description
Provide a summary of the variables in a data frame by groups of rows.
Usage
gsummary(object, FUN, form, level, groups, omitGroupingFactor = FALSE, invariant
Arguments
object
an object to be summarized - usually a data.frame
an optional summary function or a list of summary functions to be applied to
each variable in the frame. The function or functions are applied only to variables in object that vary within the groups defined by groups. Invariant
variables are always summarized by group using the unique value that they assume within that group. If FUN is a single function it will be applied to each
non-invariant variable by group to produce the summary for that variable. If
FUN is a list of functions, the names in the list should designate classes of variables in the frame such as ordered, factor, or numeric. The indicated
function will be applied to any non-invariant variables of that class. The default
functions to be used are mean for numeric factors, and Mode for both factor
and ordered. The Mode function, defined internally in gsummary, returns
the modal or most popular value of the variable. It is different from the mode
function that returns the S-language mode of the variable.
omitGroupingFactor
an optional logical value. When TRUE the grouping factor itself will be omitted
from the group-wise summary but the levels of the grouping factor will continue
to be used as the row names for the data frame that is produced by the summary.
Defaults to FALSE.
FUN
form
an optional one-sided formula that defines the groups. When this formula is
given, the right-hand side is evaluated in object, converted to a factor if
necessary, and the unique levels are used to define the groups. Defaults to
formula(object).
level
an optional positive integer giving the level of grouping to be used in an object
with multiple nested grouping levels. Defaults to the highest or innermost level
of grouping.
an optional factor that will be used to split the rows into groups. Defaults to
getGroups(object, form, level).
invariantsOnly
an optional logical value. When TRUE only those covariates that are invariant
within each group will be summarized. The summary value for the group is always the unique value taken on by that covariate within the group. The columns
in the summary are of the same class as the corresponding columns in object.
By definition, the grouping factor itself must be an invariant. When combined
with omitGroupingFactor = TRUE, this option can be used to discover
is there are invariant covariates in the data frame. Defaults to FALSE.
groups
lmList-class
...
3
optional additional arguments to the summary functions that are invoked on the
variables by group. Often it is helpful to specify na.rm = TRUE.
Value
A data.frame with one row for each level of the grouping factor. The number of columns is at
most the number of columns in object.
See Also
summary, groupedData, getGroups
Examples
ChickWeight <- do.call("data.frame", ChickWeight)
class(ChickWeight)
gsummary(ChickWeight, groups = ChickWeight$Chick)
gsummary(ChickWeight, groups = ChickWeight$Chick,
invariantsOnly = TRUE)
lmList-class
Class "lmList"
Description
A list of objects of class lm with a common model.
Objects from the Class
Objects can be created by calls of the form new("lmList", ...).
Slots
.Data: Object of class "list", a list of objects of class lm
call: Object of class "call", the function call used to create the lmList object.
pool: Object of class "logical", if TRUE then calculate the pooled standard deviation estimate
when displaying the object.
Extends
Class "list", from data part. Class "vector", by class "list".
Methods
coef signature(object = "lmList"): extract the coefficients for the linear models.
formula signature(x = "lmList"): extract the formula used when creating the lmList
object.
confint signature(object = "lmList"): confidence intervals for the fitted linear models.
pooledSD signature(object = "lmList"): the pooled standard deviation estimate from
the fitted linear models.
show signature(object = "lmList"): show the object.
update signature(object = "lmList"): update the fit.
4
lmList
lmList
List of lm Objects with a Common Model
Description
Data is partitioned according to the levels of the grouping factor g and individual lm fits are
obtained for each data partition, using the model defined in object.
Usage
lmList(formula, data, family, subset, weights,
na.action, offset, pool, ...)
Arguments
formula
For lmList, 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 grouping factor specifying the partitioning of the data according to which
different lm fits should be performed. The grouping factor g may be omitted
from the formula, in which case the grouping structure will be obtained from
data, which must inherit from class groupedData.
data
a data frame in which to interpret the variables named in object.
family
an optional family specification for a generalized linear model.
weights
an optional vector of weights to be used in the fitting process.
subset
an optional vector specifying a subset of observations to be used in the fitting
process.
na.action
a function which indicates what should happen when the data contain NAs. The
default is set by the na.action setting of options, and is na.fail if that
is unset. The “factory-fresh” default is na.omit.
offset
this can be used to specify an a priori known component to be included in the
linear predictor during fitting.
pool
an optional logical value that is preserved as an attribute of the returned value.
This will be used as the default for pool in calculations of standard deviations
or standard errors for summaries.
...
optional arguments to be passed to the model-fitting function.
Value
an object of class lmList which is a list of lm objects with as many components as the number of
groups defined by the grouping factor.
See Also
lm
Examples
(fm1 <- lmList(breaks ~ wool | tension, warpbreaks))
pooledSD
5
Extract pooled standard deviation
pooledSD
Description
The pooled estimated standard deviation is obtained by adding together the residual sum of squares
for each non-null element of object, dividing by the sum of the corresponding residual degreesof-freedom, and taking the square-root.
Usage
pooledSD(object)
Arguments
object
an object inheriting from class lmList.
Value
the pooled standard deviation for the non-null elements of object, with an attribute df with the
number of degrees-of-freedom used in the estimation.
See Also
lmList, lm
Examples
pooledSD(lmList(weight ~ Time | Chick, do.call("data.frame", ChickWeight)))
Index
∗Topic classes
lmList-class, 3
∗Topic manip
gsummary, 1
∗Topic methods
gsummary, 1
∗Topic models
lmList, 4
pooledSD, 5
show,lmList-method
(lmList-class), 3
summary, 2
update, 3
update,lmList-method
(lmList-class), 3
coef,lmList-method
(lmList-class), 3
confint,lmList-method
(lmList-class), 3
formula,lmList-method
(lmList-class), 3
getGroups, 2
groupedData, 2
gsummary, 1
gsummary,data.frame,ANY,ANY,ANY,factor-method
(gsummary), 1
gsummary-methods (gsummary), 1
lm, 4, 5
lmList, 4, 5
lmList,formula,data.frame-method
(lmList), 4
lmList-class, 3
na.fail, 4
na.omit, 4
options, 4
plot,lmList-method
(lmList-class), 3
plot,lmList.confint-method
(lmList-class), 3
pooledSD, 5
pooledSD,lmList-method
(lmList-class), 3
show, 3
6