% plot() + ylab("predicted probabilities") + xlab("") + ggtitle("") + geom_errorba" /> % plot() + ylab("predicted probabilities") + xlab("") + ggtitle("") + geom_errorba" /> % plot() + ylab("predicted probabilities") + xlab("") + ggtitle("") + geom_errorba"/>

How to change title of facets in ggpredict() for ordered logit

35 Views Asked by At

I have the following code:

ggpredict(df, terms=c("x"), by = "id") %>% plot() + 
  ylab("predicted probabilities") + xlab("") + ggtitle("") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0.05) +
  scale_x_continuous(
    breaks = seq(0, 2, 1),
    labels = c("No Answer", "No", "Yes")
  )

It produces a plot that looks like this:

enter image description here

I want to change the facet titles so I added:

ggpredict(df, terms=c("x"), by = "id") %>% plot() + 
  ylab("predicted probabilities") + xlab("") + ggtitle("") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0.05) +
  scale_x_continuous(
    breaks = seq(0, 2, 1),
    labels = c("No Answer", "No", "Yes")
  ) +
  facet_wrap(~ x, labeller = labeller(x = c("0" = "A", "1" = "B", "2" = "C", "3" = "D", "4" = "E")))

Which gives men a graph that's way off:

enter image description here

I recognize that the x-axis is squished and I plan to fix that later, but right now, my primary concern is changing the facet titles.

0

There are 0 best solutions below