|
| |
Balanced Incomplete Block Design
Tire Experiment (p59-)
First let's enter data:
> wear<-c(238,196,254,238,213,312,279,308,334,421,367,312)
> Tire<-as.factor(c(1,2,3,1,2,4,1,2,3,4,3,4))
> Compound<-LETTERS[rep(c(1,2,3,4),c(3,3,4,2))]
Let's fit model:
> options(contrasts = c("contr.treatment",
"contr.poly"))
> fit<-lm(wear~Tire+Compound)
> model.matrix(fit)
(Intercept) Tire2 Tire3 Tire4
CompoundB CompoundC CompoundD
1
1 0 0
0 0
0 0
2
1 1 0
0 0
0 0
3
1 0 1
0 0
0 0
4
1 0 0
0 1
0 0
5
1 1 0
0 1
0 0
6
1 0 0
1 1
0 0
7
1 0 0
0 0
1 0
8
1 1 0
0 0
1 0
9
1 0 1
0 0
1 0
10
1 0 0
1 0
1 0
11
1 0 1
0 0
0 1
12
1 0 0
1 0
0 1
> summary(fit,cor=F)
Call: lm(formula = wear ~ Tire + Compound)
Residuals:
1
2 3 4
5 6 7
8 9 10
11 12
22.03 -7.301 -14.73 5.158 -7.176 2.018
-27.19 14.48 -24.96 37.67 39.69 -39.69
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 215.9673 28.1677
7.6672 0.0006
Tire2
-12.6667 30.5042 -0.4152
0.6952
Tire3
52.7649 33.0532 1.5964
0.1713
Tire4
77.1399 33.0532 2.3338
0.0669
CompoundB 16.8750
32.3546 0.5216 0.6242
CompoundC 90.2232
29.3238 3.0768 0.0276
CompoundD 58.5804
38.1847 1.5341 0.1856
Residual standard error: 37.36 on 5 degrees
of freedom
Multiple R-Squared: 0.8543
F-statistic: 4.887 on 6 and 5 degrees of
freedom, the p-value is 0.05127
> anova(fit)
Analysis of Variance Table
Response: wear
Terms added sequentially (first to last)
Df Sum of Sq Mean Sq F Value
Pr(F)
Tire
3 24822.67 8274.222 5.928122 0.04218687
Compound 3 16101.21 5367.070
3.845274 0.09061428
Residuals 5 6978.79 1395.758
What about interusction:
> fit<-lm(wear~Tire*Compound)
Error in lm.fit.qr(x, y): computed fit is
singular, rank 12
Dumped
> fit<-aov(wear~Tire*Compound)
> summary(fit)
Df Sum of Sq Mean Sq
Tire
3 24822.67 8274.222
Compound
3 16101.21 5367.070
Tire:Compound 5 6978.79
1395.758
|