Skip to content
Back to formatted view

Raw Message

Message-ID: <72e8303a0803061807n7062c068g7a3766f8a30799f5@mail.gmail.com>
Date: 2008-03-07T02:07:45Z
From: Dale Steele
Subject: Finding Interaction and main effects contrasts for two-way ANOVA

I've tried  without success to calculate interaction and main effects
contrasts using R.  I've found the functions C(), contrasts(),
se.contrasts() and fit.contrasts() in package gmodels.  Given the url
for a small dataset and the two-way anova model below, I'd like to
reproduce the results from appended SAS code.  Thanks.  --Dale.

  ## 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)

/* 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;