These data are the results of a human factors study of errors in turning on stovetop burners. The factors were the shape and calibration of the control dials for the burners. The dependent variable was the number of errors over trials. The calibration had two levels, and was conceived as a between participants factor (each participant saw calibration 1 or 2, suppose ‘off’ is at the top or the bottom of the dial). There were four levels of dial shape (suppose these were round, oval, triangle and diamond). The shape factor was within, so that each participant had multiple trials with each of the shapes. Shapes were ordered randomly.
Data are taken from Winer, B. J. (1971). Statistical principles in experimental design (2nd ed). New York: McGraw Hill. (p. 525).
Again, we will use the ezANOVA package to analyze these data.
library(ez)
As usual, I would read the data from a .csv file, but input it here for instruction.
error <- c(0, 0, 5, 3, 3, 1, 5, 4, 4, 3, 6, 2, 4, 2, 7, 8, 5, 4, 6, 6, 7, 5, 8, 9)
subnum <- c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6)
calib <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
shape <- c(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)
stovetop <- data.frame(error, subnum, calib, shape)
stovetop
## error subnum calib shape
## 1 0 1 1 1
## 2 0 1 1 2
## 3 5 1 1 3
## 4 3 1 1 4
## 5 3 2 1 1
## 6 1 2 1 2
## 7 5 2 1 3
## 8 4 2 1 4
## 9 4 3 1 1
## 10 3 3 1 2
## 11 6 3 1 3
## 12 2 3 1 4
## 13 4 4 2 1
## 14 2 4 2 2
## 15 7 4 2 3
## 16 8 4 2 4
## 17 5 5 2 1
## 18 4 5 2 2
## 19 6 5 2 3
## 20 6 5 2 4
## 21 7 6 2 1
## 22 5 6 2 2
## 23 8 6 2 3
## 24 9 6 2 4
Note that again we have the long format, where each participant is represented as multiple rows. Each participant saw all four dial shapes (but only one calibration), so there are 4 rows per person. There are only six people in the design, but each provides 4 pieces of data, or 24 total observations.
stovetop$subnum <- as.factor(stovetop$subnum) # recode integer to factor
stovetop$calib <- as.factor(stovetop$calib) # again
stovetop$shape <- as.factor(stovetop$shape) # and again
two_way <-ezANOVA(data=stovetop,
dv = error, # Dependent variable.
wid=subnum, # within subject ID
within=shape, # repeated IV; renamed group variable as a factor.
between=calib, # independent group IV
detailed = T) # a little extra printout
print(two_way) # ges = Generalized Effect Size; see help file for reference
## $ANOVA
## Effect DFn DFd SSn SSd F p p<.05
## 1 (Intercept) 1 4 477.041667 17.16667 111.155340 0.0004578067 *
## 2 calib 1 4 51.041667 17.16667 11.893204 0.0260865571 *
## 3 shape 3 12 47.458333 14.83333 12.797753 0.0004769384 *
## 4 calib:shape 3 12 7.458333 14.83333 2.011236 0.1661707448
## ges
## 1 0.9371368
## 2 0.6146513
## 3 0.5972732
## 4 0.1890180
##
## $`Mauchly's Test for Sphericity`
## Effect W p p<.05
## 3 shape 0.1029492 0.3157349
## 4 calib:shape 0.1029492 0.3157349
##
## $`Sphericity Corrections`
## Effect GGe p[GG] p[GG]<.05 HFe p[HF]
## 3 shape 0.4751365 0.009892981 * 0.6638009 0.003269332
## 4 calib:shape 0.4751365 0.215220568 0.6638009 0.196336894
## p[HF]<.05
## 3 *
## 4
Note how the different factors have different degrees of freedom. Calibration is between and there are 2 levels. Because there are only 6 people we have 1 df in the numerator and 4 in the denominator.
Both shape and the calibration by shape terms are considered within. There are 4 different shapes and six people. For shape there are 18 df total (6 people by (k-1)=3 shapes), so there are 3 df for shape, 3 for the interaction of shape and dial (1 df by 3 df), which leaves 18 - 6 = 12 df for the residual, error term. Both the shape and shape by calibration terms are tested against the same error.
To visualized the results, we can create a graph:
boxplot(stovetop$error~stovetop$shape*stovetop$calib, main='Stovetop Burner Errors', xlab = 'Shape.Calibration', ylab = 'Number of Errors', col=c('Yellow', 'Yellow', 'Yellow', 'Yellow', 'Green', 'Green', 'Green', 'Green'))