[R] Setting up contrasts

David J. Netherway david.netherway at adelaide.edu.au
Mon May 3 10:25:12 CEST 2004


I am using the following model:
lm <- lm(mydata[[variableName]] ~ Age + Gender + Group, data=mydata)

There are 5 groups in "Group": nonc (the control), c1,c2,c3 and c4.

How do I contrast nonc vs the others?

and

How do I contrast c1 vs other c's (ie c2,c3,c4 as a subgroup)?

I have looked at the contrasts option in lm and model.matrix and am
really none the wiser.
Though it looks like I need to read up on model matrices again.

Any help would be appreciated.

Thanks, David




More information about the R-help mailing list