Skip to content
Prev 138975 / 398506 Next

Finding Interaction and main effects contrasts for two-wayANOVA

Thanks to those who have replied to my original query.  However, I'm
still confused on how obtain estimates, standard error and F-tests for
main effect and interaction contrasts which agree with the SAS code
with output appended below.

for example,
 ## Given the dataset (from Montgomery)
twoway <- read.table("http://dsteele.veryspeedy.net/sta501/twoway.txt",
col.names=c('material', 'temp','voltage'),colClasses=c('factor',
'factor', 'numeric'))

 ## the model
fit <- aov(voltage ~ material*temp, data=twoway)

material.means <- tapply(twoway$voltage, twoway$material, mean)
temp.means <- tapply(twoway$voltage, twoway$temp, mean)
cell.means <- tapply(twoway$voltage, twoway[,1:2], mean)

Contrasts of Interest ....
[1] 37.75
1
-25.16667
50
80.66667


I expected the following code to provide the estimates above  for
(material 1 - material 2) and (temp1 - temp3), but get unexpected
results...
Estimate Std. Error   t value  Pr(>|t|)
material(1 - 2)      -21   18.37407 -1.142915 0.2631074
Estimate Std. Error  t value     Pr(>|t|)
temp50 - 80    77.25   18.37407 4.204294 0.0002572756

Thanks.  --Dale

/* SAS code */
proc glm data=twoway;
class material temp;
model voltage = material temp material*temp;
contrast '21-22-31+32' material*temp 0 0 0 1 -1 0 -1 1 0;
estimate '21-22-31+32' material*temp 0 0 0 1 -1 0 -1 1 0;
contrast 'material1-material2' material 1 -1 0;
estimate 'material1-material2' material 1 -1 0;
contrast 'temp50 - temp80' temp 1 0 -1;
estimate 'temp50 - temp80' temp 1 0 -1;
run;

SAS output

 Contrast                   DF    Contrast SS    Mean Square   F Value   Pr > F

 21-22-31+32                 1     1425.06250     1425.06250      2.11   0.1578
 material1-material2         1     3800.16667     3800.16667      5.63   0.0251
 temp50 - temp80             1    39042.66667    39042.66667     57.82   <.0001


                                              Standard
  Parameter                   Estimate           Error    t Value    Pr > |t|

  21-22-31+32               37.7500000      25.9848603       1.45      0.1578
  material1-material2      -25.1666667      10.6082748      -2.37      0.0251
  temp50 - temp80           80.6666667      10.6082748       7.60      <.0001
On Sat, Mar 8, 2008 at 11:02 AM, Gregory Warnes <gregory.warnes at mac.com> wrote: