I am taking a class that uses SAS while trying to conduct analyses in Splus
(using 6.2 windows build 6173). I'm having trouble understanding specified
contrasts for the two.
In SAS GLM if I fit a model (there are 3 trials and 22 subjects) with
contrasts specified as
PROC GLM;
CLASS trial subject;
MODEL logEMG = subject trial;
contrast 'Trial 2 vs. 1' trial -1 1 0;
contrast 'Trial 3 vs. 1' trial -1 0 1;
estimate 'Trial 2 vs. 1' trial -1 1 0;
estimate 'Trial 3 vs. 1' trial -1 0 1;
run;
From the output the parameter estimates are then:
Parameter Estimate Error t Value Pr > |t|
Trial 2 vs. 1 0.16790077 0.09462864 1.77 0.0833
Trial 3 vs. 1 0.52257977 0.09462864 5.52 <.0001
In Splus when I define contrasts and fit a model
> contrasts.emg <- matrix(c(-1, 1, 0, -1, 0, 1), nrow = 3)
> emg.glm <- glm(logEMG ~ C(factor(EMG$TRIAL), contrasts.emg) +
factor(subject), data = EMG)
> contrasts(model.matrix(emg.glm))
$"C(factor(EMG$TRIAL), contrasts.emg)":
[,1] [,2]
1 -1 -1
2 1 0
3 0 1
These are the parameter estimates for TRIAL
Coefficients:
Value Std. Error t value
(Intercept) 5.57149066 0.18120006 30.74773114
C(ordered(EMG$TRIAL), contrasts.emg)1 -0.06225941 0.05463387 -1.13957522
C(ordered(EMG$TRIAL), contrasts.emg)2 0.29241959 0.05463387 5.35234958
But when I fit (I have options(contrasts=c('contr.treatment','contr.poly'))
)
> emg.glm <- glm(logEMG ~ factor(EMG$TRIAL) + factor(subject), data = EMG)
> contrasts(model.matrix(emg.glm))
$"factor(EMG$TRIAL)":
2 3
1 0 0
2 1 0
3 0 1
I get the same result as in the SAS proc GLM above
Coefficients:
Value Std. Error t value
(Intercept) 5.34133048 0.18925729 28.22258809
factor(EMG$TRIAL)2 0.16790077 0.09462864 1.77431235
factor(EMG$TRIAL)3 0.52257977 0.09462864 5.52242688
Can someone explain what I am I not understanding?
Mark Grant
|