[R] Sum of Squares Type I, II, III for ANOVA

Thanh Tran m@@ternh@ttt @ending from gm@il@com
Wed Nov 7 00:58:23 CET 2018


Hi everyone,
I'm studying the ANOVA in R and have some questions to share. I investigate
the effects of 4 factors (temperature-3 levels, asphalt content-3 levels,
air voids-2 levels, and sample thickness-3 levels) on the hardness of
asphalt concrete in the tensile test (abbreviated as KIC). These data were
taken from a acticle paper. The codes were wrriten as the follows:

> data = read.csv("Saha research.csv", header =T)
> attach(data)
> tem = as.factor(temperature)
> ac= as.factor (AC)
> av = as.factor(AV)
> thick = as.factor(Thickness)
> model =
lm(KIC~tem+ac+av+thick+tem:ac+tem:av+tem:thick+ac:av+ac:thick+av:thick)
> anova(model) #Type I tests
> library(car) Loading required package: carData >
anova(lm(KIC~tem+ac+av+thick+tem:ac+tem:av+tem:thick+ac:av+ac:thick+av:thick),type=2)
Error: $ operator is invalid for atomic vectors
> options(contrasts = c("contr.sum", "contr.poly"))
> Anova(model,type="3") # Type III tests
> Anova(model,type="2") # Type II tests

With R, three results from Type I, II, and III almost have the same as
follows.

Analysis of Variance Table Response: KIC Df Sum Sq Mean Sq F value Pr(>F)
tem 2 15.3917 7.6958 427.9926 < 2.2e-16 *** ac 2 0.1709 0.0854 4.7510
0.0096967 ** av 1 1.9097 1.9097 106.2055 < 2.2e-16 *** thick 2 0.2041
0.1021 5.6756 0.0040359 ** tem:ac 4 0.5653 0.1413 7.8598 6.973e-06 ***
tem:av 2 1.7192 0.8596 47.8046 < 2.2e-16 *** tem:thick 4 0.0728 0.0182
1.0120 0.4024210 ac:av 2 0.3175 0.1588 8.8297 0.0002154 *** ac:thick 4
0.0883 0.0221 1.2280 0.3003570 av:thick 2 0.0662 0.0331 1.8421 0.1613058
Residuals 190 3.4164 0.0180 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’
0.05 ‘.’ 0.1 ‘ ’ 1

However, these results are different from the results in the article,
especially for the interaction (air voids and sample thickness). The
results presented in the article are as follows:
Analysis of variance for KIC, using Adjusted SS for tests. Source DF Seq SS
Adj MS F-stat P-value Model findings Temperature 2 15.39355 7.69677 426.68
<0.01 Significant AC 2 0.95784 0.47892 26.55 <0.01 Significant AV 1 0.57035
0.57035 31.62 <0.01 Significant Thickness 2 0.20269 0.10135 5.62 <0.01
Significant Temperature⁄AC 4 1.37762 0.34441 19.09 <0.01 Significant
Temperature⁄AV 2 0.8329 0.41645 23.09 <0.01 Significant
Temperature⁄thickness 4 0.07135 0.01784 0.99 0.415 Not significant AC⁄AV 2
0.86557 0.43279 23.99 <0.01 Significant AC⁄thickness 4 0.04337 0.01084 0.6
0.662 Not significant AV⁄thickness 2 0.17394 0.08697 4.82 <0.01 Significant
Error 190 3.42734 0.01804 Total 215 23.91653

Therefore, I wonder that whether there is an error in my code or there is
another type of ANOVA in R. If you could answer my problems, I would be
most grateful.
Best regards,
Nhat Tran
Ps: I also added a CSV file and the paper for practicing R.


More information about the R-help mailing list