1

I want to run a quantile regression in R which includes a three-way-interaction-term with three categorical predictors at the median (tau = 0.5). To interpret the effect, I want to create a plot. For linear models I use the function effect() from the package "effects". Unfortunately, this does not work with rq() from the package "quantreg". Do you have any suggestions on how to display an interaction effect?

library(quantreg)
data(mtcars)
summary(rq(formula = mpg ~ vs * am * carb, tau = 0.5, data = mtcars))
Lena
  • 11
  • 3

1 Answers1

1

You can use the visreg package, though three-way interactions will have to be simplified (by you), plotting two of the terms at a time, for instance:

mod <- rq(formula = mpg ~ vs * am * carb, tau = 0.5, data = mtcars)

library(visreg)
visreg(mod, "carb", by="am", overlay=TRUE)

gives

enter image description here

Remko Duursma
  • 2,741
  • 17
  • 24
  • Thank you for your quick answer! It seems like a great way in general ,in this case I've tried visreg() and unfortunately I don't see much in my plot due to fairly small effect sizes and large outliers. I don't get the confidence intervals with two categorical predictors, so I'm still looking for a way to plot the three-way interaction in along the lines of "effect()" or "margin()" . – Lena Jul 31 '17 at 20:17