[R-sig-eco] Contrasts for glm models

Mgr. Martin Weiser martin.weiser at natur.cuni.cz
Fri Feb 24 20:03:53 CET 2012


Dne 24. února 2012 15:53 Scott Chamberlain
<scttchamberlain4 at gmail.com> napsal(a):
> Hello,
>
>
> I have looked at the archives and I still can not figure this out.  So this code
>
> dat <- data.frame(var1 = as.factor(rep(c("a","b"), each=8)),
>           var2 = as.factor(rep(c("c","d"), 8)),
>           response = round(rnorm(16, 10, 4), 0))
> mod <- glm(response ~ var1 * var2, data=dat, family=poisson)
> anova(mod, test="Chisq")
>
>
>
> gives me my glm model with poisson error dist, and main effects tests, but I would like to compare the levels of var2 (c and d) within each level of var1 (a and b).  What I don't want is just c vs. d for var2 averaged across a and b levels of var1.
>
> I imagine multcomp is the way to go here?
>
>
> Thanks!
> --
> Scott Chamberlain
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Hello,
to me it seems that you ask for nesting:
mod <- glm(response ~ var2 %in% var1, data=dat, family=poisson)
But may be I am wrong.
Best,
Martin Weiser



More information about the R-sig-ecology mailing list