[R] Correct contrast for unreplicated 2K factorial design

kjetil brinchmann halvorsen kjetil at entelnet.bo
Fri Jun 27 18:57:40 CEST 2003


On 27 Jun 2003 at 0:38, Peter Ho wrote:

> Hi all,
> 
> I have been trying to reproduce an analysis from Douglas Montgomery´s 
> book on design and analysis of experiments. 

If you are learning design of experiments, there are better books 
around. Montgomery's sems very populat, though. Anybody knows why?


Table 6.10 of example 6.2 on 
> page 246, gives a table as follows:

I cannot find this example in my spanish translation, but try anyhow.

> 
>  > NPK <- expand.grid(A=mp,B=mp,C=mp,D=mp)
>  > Rate <- c(45,71,48,65,68,60,80,65,43,100,45,104,75,86,70,96)
>  > filtration <- cbind(NPK,Rate)
>  > filtration
>    A B C D Rate
> 1  - - - -   45
> 2  + - - -   71
> 3  - + - -   48
> 4  + + - -   65
> 5  - - + -   68
> 6  + - + -   60
> 7  - + + -   80
> 8  + + + -   65
> 9  - - - +   43
> 10 + - - +  100
> 11 - + - +   45
> 12 + + - +  104
> 13 - - + +   75
> 14 + - + +   86
> 15 - + + +   70
> 16 + + + +   96
> 

To get something close to the usual hand-calculation results, you 
want 

> options(contrasts=c("contr.sum", "contr.poly"))
> options("contrasts")
$contrasts
[1] "contr.sum"  "contr.poly"

> filt.mod1 <- aov( Rate ~ A*B*C*D, data=filtration)
> summary(filt.mod1)
            Df  Sum Sq Mean Sq
A            1 1870.56 1870.56
B            1   39.06   39.06
C            1  390.06  390.06
D            1  855.56  855.56
A:B          1    0.06    0.06
A:C          1 1314.06 1314.06
B:C          1   22.56   22.56
A:D          1 1105.56 1105.56
B:D          1    0.56    0.56
C:D          1    5.06    5.06
A:B:C        1   14.06   14.06
A:B:D        1   68.06   68.06
A:C:D        1   10.56   10.56
B:C:D        1   27.56   27.56
A:B:C:D      1    7.56    7.56

> summary.lm(filt.mod1)

Call:
aov(formula = Rate ~ A * B * C * D, data = filtration)

Residuals:
ALL 16 residuals are 0: no residual degrees of freedom!

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  70.0625                            
A            10.8125                            
B             1.5625                            
C             4.9375                            
D             7.3125                            
A:B           0.0625                            
A:C          -9.0625                            
B:C           1.1875                            
A:D           8.3125                            
B:D          -0.1875                            
C:D          -0.5625                            
A:B:C         0.9375                            
A:B:D         2.0625                            
A:C:D        -0.8125                            
B:C:D        -1.3125                            
A:B:C:D       0.6875                            

Residual standard error: NaN on 0 degrees of freedom
Multiple R-Squared:     1,      Adjusted R-squared:   NaN 
F-statistic:   NaN on 15 and 0 DF,  p-value: NA 


(You did'nt specify a model, so I took a saturated model). Note that 
the traditional estimates gives the change in expectation from "low (-
1)" to high (+1)", while R gives the usual least-squares estimates ---
change in expectation by one unit change in predictor. So maybe you 
must multiply the coefficienta above with 2 to get Montgomery's 
results.

Kjetil Halvorsen

> Two additional tables follow. Table 6-11 for contracts constants and 
> Table 6-12 for Factor effects estimates.
> So far my attempts at fitting the model gives me very different effect 
> estimates. This I guess  is because I have not set the right contrasts?
> Can anyone explain to me how I could set the correct contrasts in R to 
> estimate the effects in this unreplicated 2^4 factorial?
> 
> Thanks in advance,
> 
> 
> Peter
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list