[19201] in s-news-athena
[S] Defining contrasts in factors
daemon@ATHENA.MIT.EDU (Pierre Delfosse)
Mon Sep 13 09:42:22 1999
Message-Id: <C1B1A78EB953D211902D0040056AC48B0451B2@VRVCOM>
From: Pierre Delfosse <pierre.delfosse@centexbel.be>
To: s-news@wubios.wustl.edu
Date: Mon, 13 Sep 1999 13:55:00 +0200
Mime-Version: 1.0
Content-Type: text/plain
Dear S+ users,
I would like to understand how the dummy coefficients associated to a
factor are computed in "lm" in function of the values of the matrix of
contrasts.
Let y1, y2 and y3 be the mean response values for the 3 levels of a
factor.
Setting contrasts with
> options(contrasts=c("contr.treatment","contr.poly"))
we have the following matrix of contrasts
> contr.treatment(3)
2 3
1 0 0
2 1 0
3 0 1
and the "lm" coefficients of the factor are y2-y1 and y3-y1.
Setting contrasts with
> options(contrasts=c("contr.sum","contr.poly"))
we have the following matrix of contrasts
> contr.sum(3)
[,1] [,2]
1 1 0
2 0 1
3 -1 -1
and the "lm" coefficients of the factor are y1-ybar and y2-ybar.
Setting contrasts with
> options(contrasts=c("contr.helmert","contr.poly"))
we have the following matrix of contrasts
> contr.helmert(3)
[,1] [,2]
1 -1 -1
2 1 -1
3 0 2
and the "lm" coefficients of the factor are (y2-y1)/2 and
(y3-(y1+y2)/2)/3.
The "lm" coefficients are thus visibly not obtained by multiplying the
columns of the matrix of contrasts with the (y1, y2, y3) vector.
How are they then obtained? How can I define other contrasts if I do not
know the way they are computed?
Thak you for your attention.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news