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!
Axel.

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to