Skip to content
Prev 259568 / 398502 Next

Help with contrasts

Or alternatively (though very similar to Peter's idea) you can do

ci <- contrasts
formals(ci)$contrasts <- FALSE
dd <- data.frame(a = gl(3,4), b = gl(4,1,12))
mm <- model.matrix(~ a + b, dd, contrasts = list(a=ci(dd$a),
b=ci(dd$b))) 

Best,
Leo.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of peter dalgaard
Sent: 2011, May, 11 7:31 AM
To: Lars Bishop
Cc: R-help at r-project.org Help
Subject: Re: [R] Help with contrasts
On May 11, 2011, at 12:51 , Lars Bishop wrote:

            
contr.SAS, etc).
It's not actually using contr.treatment, it's just calling
contr.identity with contrasts=TRUE...

I don't think there's a painless way to avoid this. The closest I can
think of is

cI <- contr.treatment
formals(cI)$contrasts <- FALSE
dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) model.matrix(~ C(a,cI,3) +
C(b,cI,4), dd)



--
Peter Dalgaard
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000
Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
_______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive
any related rights and obligations. Any distribution, use or copying of this e-mail or the information
it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courriel peut contenir des renseignements prot?g?s et confidentiels.
L?exp?diteur ne renonce pas aux droits et obligations qui s?y rapportent.
Toute diffusion, utilisation ou copie de ce courriel ou des renseignements qu?il contient
par une personne autre que le destinataire d?sign? est interdite.
Si vous recevez ce courriel par erreur, veuillez m?en aviser imm?diatement, 
par retour de courriel ou par un autre moyen.