[R] Command for simple effects following 2 way anova with interaction
Richard M. Heiberger
rmh at temple.edu
Thu Dec 1 06:08:11 CET 2016
## Use the split argument to summary.aov
## This tests the levels of tension within each level of wool using a common
## Residuals sum of squares.
sapply(warpbreaks, levels)
model2 <- aov(breaks ~ wool/tension, data = warpbreaks)
colnames(model.matrix(model2))
## [1] "(Intercept)" "woolB" "woolA:tensionM" "woolB:tensionM"
## [5] "woolA:tensionH" "woolB:tensionH"
sapply(warpbreaks[2:3], levels)
summary(model2,
split=list("wool:tension"=list("woolA/tension"=c(1,3),
"woolB/tension"=c(2,4))))
## The less good choice has the same numerator sums of squares but
## different Residuals sums of squares, with fewer df for each,
## and comes to different conclusions.
model3A <- aov(breaks ~ tension,
data = warpbreaks[warpbreaks$wool=="A",])
summary(model3A)
model3B <- aov(breaks ~ tension,
data = warpbreaks[warpbreaks$wool=="B",])
summary(model3B)
## The boxplots show that model2 better describes the data.
## There is a significant difference for woolA and not for woolB.
library(lattice)
bwplot(breaks ~ tension | wool, data=warpbreaks)
On Wed, Nov 30, 2016 at 10:55 PM, Ashim Kapoor <ashimkapoor at gmail.com> wrote:
> Dear All,
>
> Suppose I do :-
>
> head(warpbreaks)
> model1<- aov(breaks ~ wool*tension,data = warpbreaks)
> summary(model1)
>
> There is significant interaction. So I need to test for simple effects of
> wool at each level of tension and vice versa. I can do a subset and then
> do a one way anova for each level of tension and wool. My query is that is
> there any command programmed which can do this automatically?
>
> Best Regards,
> Ashim
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list