cld2: Modified Compact Letter Display to Irregular Designs

Description Usage Arguments Value Author(s) See Also Examples

View source: R/pairwise.R

Description

This functions get the compact letter display for objects of class "glht". Modification was done to get the letters to design with missing cells, non completelly crossed factorial designs and nested factorial designs. These models are usually declared by a model matrix to have all effects estimated. It is assumed that Tukey contrasts was used.

Usage

1
cld2(object, level = 0.05)

Arguments

object

an object returned by glht(). It is assumed that the matrix used as the linfct argument in glht corresponds to a matrix to get Tukey contrasts of least squares means.

level

the nominal significance level.

Value

an object of class "cld" with letters to resume mean comparisons.

Author(s)

Walmes Zeviani, walmes@ufpr.r.

See Also

apc(), LE_matrix(), glht().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Toy data 1: experiment with cultivars in several locations.
td1 <- expand.grid(loc = gl(5, 1),
                   block = gl(3, 1),
                   cult = LETTERS[1:6])
td1 <- subset(td1, !(loc == 1 & cult == "A"))
td1 <- subset(td1, !(loc == 2 & cult == "B"))
xtabs(~loc + cult, td1)
td1$y <- seq_len(nrow(td1))

library(lme4)

# Fit the mixed model.
m0 <- lmer(y ~ loc * cult + (1 | loc:block), data = td1)
logLik(m0)

# The same model but without rank deficience.
td1$loccult <- with(td1, interaction(loc, cult, drop = TRUE))
m1 <- lmer(y ~ loccult + (1 | loc:block), data = td1)
logLik(m1)

library(doBy)

X <- LE_matrix(lm(nobars(formula(m1)), data = td1), effect = "loccult")
rownames(X) <- levels(td1$loccult)
dim(X)

Xs <- X[grepl(x = rownames(X), "^1\\."),]
Xc <- apc(Xs)

library(multcomp)

g <- summary(glht(m1, linfct = Xc), test = adjusted(type = "fdr"))

cld2(g)

confint(glht(m1, linfct = Xs), calpha = univariate_calpha())

walmes/wzRfun documentation built on Aug. 10, 2021, 2:19 p.m.