Learn R Programming

VCA (version 1.2.1)

lsmeans: Least Squares Means of Fixed Effects.

Description

Computes Least Squares Means (LS Means) of fixed effects for fitted mixed models of class 'VCA'.

Usage

lsmeans(obj, var = NULL, type = c("simple", "complex"),
  ddfm = c("contain", "residual", "satterthwaite"), quiet = FALSE)

Arguments

obj
(VCA) object having at least one fixed effect
var
(character) string specifying a fixed effects variable for which LS Means should be computed, defaults to all fixed effects, i.e. for each level of a fixed effects variable ls means will be computed
type
(character) "simple" = fast version of computing LS means
ddfm
(character) string specifying the method used for computing the degrees of freedom of the t-statistic. Only used when type="complex". Available methods are "contain", "residual", and "satterthwaite".
quiet
(logical) TRUE = suppress warning messages, e.g. for non-estimable contrasts

Value

  • (matrix) with LS Means of fixed effects and respective standard errors, in case of 'type="complex"'

Details

Function computes LS Means of fixed effects and their corresponding standard errors. In case of setting argument 'type' equal to "complex" (or any abbreviation) a $t$-test is performed on each LS Mean, returning degrees of freedom, t-statistic and corresponding p-values. One can choose from one of three denominator degrees of freedom ('ddfm')-methods. Actually, function test.fixef is called with the "no intercept" version of the fitted model. The "complex" option is significantly slower for unbalanced designs (see test.fixef for details). In case that the 'VarCov' element of the 'VCA' object already exists (calling vcovVC), which is the most time consuming part, results can be obtained in less amount of time. Standard Errors of LS Means are computed as $TPT^{T}$, where $T$ is the LS Means generating contrast matrix and $P$ is the variance-covariance matrix of fixed effects.

Examples

Run this code
#
data(dataEP05A2_2)
fit1 <- anovaMM(y~day/(run), dataEP05A2_2)
lsmeans(fit1)
lsmeans(fit1,, "complex")

# a more complex model
data(VCAdata1)
fit2 <- anovaMM(y~(lot+device)/(day)/(run), VCAdata1[VCAdata1$sample==2,])
lsmeans(fit2, "lot")
lsmeans(fit2, "device", "complex")

# pre-computed 'VarCov' element saves time
system.time(lsm1 <- lsmeans(fit2, "device", "complex"))
fit2$VarCov <- vcovVC(fit2)
system.time(lsm2 <- lsmeans(fit2, "device", "complex"))
lsm1
lsm2

Run the code above in your browser using DataLab