When I run a binomial regression in R with an independed factor variable consisting of three levels \"Higher\" , \"Middle\" and \"Lower\" of which I want to change the referen
cbsnivcat3
is an ordered factor, so relevel
won't work. What you can do is change it to an ordinary factor:
cbsnivcat3 <- factor(cbsnivcat3, levels=c("Lower","Middle","Higher"))
Try this
df <- data.frame(y=sample(c(0,1), size=100,replace=T),x1=rep(c('a','b','c'),100), x2=1:100)
summary(glm(y~x1+x2,data=df))
df$x1 <- relevel(df$x1, ref='b')
summary(glm(y~x1+x2,data=df))
df$x1 <- relevel(df$x1, ref='c')
summary(glm(y~x1+x2,data=df))