This example is a follow-up ANOVA from the One-Way example. I am using some data from an evaluation of my research classes, where I did a pre-test and a post-test of my classes. What I want to do here is to compare the three classes, Tuesday, Saturday, online. Tuesday was a regular face-to-face class, Saturday was a hybrid class, where students watched pre-recorded lecture and came to class to do discussion and online had the same pre-recorded lectures as Saturday, but did their discussion via synchronous video enabled chats. the NULL hypothesis would be that the means of the percent improvement PERCENTIMP variable would be equal between the three groups. Now I want to see if scores on the Pre-test PRE has an effect, considering which class the student is enrolled in.
SW <-read.delim("/Volumes/Mirror Mirror /Google Drive/Research_UMKC/SE4SW.FE/T_Tests/prepost.txt")
in the earlier example we did a simple, aov(PERCENTIMP~Class, data = SW) command to get our ANOVA.
To add-in the effect of the PRE test we simply use the + plus sign, followed by the name of the variable, in this case PRE. We give this object a name that makes it easy to remember what our model is doing av.pct.class.pre. One can quickly see where if one were conducted more than just a couple ANOVA tests that the practice of creating meaningful names can be quite helpful. Using scripting language helps keep things clear. Also, if you do you ANOVA in R Commander, it will assign the model with a unique name, unless you purposely over-ride the default settings.
first create the model object
av.pct.class.pre <- aov(POST~Class+PrePF, data = SW)
then view the model to get the F statistics
av.pct.class.pre
## Call:
## aov(formula = POST ~ Class + PrePF, data = SW)
##
## Terms:
## Class PrePF Residuals
## Sum of Squares 1581.955 1216.332 11123.356
## Deg. of Freedom 2 1 38
##
## Residual standard error: 17.10906
## Estimated effects may be unbalanced
Finally, use the summary function to view the interactions
summary(av.pct.class.pre)
## Df Sum Sq Mean Sq F value Pr(>F)
## Class 2 1582 791.0 2.702 0.0799 .
## PrePF 1 1216 1216.3 4.155 0.0485 *
## Residuals 38 11123 292.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The output above indicates a significant influence on the post-test coming from how well one did on the pre-test. Which of the three sections the person was enrolled in does not have a significant influence on the performance of students on the POST-test.
Were there statistical differences between the three classes, we could have used the TukeyHSD test to find out where the difference is. Had the probability been good in this example, we would be looking the difference between Tuesday and Saturday in the table below.
TukeyHSD(av.pct.class.pre,'Class', ordered = FALSE)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = POST ~ Class + PrePF, data = SW)
##
## $Class
## diff lwr upr p adj
## Saturday-online -4.4375 -21.257796 12.38280 0.7971832
## Tuesday-online 10.4375 -4.314875 25.18988 0.2089702
## Tuesday-Saturday 14.8750 -1.945296 31.69530 0.0919769
by using the plot command on Multi-way ANOVA model we just ran, we get this nice plot that shows us the the over-lap, and by how much.
r plot(TukeyHSD(av.pct.class.pre,'Class', ordered = FALSE) )
final