[R] using the design matrix to correctly configure contrasts

Walmes Zeviani walmeszeviani at hotmail.com
Wed Jun 2 17:50:35 CEST 2010


Take a look at contrast package. It has functions to handle with user
contrasts. Below you have a reproducible and minimal example using
contrast's functions.

da <- expand.grid(A=factor(paste("A", 1:3, sep="")),
                  B=factor(paste("B", 1:4, sep="")), rep=1:4)
eta <- model.matrix(~A*B, da)%*%matrix(c(0, 1,2, -1,0,1, 0,1,2, 0,0,0))
da$y <- rnorm(da$A, mean=eta, sd=1)

g0 <- lm(y~A*B, data=da)
anova(g0)

require(contrast)

c0 <- contrast(g0,
               list(B="B1", A="A1"),
               list(B="B2", A="A1"))
c0
c0$X

Walmes.

-----
..ooo0
...................................................................................................
..(....)... 0ooo...                              Walmes Zeviani
...\..(.....(.....)...     Master in Statistics and Agricultural
Experimentation
....\_)..... )../....       walmeszeviani at hotmail.com, Lavras - MG, Brasil
............
(_/............................................................................................
-- 
View this message in context: http://r.789695.n4.nabble.com/using-the-design-matrix-to-correctly-configure-contrasts-tp2238719p2240372.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list