Description Usage Arguments Details Value Note See Also Examples
View source: R/testsPostHoc-utils.R
Places significance letters next to mean points on an active fitPlot
from a one-way or a two-way ANOVA.
1 2 3 4 5 6 7 8 9 10 11 |
mdl |
A |
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 |
pos |
A value or vector of values indicating the positiong to place the characters relative to each group mean point. Note that |
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 |
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.
None. However, an active graphic is modified.
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.
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.