Learn R Programming

doBy (version 4.5-10)

LSmeans: Compute linear estimates

Description

Compute linear estimates for a range of models. One example of linear estimates is population means (also known as LSMEANS).

Usage

LSmeans(object, effect = NULL, at = NULL, level=0.95,      ...)

Arguments

object
Model object
effect
A vector of variables. For each configuration of these the estimate will be calculated.
at
A list of values of covariates (including levels of some factors) to be used in the calculations
level
The level of the (asymptotic) confidence interval.
...
Additional arguments; currently not used.

Value

  • A dataframe with results from computing the contrasts.

See Also

LSmatrix linest

Examples

Run this code
## Make balanced dataset
dat.bal <- expand.grid(list(AA=factor(1:2), BB=factor(1:3), CC=factor(1:3)))
dat.bal$y <- rnorm(nrow(dat.bal))

## Make unbalanced dataset
#   'BB' is nested within 'CC' so BB=1 is only found when CC=1
#   and BB=2,3 are found in each CC=2,3,4
dat.nst <- dat.bal
dat.nst$CC <-factor(c(1,1,2,2,2,2,1,1,3,3,3,3,1,1,4,4,4,4))

mod.bal  <- lm(y ~ AA + BB*CC,    data=dat.bal)
mod.nst  <- lm(y ~ AA + BB : CC, data=dat.nst)

LSmeans(mod.bal, effect=c("BB", "CC"))
LSmeans(mod.nst, effect=c("BB", "CC"))

LSmeans(mod.nst, at=list(BB=1, CC=1))

LSmeans(mod.nst, at=list(BB=1, CC=2))
## Above: NA's are correct; not an estimable function


if( require( lme4 )){
warp.mm <- lmer(breaks ~ -1 + tension + (1|wool), data=warpbreaks)
class(warp.mm)
fixef(warp.mm)
coef(summary(warp.mm))
vcov(warp.mm)
if (require(pbkrtest ))
vcovAdj(warp.mm)
}

Run the code above in your browser using DataLab