Dears useRs, I have 2 factors, (for the sake of explanation - A and B), with 4 levels each. I've already fitted a negative binomial generalized linear model to my data, and now I need to split the factors in two distinct analysis of deviance table: - A within B1, A within B2, A within B3 and A within B4 - B within A1, B within A2, B within A3 and B within A4
Here is a code that illustrates my problem: # inputing my data require(MASS) my.data <- data.frame("A"=rep(c(rep("Alevel1",4),rep("Alevel2",4),rep("Alevel3",4),rep("Alevel4",4)),4), "B"=c(rep("Blevel1",16),rep("Blevel2",16),rep("Blevel3",16),rep("Blevel4",16)), "value"=rnegbin(64, 10, 10)) # fitting the model with interaction (a + b + a:b) model <- glm.nb(value ~ A*B, data=my.data) anova(model, test="F") Df Deviance Resid. Df Resid. Dev F Pr(>F) NULL 63 80.639 A 3 1.374 60 79.265 0.4581 0.7115 B 3 2.285 57 76.980 0.7616 0.5155 A:B 9 9.700 48 67.280 1.0778 0.3753 #until here it's ok, now I need to redistribute the 12 degrees of freedom (B+A:B -> 3+9) into 4 splitted factors (A within B1, A within B2...) model2 <- glm.nb(value ~ A/((B=="Blevel1")+(B=="Blevel2")+(B=="Blevel3")+(B=="Blevel4")), data=my.data) anova(model2, test="F") Df Deviance Resid. Df Resid. Dev F Pr(>F) NULL 63 80.639 A 3 1.374 60 79.265 0.4581 0.7115 A:B == "Blevel1" 4 3.871 56 75.394 0.9676 0.4238 A:B == "Blevel2" 4 5.236 52 70.158 1.3090 0.2639 A:B == "Blevel3" 4 2.878 48 67.280 0.7195 0.5784 A:B == "Blevel4" 0 0.000 48 67.280 However, the 12 degrees of freedom are distributed as 4,4,4,0 and not 3,3,3,3, as I expected. Is there a way of obtaining the split I need? Thanks in advance, all the best! Rafael. ____________________________________________________________________________________ [[elided Yahoo spam]] [[alternative HTML version deleted]]
______________________________________________ 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.