Search code examples
rlinear-regression

Relevel command in R not "releveling"


I'm using a form of the relevel command that seems to run without error, but it has not successfully releveled my baseline variable (I want my baseline to be "manage") when I go to run my model again.

mods= ~ relevel(factor(ENROLLMENT_PLAN, ref="manage"))

model4 <- lm(formula= Y ~ ENROLLMENT_PLAN + X + X, data=mydata); stargazer(model4, header=FALSE, font.size = "tiny", type = "text", align=TRUE, single.row = FALSE, column.sep.width = "1pt", digits=2)

Could someone please assist with my code?


Solution

  • You didn't change the ENROLLMENT_PLAN inside mydata. (What is mods BTW?)

    mydata$ENROLLMENT_PLAN = relevel(factor(mydata$ENROLLMENT_PLAN), ref="manage")
    
    model4 <- lm(formula= Y ~ ENROLLMENT_PLAN + X + X, data=mydata)