I'm running a glm in R with two categorical variables, one of which is binary, the other of which can take on five values. I would like it so that my model returns an intercept value that reflects the case where my binary variable is "off," and where each of my five categories is provided an increase/decrease based on whether it is off or on (only one can be on at a time). Currently, I have succeeded in the first task, but I believe that my model is assuming a default of the fifth category being on, which I do not want. The results of my regression are below:
And the code to make it:
## GLM with Five Quintiles in One Regression
S = factor(rep(c("first","second","third", "fourth", "fifth"),c(2,2,2,2,2)))
Sfirst = (S=="first")
Ssecond = (S=="second")
Sthird = (S=="third")
Sfourth = (S=="fourth")
Sfifth = (S=="fifth")
N = factor(rep(c("outside", "nonoutside"), 5))
Noutside = (N=="outside")
Nnonoutside = (N=="nonoutside")
yt = c(79, 73, 73, 69, 103, 73, 127, 61, 111, 36)
nt = c(15, 31, 11, 10, 15, 8, 7, 5, 4, 8)
countt = cbind(yt, nt)
print(countt)
resultt = glm(countt ~ Noutside + Nnonoutside + Sfirst + Ssecond + Sthird + Sfourth + Sfifth, family =
binomial("logit"))
summary(resultt)
My question: what is considered the "proper" way to create a dummy variable for this regression such that Sfifth is also assigned an estimate, as opposed to being baked into the intercept value, as it seems like it currently is. Any suggestions would be sincerely appreciated.