Dear all, I have small difficulty in comprehending the loglinear model with R. Assume, we have following data
dat <- array(c(911, 44, 538, 456, 3, 2, 43, 279), c(2, 2, 2)) Now I fit a loglinear model with this and get the fitted values: library(MASS) Model_1 <- loglm(~1 + 2 + 3, dat) fitted(Model_1) I could do this same task using glm() function as well because loglinear model is just 1 kind of glm ### Create dummy variables manually Dummy_Variable_Matrix <- rbind(c(1, 1, 1), c(0, 1, 1), c(1, 0, 1), c(0, 0, 1), c(1, 1, 0), c(0, 1, 0), c(1, 0, 0), c(0, 0, 0)) ### Fit glm model_2 <- glm(as.vector(dat) ~ Dummy_Variable_Matrix[,1] + Dummy_Variable_Matrix[,2] + Dummy_Variable_Matrix[,3], poisson(link = log)); fitted(model_2) ### However................ fitted(model_2) == as.vector(fitted(Model_1)) ### do not match However it is true that the difference is very small, still I am wondering whether should I just ingore that small difference? Or I have done something fundamentally wrong? Thanks for your help! ______________________________________________ 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.