addSigLetters: Places significance letters next to mean points on a fitPlot.

Description Usage Arguments Details Value Note See Also Examples

View source: R/testsPostHoc-utils.R

Description

Places significance letters next to mean points on an active fitPlot from a one-way or a two-way ANOVA.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
addSigLetters(
  mdl,
  lets,
  which,
  change.order = FALSE,
  pos = rep(2, length(mns)),
  offset = 0.5,
  col = rep(1, length(mns)),
  cex = rep(0, length(mns)),
  ...
)

Arguments

mdl

A lm object or formula depicting an ANOVA

lets

A vector of characters to be placed next to each group mean point

which

A character string listing terms in the fitted model for which the means should be calculated and the letters placed

change.order

A logical that is used to change the order of the factors in the lm object. This is used to change which factor is plotted on the x-axis and which is used to connect means. Used only with a two-way ANOVA and only if the same argument is used with the fitPlot function

pos

A value or vector of values indicating the positiong to place the characters relative to each group mean point. Note that 1=below, 2=left, 3=above, and 4=right

offset

A value indicating a proportion of character widths to move the character away from each group mean point

col

A single or vector of numeric or character representations of colors used for each character

cex

A single or vector of numeric values used to represent the character expansion values

...

Other arguments to be passed to the text function

Details

The graphic of group means must be active for this function to place the characters next to the group mean points. Typically this graphic is made with the fitPlot function.

Value

None. However, an active graphic is modified.

Note

Students are often asked to determine which level means are different if a significant one-way or two-way ANOVA is encountered. The results of these multiple comparisons are often illustrated by placing “significance letters” next to mean points on an interaction of main effects plot. In R this can be accomplished with a number of text calls. This function, however, simplifies this process so that newbie students can create the graphic in an efficient and relatively easy manner (in conjunction with fitPlot). This function thus allows newbie students to interact with and visualize moderately complex linear models in a fairly easy and efficient manner.

See Also

fitPlot.

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
37
38
39
40
41
42
43
if (require(FSA)) {
data(Mirex)
Mirex$year <- factor(Mirex$year)

## one-way ANOVA
lm1 <- lm(mirex~year,data=Mirex)
anova(lm1)
# suppose multiple comparison results from following
## Not run: 
mc1 <- multcomp::glht(lm1,mcp(year="Tukey"))
summary(mc1)

## End(Not run)
fitPlot(lm1,main="")
addSigLetters(lm1,c("a","a","a","a","ab","b"),pos=c(2,2,4,4,4,4))

# same example, but using cld() from multcomp
## Not run: 
( sl1 <- multcomp::cld(mc1) )
fitPlot(lm1,main="")
addSigLetters(lm1,lets=sl1,pos=c(2,2,4,4,4,4))

## End(Not run)

## two-way ANOVA
lm2 <- lm(mirex~year*species,data=Mirex)
anova(lm2)

# suppose multiple comparison results from following
## Not run: 
mc2y <- glht(lm2,mcp(year="Tukey"))
summary(mc2y)
mc2s <- glht(lm2,mcp(species="Tukey"))
summary(mc2s)

## End(Not run)
op <- par(mfcol=c(1,2))
fitPlot(lm2,which="year",type="b",pch=19,ylim=c(0.05,0.35),main="")
addSigLetters(lm2,which="year",c("a","a","a","a","ab","b"),pos=c(2,2,4,4,4,4))
fitPlot(lm2,which="species",type="b",pch=19,ylim=c(0.05,0.35),main="")
addSigLetters(lm2,which="species",c("a","a"),pos=c(2,4))
par(op)
}

droglenc/NCStats documentation built on June 5, 2021, 2:06 p.m.