8.11 Visualizing multiple conditional logistic regression plots

  • We can create multiple conditional plots by adding a by option.

  • The following code plots the probability of being married given age, seperately for men and women (by="sex"), controlling for race and job sector.

# plot results
library(ggplot2)
library(visreg)
visreg(cps85_glm, "age",
       by = "sex",
       gg = TRUE, 
       scale="response") +
  labs(y = "Prob(Married)", 
       x = "Age",
       title = "Relationship of age and marital status",
       subtitle = "controlling for race and job sector",
       caption = "source: Current Population Survey 1985")

  • In this data, the probability of marriage is very similar for men and women.