addSigLetters {NCStats}R Documentation

Places significance letters next to mean points on a fitPlot.

Description

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

Usage

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

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)
}


[Package NCStats version 0.4.7 Index]