Skip to content
Prev 75812 / 398502 Next

do glm with two data sets

On Thu, 2005-08-18 at 10:38 -0400, Hu, Ying (NIH/NCI) wrote:
This is redundant, as:
and:

fit <- glm(e[1, ] ~ g[1, ])

are equivalent - you don't need data = d1 in this case, e.g:

e <- matrix(c(0, 1, 0, 0, 1, 1, 1, 1, -1), ncol = 3, byrow = TRUE)
e
g <- matrix(c(1.22, 1.34, 2.44, 2.33, 2.56, 2.56, 1.56, 1.99, 1.46),
ncol = 3, byrow = TRUE)
g
fit <- glm(e[1, ] ~ g[1, ])
fit

works fine.
This seems a strange way of doing this. Why not:

pred <- g[1, ]
resp <- e[1, ]
fit <- glm(resp ~ pred)
fit

and do your subsetting outside the glm call - makes things clearer no?
Unless you plan to do many glm()s one per row of your two matrices. If
that is the case, then there are better ways of approaching this.
HTH

G