gender
1 144.550 144.550 64.041 1.16e-07 ***
Residuals 20 45.143 2.257
--Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
# Model I ANOVA for just the factor interactions:
anova( lm(lintmass ~ species:gender) )
Analysis of Variance Table
Response: lintmass
Df Sum Sq Mean Sq F value
Pr(>F)
species:gender 5 197.622 39.524 18.026 1.898e-06 ***
Residuals
18 39.468 2.193
--Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
# Model II and Model III (mixed random and fixed effects models) are
# handled differently, using the `nlme' package:
library(nlme)
# load the extra package
ldata<-data.frame(lintmass,species,gender)
# make an ape lint database
# Model II (random effects) with species choice first
ldata1<-groupedData( lintmass ~ 1 | species/gender, data=ldata)
anova(lme(ldata1))
lme(ldata1)
Linear mixed-effects model fit by REML
Data: ldata1
Log-restricted-likelihood: -50.48286
Fixed: lintmass ~ 1
(Intercept)
16.22917
Random effects:
Formula: ~1 | species
(Intercept)
StdDev: 0.0002757162
Formula: ~1 | gender %in% species
(Intercept) Residual
StdDev:
3.054987 1.480756
Number of Observations: 24
Number of Groups:
species gender %in% species
3
Data: ldata2
Log-restricted-likelihood: -48.94808
Fixed: lintmass ~ 1
(Intercept)
16.22917
Random effects:
Formula: ~1 | gender
(Intercept)
StdDev:
3.307584
Formula: ~1 | species %in% gender
(Intercept) Residual
StdDev:
1.663978 1.480756
Number of Observations: 24
Number of Groups:
gender species %in% gender
2
6
anova(lme(ldata2))
numDF denDF F-value p-value
(Intercept)
1
18 43.73083 <.0001
Residuals
15 1.7917 0.1194
--Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
>
Ride 1
-----0
0
0
0
0
0
1
1
1
0
1
1
1
1
0
1
1
1
# defines cochranQ()
"cochran.R" into the R session.
DF = 5
DF = 3
p = 0.3400161
p = 0.1290031
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
>
>
>
>
>
Three-Factor ANOVA:
Read the data using scan():
a1
------------b1 b2 b3
--- --- ---
a2
------------b1 b2 b3
--- --- ---
a3
------------b1 b2 b3
--- --- ---
a4
------------b1 b2 b3
--- --- ---
4.1
4.3
4.5
3.8
4.3
4.6
4.9
4.2
4.5
4.8
3.7
3.9
4.1
4.5
3.9
4.9
4.6
5.3
5.0
4.6
5.2
5.6
5.8
5.4
5.5
4.7
4.7
5.0
4.5
4.7
5.0
5.4
5.7
5.3
5.4
6.1
6.2
6.5
5.7
6.1
5.5
5.9
5.6
5.0
5.9
3.9
3.3
3.4
3.7
3.3
4.4
4.3
4.7
4.1
4.2
3.7
3.9
4.0
4.4
3.9
4.8
4.5
5.0
4.6
5.0
5.6
5.8
5.4
6.1
5.4
5.0
5.2
4.6
4.9
4.7
4.9
5.5
5.5
5.3
5.5
5.9
5.3
5.5
5.7
5.5
5.0
5.4
4.7
5.1
4.9
6.0
5.7
5.5
5.7
5.5
6.0
6.3
5.7
5.9
5.7
6.1
5.3
5.5
5.8
5.6
4.1
3.9
4.3
4.0
4.3
4.9
4.7
4.9
5.3
4.3
4.3
4.1
3.8
4.7
3.8
c1:
c2:
NOTE: Cut and paste the numbers without the leading # or labels
Y <- scan()
A <- gl(4,3, 4*3*2*5, labels=c("a1","a2","a3","a4"));
B <- gl(3,1, 4*3*2*5, labels=c("b1","b2","b3"));
C <- gl(2,60, 4*3*2*5, labels=c("c1","c2"));
anova(lm(Y~A*B*C)) # all effects and interactions
Analysis of Variance Table
Response: Y
Df Sum Sq Mean Sq F value
Pr(>F)
A
3 40.322 13.441 182.4506 < 2.2e-16 ***
B
2 8.821 4.411 59.8722 < 2.2e-16 ***
C
1 4.760 4.760 64.6165 2.356e-12 ***
A:B
6 0.814 0.136 1.8420 0.09895 .
A:C
3 2.351 0.784 10.6376 4.216e-06 ***
B:C
2 0.126 0.063 0.8563 0.42793
A:B:C
6 0.944 0.157 2.1354 0.05616 .
Residuals 96 7.072 0.074
--Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1