I am trying to model a binary outcome in R that has many independent variables. 5 of the Ivs are factors with more than two levels. When I try to remove the intercept it only does it for one of the independent variables. I would like to see if any of the coefficients for the levels are significantly different from any of the others within that variable(and it would be nice to see if any of the levels are significantly different from the average). When I do a summary of the glm it only shows the values of the coefficient as it relates to the first level(Except for the first IV). To recreate it I have the R code for something similar using mtcars:
md <- datasets::mtcars
md <- mutate(md, ncyl = ifelse(cyl==6,"Six Cyl", cyl))
md <- mutate(md, ncyl = ifelse(cyl==4,"Four Cyl",ncyl))
md <- mutate(md, ncyl = ifelse(cyl==8,"Eight Cyl",ncyl))
md <- mutate(md, wgear = ifelse(gear==3,"Three G",gear))
md <- mutate(md, wgear = ifelse(wgear==4,"Four G",wgear))
md <- mutate(md, wgear = ifelse(wgear==5,"Five G",wgear))
md <- mutate(md, wcarb = ifelse(carb==1,"One Carb",carb))
md <- mutate(md, wcarb = ifelse(carb==2,"Two Carb",wcarb))
md <- mutate(md, wcarb = ifelse(carb==3,"Three Carb",wcarb))
md <- mutate(md, wcarb = ifelse(carb==4,"Four Carb",wcarb))
md <- mutate(md, wcarb = ifelse(carb==6,"Six Carb",wcarb))
md <- mutate(md, wcarb = ifelse(carb==8,"Eight Carb",wcarb))
md <- md[,-c(2,10,11)]
model <- glm(mpg~., data = md)
summary(model)
modelint <- glm(mpg~.-1, data = md)
summary(modelint)
So for summary(modelint)
I can see the values for the coefficients of all 3 possible values ncyl, and with confint(modelint)
I can at least see confidence intervals for all of the possible values. But wgear and wcarb are just compared to their first level alphabetically and the t values are just if it is different from the first level. I know if I just did mpg~wgear-1
I could see their comparisons, but I think this does not take into account all of the other variables. Ideally I would like to see how 1 carb compares to two carb, three, four,... and 1 carb vs not 1 carb while taking into account the other variables. Is there a better function to use than glm? Any advice would be greatly appreciated!