sjPlot plot_model() plotting reference category odds ratio 1

74 views Asked by At

I fitted a logistic multilevel model. Everything worked fine. The problem arises when I want to plot the Odds ratios. The function plot_model() in the R-package sjPlot plots only by default the categories that are NOT the reference category. That's usually fine but for my case it makes sense to include the reference category in the odds ratios plot and set it to 1. So my question is do I really have to manually extract the information of the ggplot object that is created by plot_model and then add all the reference categories to the data of gg object and set them to 1? or is there a faster, cleaner and less messy way to deal with this issue?

Example to recreate simple logistic model. Dont mind the output it is just to have categories

# Load the dataset
data(mtcars)

# Convert mpg to a binary variable
mtcars$mpg_high <- ifelse(mtcars$mpg > median(mtcars$mpg), 1, 0)

# Convert categorical variables to factors
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$vs <- as.factor(mtcars$vs)
mtcars$am <- as.factor(mtcars$am)

# Fit logistic regression model
model <- glm(mpg_high ~ cyl + vs + am, data = mtcars, family = binomial)

# Summary of the model
summary(model)
require(sjPlot)

plot_model(model)

My question is how do I get to plot conveniently the reference category and set it to 1?

0

There are 0 answers