strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
603 stars 91 forks source link

support for a quantile regression #925

Open yuryzablotski opened 6 months ago

yuryzablotski commented 6 months ago

Describe the solution you'd like I would like to be able to plot predictions of quantile regression similarly, like it's currently possible for OLS / GLM. A single quantile would be great, all quantiles at once would be terrific!

It works with only plot_model(model), but doesn't work with plot_model(model, type = "eff", terms = "predictor")

By the way, the emmeans guys (almost, some bugs are still there) made it work with quantile regression and I can use the emmip for plotting. But I prefer your package.

How could we do it? Should be very similar to OLS with the use of "tau" argument, where tau is the quantile. A list of taus is of couarse a much better choice, a compared to a single tau.

Code example

library(ISLR) library(quantreg)

lr <- lm(wage ~ jobclass + age, Wage) qr10 <- rq(wage ~ jobclass + age, Wage, tau = 0.1) qr50 <- rq(wage ~ jobclass + age, Wage, tau = 0.5) qr90 <- rq(wage ~ jobclass + age, Wage, tau = 0.9)

qr_all <- rq(wage ~ jobclass + age, Wage, tau = seq(.05, .95, by = 0.05))

summary(qr_all) %>% plot()