#ggeffects

Dr Mircea Zloteanu 🌼🐝mzloteanu
2025-02-18

#282 Plotting ordinal logistic predicted effects on latent scale of ordinal outcome {ggeffects}

Thoughts: An interesting discussion on plotting ordinal data on the latent scale or probability scale.

github.com/strengejacke/ggeffe

Image from Microsoft SwiftKey Keyboard
2024-12-01

I know it's shameless self-promotion (forgive me), but the examples of `conditional_values()` can also be used to demonstrate the intuitive user interface from {ggeffects}, also using the okabe-ito palette. See following code (in Alt-text), and plot results in the 2nd post... #ggeffects #rstats

RE: https://bsky.app/profile/did:plc:vyspvwpd2wp4rt3sg3guwefm/post/3lc5tv6nmec2h

library(ggeffects)
library(mgcv)
library(gratia)
load_mgcv()

df <- data_sim("eg1", seed = 2)
m1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")

# Plot 1
predict_response(m1, "x2") |> plot(colors = "okabe-ito")

# Plot 2
predict_response(m1, c("x2", "x1 [fivenum]")) |> plot(colors = "okabe-ito")

# Plot 3
predict_response(m1, c("x2", "x1 [fivenum]", "x0 [quart2]", "x3")) |>
  plot(colors = "okabe-ito", n_rows = 2)

df <- data_sim("eg4", seed = 2)
m2 <- gam(y ~ fac + s(x2, by = fac) + s(x0), data = df, method = "REML")

# Plot 4
predict_response(m2, c("fac", "x2 [fivenum]")) |> plot(colors = "okabe-ito")

# Plot 5
predict_response(m2, c("x2", "fac [2,3]")) |> plot(colors = "okabe-ito")

The function has a simple API and should be as intuitive as `ggpredict()` and friends. It can be used for many common use cases of calculating contrasts and pairwise comparisons. A detailed vignetted is here: strengejacke.github.io/ggeffec ...there still might be the need for more sophisticated comparisons. In this case, I recommend using the marginaleffects package directly. Some further related recommended reading is, e.g. the vignettes about "Comparisons"(vincentarelbundock.github.io/m) #rstats #ggeffects

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst