Will the signs of coef (Estimate) of lm and glm always be the same? ^
According to below toy example, it seems yes. Can you provide a case where they might be different? (If it matters in my real data the outcome is binary, hence used mpg > 20
)
# dummy data
d <- mtcars
# fit lm, glm, glm_bi
fit_lm <- lm(mpg > 20 ~ cyl + disp, data = d)
fit_glm <- glm(mpg > 20 ~ cyl + disp, data = d)
fit_glm_bi <- glm(mpg > 20 ~ cyl + disp, family = binomial, data = d)
# Signs are always same?
# lm compared to glm
all.equal(sign(coef(fit_lm)),
sign(coef(fit_glm)))
# output
# [1] TRUE
# lm compared to glm(family = binomial)
all.equal(sign(coef(fit_lm)),
sign(coef(fit_glm_bi)))
# output
# [1] TRUE
^ Very much sounds like a dupe, found this similar post: Sign of coefficients in linear regression vs. the sign of correlation. Let me know if this is a dupe.