[R-sig-eco] log-linear model and log-likelihood ratio
Marta Rufino
mrufino at cripsul.ipimar.pt
Sat Feb 14 19:22:35 CET 2009
Dear all,
I am trying learn something (on analysis of frequencies) by reproducing
the examples from Quinn & Keough book (experimental design...) from
chapter 14, section 14.3 on log-linear models.
# This would be the data
floodplain=data.frame(y=c(15,4,0, 13,8,17),
position=gl(3,1,6, labels=c("bottom","middle","top")),
dead_coli=gl(2,3,labels=c("with","without")))
# The first full model would be (log-linear model to calculate the
log-likelihood ratio):
loglm(y ~ position + dead_coli + position:dead_coli, floodplain) # which
includes interaction.. and does not work, not even if I add a constant
of .5 to y. In the book it is suppose to give: -10.429
# the second reduced model would be (does not work)
loglm(y~ position + dead_coli, floodplain) #which works, but gives a
different result from the book. In the book it gives: -19.735
This is needed to calculate G2 statistic (from Sokal and Rohlf) for
which I could not find anything in R, also.
Any idea about what is wrong or the correct calculations? I looked on
Sokal and Rohlf, and had the same problem...
Thank you very much e in advance,
Best wishes,
Marta
More information about the R-sig-ecology
mailing list