[R-sig-ME] Setting average as baseline rather than a dummy variable in a negative binomial glm
Daniel Rubi
daniel_rubi at ymail.com
Fri Aug 5 18:37:30 CEST 2016
Hi,
I first posted this in cross validated, but thought this forum is better suited for this question.
I have binomial data (meaning k successes out of n trials) for a set of conditions. I would like to fit a glm in order to quantify the effect of each condition on the success.Since the data are overdisperesed I thought of using a negative binomial glm (glm.nb from the R MASS package does that).Code snippet (though not really overdisperesed):set.seed(1)
df <- data.frame(k = as.integer(runif(200,1,20)),
n = as.integer(runif(200,100,200)),
cond = rep(LETTERS[1:20],10),
stringsAsFactors = F)
df$cond <- as.factor(df$cond)
library(MASS)
fit <- glm.nb(k ~ cond + offset(n), data = df)
Obviously cond A will be set as baseline and all effects will be relative to it. However, this makes interpretation very difficult for me. Therefore my question is how do I fit a glm.nb model where the effects are relative to the mean across all conditions rather than the dummy variable set as baseline?
Thanks a lot,Dan
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list