[R] glm specification where response is a 2col matrix
Uwe Ligges
ligges at statistik.tu-dortmund.de
Tue Jan 11 18:42:32 CET 2011
Hi,
when I apply a glm() model in two ways,
first with the response in a two column matrix specification with
successes and failures
y <- matrix(c(
5, 1,
3, 3,
2, 2,
0, 4), ncol=2, byrow=TRUE)
X <- data.frame(x1 = factor(c(1,1,0,0)),
x2 = factor(c(0,1,0,1)))
glm(y ~ x1 + x2, data = X, family="binomial")
second with a model matrix that full rows (i.e. has as many rows as real
observations) and represents identical data:
Xf <- data.frame(x1 = factor(rep(c(1,1,0,0), rowSums(y))),
x2 = factor(rep(c(0,1,0,1), rowSums(y))))
yf <- factor(rep(rep(0:1, 4), t(y)))
glm(yf ~ x1 + x2, data = Xf, family="binomial")
we will find that the number of degrees of freedom and the AIC etc.
differ -- I'd expect them to be identical (as the coefficient estimates
and such things are).
maybe I am confused tonight, hence I do not file it as a bug report
right away and wait to be enlightened ...
Thanks and best wishes,
Uwe
More information about the R-help
mailing list