[R] Crossed factorial design with 2 random factors
Hans Ole Ørka
hans-ole.orka at umb.no
Thu Nov 29 11:45:38 CET 2007
Hello, I have a balanced factorial crossed design with 2 random factors; boars and farms, the response are number of piglets (2 replicates). In Minitab I analyze the experiment with ANOVA->GLM where both factors and the interaction are included. In addition I get the expexded mean squares and the variance components printed out (For Minitab output see bellow).
I have not yet figured out how to get the same results from R. I have tried both aov and lme, but I can figure out how to reproduce the result output from Minitab in a right manner. All help are appreciated. The data is:
#Data for R
Boar<-factor(c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10),rep(6,10)))
Farm<-factor(c(rep(seq(1,5,1),12)))
Replicates<-factor(rep(c(rep(1,5),rep(2,5)),6))
Piglets<-c(8,8,6,8,7,7,6,6,8,9,8,7,7,9,9,8,8,9,8,8,8,8,9,9,11,9,
9,9,9,9,8,9,10,11,11,9,8,10,11,10,9,8,9,12,13,8,9,10,10,13,9,10,12,13,12,8,9,11,12,12)
The minitab output:
General Linear Model: Piglets versus Boar; Farm
Factor Type Levels Values
Boar random 6 1; 2; 3; 4; 5; 6
Farm random 5 1; 2; 3; 4; 5
Analysis of Variance for Piglets, using Adjusted SS for Tests
Source DF Seq SS Adj SS Adj MS F P
Boar 5 84.7333 84.7333 16.9467 11.92 0.000
Farm 4 45.1667 45.1667 11.2917 7.94 0.001
Boar*Farm 20 28.4333 28.4333 1.4217 2.37 0.016
Error 30 18.0000 18.0000 0.6000
Total 59 176.3333
S = 0.774597 R-Sq = 89.79% R-Sq(adj) = 79.92%
Expected Mean Squares, using Adjusted SS
Source Expected Mean Square for Each Term
1 Boar (4) + 2.0000 (3) + 10.0000 (1)
2 Farm (4) + 2.0000 (3) + 12.0000 (2)
3 Boar*Farm (4) + 2.0000 (3)
4 Error (4)
Error Terms for Tests, using Adjusted SS
Synthesis
Source Error DF Error MS of Error MS
1 Boar 20.00 1.4217 (3)
2 Farm 20.00 1.4217 (3)
3 Boar*Farm 30.00 0.6000 (4)
Variance Components, using Adjusted SS
Estimated
Source Value
Boar 1.5525
Farm 0.8225
Boar*Farm 0.4108
Error 0.6000
Thanks
Hans Ole Oerka
More information about the R-help
mailing list