[R] Help with options("contrasts")

From: Axel Urbiz <axel.urbiz_at_gmail.com>
Date: Mon, 09 May 2011 18:54:16 -0400

Dear list,

Is it possible to specify a contrast in options() that would create an identity matrix for each factor in the model matrix? For example, for each factor in 'dd' below, I can create an identity matrix using contrasts = FALSE. Is it possible to set this in options(), so when I create a model matrix from any factor, the factor coding would follow this specification for the contrast?

dd <- data.frame(a = gl(3,4), b = gl(4,1,12))
ca <- contrasts(dd$a, contrasts= FALSE)  # 3 x 3 identity matrix
cb <- contrasts(dd$b, contrasts= FALSE)  # 4 x 4 identity matrix
My attempt below works fine, but again, I'd like to specify this in the options() as opposed to each contrast individually. model.matrix(~ a + b, dd, contrasts =list(a=ca, b=cb)) Thanks for any help!

        [[alternative HTML version deleted]]

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. Received on Mon 09 May 2011 - 22:58:24 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 May 2011 - 00:10:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive