This is a solved problem from the text book titled “Statistics for Business and Economics” by Anderson and Sweeny
#Andersen Sweeny Problem
df2 = read.table("ATC_Stress_Test.txt", header=TRUE); df2
## System_A System_B System_C
## 1 15 15 18
## 2 14 14 14
## 3 10 11 15
## 4 13 12 17
## 5 16 13 16
## 6 13 13 13
r = c(t(as.matrix(df2))) # response data
r
## [1] 15 15 18 14 14 14 10 11 15 13 12 17 16 13 16 13 13 13
f = c("System_A", "System_B", "System_C") # treatment levels
k = 3 # number of treatment levels
n = 6 # number of control blocks
tm = gl(k, 1, n*k, factor(f)) # matching treatment
tm
## [1] System_A System_B System_C System_A System_B System_C System_A System_B
## [9] System_C System_A System_B System_C System_A System_B System_C System_A
## [17] System_B System_C
## Levels: System_A System_B System_C
blk = gl(n, k, k*n) # blocking factor
blk
## [1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6
## Levels: 1 2 3 4 5 6
av = aov(r ~ tm + blk)
summary(av)
## Df Sum Sq Mean Sq F value Pr(>F)
## tm 2 21 10.5 5.526 0.0242 *
## blk 5 30 6.0 3.158 0.0574 .
## Residuals 10 19 1.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1