Computes LS-means or pairwise differences of LS-mean for all factors in a
linear mixed model. lsmeansLT
is provided as an alias for
ls_means
for backward compatibility.
# S3 method for lmerModLmerTest
ls_means(
model,
which = NULL,
level = 0.95,
ddf = c("Satterthwaite", "Kenward-Roger"),
pairwise = FALSE,
...
)# S3 method for lmerModLmerTest
lsmeansLT(
model,
which = NULL,
level = 0.95,
ddf = c("Satterthwaite", "Kenward-Roger"),
pairwise = FALSE,
...
)
# S3 method for lmerModLmerTest
difflsmeans(
model,
which = NULL,
level = 0.95,
ddf = c("Satterthwaite", "Kenward-Roger"),
...
)
a model object fitted with lmer
(of class
"lmerModLmerTest"
).
optional character vector naming factors for which LS-means should
be computed. If NULL
(default) LS-means for all factors are computed.
confidence level.
method for computation of denominator degrees of freedom.
compute pairwise differences of LS-means instead?
currently not used.
An LS-means table in the form of a data.frame
. Formally an object
of class c("ls_means", "data.frame")
with a number of attributes set.
Confidence intervals and p-values are based on the t-distribution using degrees of freedom based on Satterthwaites or Kenward-Roger methods.
LS-means is SAS terminology for predicted/estimated marginal means, i.e. means for levels of factors which are averaged over the levels of other factors in the model. A flat (i.e. unweighted) average is taken which gives equal weight to all levels of each of the other factors. Numeric/continuous variables are set at their mean values. See emmeans package for more options and greater flexibility.
LS-means contrasts are checked for estimability and unestimable contrasts appear
as NA
s in the resulting table.
LS-means objects (of class "ls_means"
have a print method).
show_tests
for display of the
underlying LS-means contrasts.
# NOT RUN {
# Get data and fit model:
data("cake", package="lme4")
model <- lmer(angle ~ recipe * temp + (1|recipe:replicate), cake)
# Compute LS-means:
ls_means(model)
# Get LS-means contrasts:
show_tests(ls_means(model))
# Compute pairwise differences of LS-means for each factor:
ls_means(model, pairwise=TRUE)
difflsmeans(model) # Equivalent.
# }
Run the code above in your browser using DataLab