Title: | Least-Squares Means |
---|---|
Description: | Obtain least-squares means for linear, generalized linear, and mixed models. Compute contrasts or linear functions of least-squares means, and comparisons of slopes. Plots and compact letter displays. Least-squares means were proposed in Harvey, W (1960) "Least-squares analysis of data with unequal subclass numbers", Tech Report ARS-20-8, USDA National Agricultural Library, and discussed further in Searle, Speed, and Milliken (1980) "Population marginal means in the linear model: An alternative to least squares means", The American Statistician 34(4), 216-221 <doi:10.1080/00031305.1980.10483031>. NOTE: lsmeans now relies primarily on code in the 'emmeans' package. 'lsmeans' will be archived in the near future. |
Authors: | Russell Lenth [aut, cre, cph] |
Maintainer: | Russell Lenth <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 2.30-1 |
Built: | 2024-11-26 02:50:18 UTC |
Source: | https://github.com/rvlenth/lsmeans |
This package provides methods for obtaining so-called least-squares means for factor combinations in a variety of fitted linear models. It can also compute contrasts or linear combinations of these least-squares means, (several standard contrast families are provided), and in addition can estimate and contrast slopes of trend lines. Popular adjustments for multiple-comparisons are provided, as well as graphical ways of displaying the results.
Almost the entire codebase for lsmeans now resides in the emmeans package (named for the more general term, “estimated marginal means”). lsmeans exists only as a transitional entity for the few remaining packages that depend on it.
Russell V. Lenth (author), Maxime Hervé (contributor)
Maintainer: Russ Lenth <[email protected]>
Russell V. Lenth (2016) Least-Squares Means: The R Package lsmeans. Journal of Statistical Software, 69(1), 1-33. doi:10.18637/jss.v069.i01
Searle S.R. Speed F.M. Milliken G.A. (1980) Population marginal means in the linear model: An alternative to least squares means. The American Statistician 34(4), 216-221.
The datasets ‘auto.noise’, ‘feedlot’, ‘fiber’, ‘MOats’, ‘nutrition’, and ‘oranges’ are provided in case a user customarily loads the data from lsmeans. But the same datasets are provided in the emmeans package, and they are documented there.
auto.noise
auto.noise
Russell V. Lenth
These functions are provided in lsmeans because they have been renamed in emmeans
ref.grid(object, ...) recover.data(object, ...) lsm.basis(object, ...)
ref.grid(object, ...) recover.data(object, ...) lsm.basis(object, ...)
object |
A model object in a supported class. |
... |
Additional arguments passed to companion functions in the emmeans package. |
lsmeans now passes all its computations to emmeans, and the return values
are thus what is returned by the corresponding functions ref_grid
, recover_data
, and emm_basis
, respectively.
Russell V. Lenth
fiber.lm <- lm(strength ~ machine + diameter, data = fiber) rg <- ref.grid(fiber.lm, at = list(diameter = c(20, 24, 28))) rg # Note this is an emmGrid object defined in emmeans. The old "ref.grid" # class is now an extension of this: r.g. <- new("ref.grid", rg) lsmeans(r.g., "machine")
fiber.lm <- lm(strength ~ machine + diameter, data = fiber) rg <- ref.grid(fiber.lm, at = list(diameter = c(20, 24, 28))) rg # Note this is an emmGrid object defined in emmeans. The old "ref.grid" # class is now an extension of this: r.g. <- new("ref.grid", rg) lsmeans(r.g., "machine")
ref.grid
and lsmobj
classesThe codebase for lsmeans is now mostly in emmeans. These two classes
are simple extensions of the emmGrid
class defined in emmeans,
and are provided as support for objects created in older versions of lsmeans.
For details, see emmGrid-class
.
Russell V. Lenth
The lsmeans package is being deprecated and further development will take place in its successor, emmeans. Users may use emmeans in almost exactly the same way as lsmeans, but a few function names and internal details are changed.
In transitioning to emmeans, users will find that the vignettes are constructed quite differently and that, in those and in the documentation, emphasis is placed on “estimated marginal means” rather than “least-squares means”. The term “estimated marginal means” is broader and more appropriate for use with some models, e.g. ordinal regression, that don't really involve least-squares methods. That is the reason for the change.
Accordingly, emmeans users are encouraged to use the functions emmeans()
,
emtrends()
, emmip()
, etc. in lieu of lsmeans()
, etc.
The latter functions are still available in emmeans; they run
the corresponding emmxxxx
function and relabel the results.
The emmeans package provides some functions that help convert scripts and R Markdown
files containing lsmeans code so they will work in emmeans.
There is also a function to convert ref.grid
and lsmobj
objects
to the emmGrid
objects used in emmeans.
More extensive information is given in
vignette("transition-from-lsmeans", package = "emmeans")
.
Russell V. Lenth