Multinomial logistic regression is used to model a nominal outcome variable. Because of the nominal categorical nature of the outcome variable, the output table becomes complex, especially when the researcher includes a great number of predictors. Visualization can help researchers quickly summarize the patterns of results. Using tidyverse R package (ggplot2 is embedded in this package), we can visualize the regression results table.
Let’s look at an example where the outcome variable has four categories, i.e., four different attitudes towards science and technology (negative & positive, negative, moderate, and positive). Eight predictors are included in the model. The positive attitudes group is used as the reference.
Using the tidyverse R package, we can visualize the regression results table. The plot is organized by three groups of attitudes (moderate, negative, and negative & positive). The positive group is used as the reference, so it is not shown on the plot. The coefficient estimates with 95% CIs are presented in red bars on the plot. The numbers labeled next to the red bars provide effect size measures (ORs). To make it easier for readers to compare ORs, the reciprocal of ORs, i.e., 1/(exp(beta)), was used for predictors with negative coefficients. We can easily identify the patterns of findings across three groups of attitudes by comparing the point estimates, 95% CIs, and ORs horizontally for each predictor. This visualization tool can be used for regular multinomial logistic regression and can also be used for latent class analysis when adding the covariates to identify the characteristics of the classes. The R code can be found at (https://rpubs.com/swallow00001/viz_multinomial_regression).
library(readr)
library(tidyverse)
mydata <- read_csv("Reg_results.csv")
coef_plot <-mydata %>%
mutate(Group = case_when(
Group == "moderate" ~ "Moderate",
Group == "negative" ~ "Negative",
Group == "neg_pos" ~ "Negative & Positive"),
Covariate = case_when(
Covariate == "AGEGRP5" ~ "Age - 65+",
Covariate == "AGEGRP1" ~ "Age - 25 - 34",
Covariate == "RELIG" ~ "Religiosity",
Covariate == "RELIG_KID" ~ "Child \n Religious Faith",
Covariate == "PCFREQ2"~ "Computer Use",
Covariate == "EDU3GRP2"~ "College or More",
Covariate == "EDU3GRP1" ~ "High School",
Covariate == "EMP3GRP1" ~ "Currently Working"))%>%
ggplot(aes(y = Covariate, x = estimate, pch = Group,label = OR)) +
geom_point(aes(y = Covariate, x=estimate), color= "#FF6666") +
geom_errorbarh(aes(xmax = Upper, xmin = Lower,height = .12), color ="#FF6666",size = 0.6) +
geom_vline(xintercept =0, linetype = "dashed") +
scale_shape_manual(values = c(0,2,19)) +
geom_text(size = 3, nudge_x = 2,vjust = -0.25) +
facet_grid(.~Group) +
scale_x_continuous(name ="Regression Coefficients with Odds Ratio", limits=c(-5,5)) +
theme(legend.position = "bottom")
coef_plot
Pullman, A., Chen, M., Zou, D., Hives, B., & Liu,
Y. (2018). Researching multiple publics through latent profile
analysis: Similarities and differences in science and technology
attitudes in China, Japan, South Korea and the United States. Public
Understanding of Science, 28(2), 130-145. DOI:
10.1177/0963662518791902