I find your ggocef_compare() such a useful tool for comparing models. Is there a way to retain the factor ordering for the reference levels?
d <- as.data.frame(Titanic)
d$Sex <- factor(d$Sex, levels=c("Male", "Female"))
d$Sex=relevel(as.factor(d$Sex),ref="Male")
m1 <- glm(Survived ~ Sex + Age, family = binomial, data = d)
m2 <- glm(Survived ~ Sex + Age + Class, family = binomial, data = d)
models <- list("Model 1" = m1, "Model 2" = m2)
ggcoef_compare(models, exponentiate = TRUE)
Which produces:
This differs from ggcoef_model(), which retains the specified order:
d <- as.data.frame(Titanic)
d$Sex <- factor(d$Sex, levels=c("Male", "Female"))
d$Sex=relevel(as.factor(d$Sex),ref="Male")
m1 <- glm(Survived ~ Sex + Age, family = binomial, data = d)
ggcoef_model(m1, exponentiate = TRUE)
There is probably a straightforward way to do this, but I'm struggling to find it. Additionally, if I try to remove the reference row, I receive an error:
d <- as.data.frame(Titanic)
d$Sex <- factor(d$Sex, levels=c("Male", "Female"))
d$Sex=relevel(as.factor(d$Sex),ref="Male")
m1 <- glm(Survived ~ Sex + Age, family = binomial, data = d)
m2 <- glm(Survived ~ Sex + Age + Class, family = binomial, data = d)
models <- list("Model 1" = m1, "Model 2" = m2)
ggcoef_compare(models, exponentiate = TRUE, add_reference_rows = FALSE)
```
Error in eval_tidy(dot, data = mask): object 'reference_row' not found
I find your ggocef_compare() such a useful tool for comparing models. Is there a way to retain the factor ordering for the reference levels?
Which produces:
This differs from ggcoef_model(), which retains the specified order:
There is probably a straightforward way to do this, but I'm struggling to find it. Additionally, if I try to remove the reference row, I receive an error:
Thanks!