In R (ggplot2) how to add arrows for binary variables that move estimate line up/down?

Viewed 49

Assume I do the following:

    # Simple scatter plot with correlation coefficient and
# regression line
#::::::::::::::::::::::::::::::::::::::::::::::::::::
ggscatter(mtcars, x = "wt", y = "mpg", add = "reg.line") +
  stat_cor(label.x = 3, label.y = 34) +
  stat_regline_equation(label.x = 3, label.y = 32)
#> `geom_smooth()` using formula 'y ~ x'

(I copied that from: https://rpkgs.datanovia.com/ggpubr/reference/stat_regline_equation.html)

However, my model is not only (x= wt and y= mpg) I also have 3 dummies, say CABRIO (0/1) and MPV (0/1) and SUV (0/1) (assume here, they are mutually exclusive (each car is only one of the dummies or a left-out category), interactions impossible!). I add them linearly in the model, so they just change the slope: mpg = b1* wt + b2 * CABRIO + b3 * MPV + b4 * SUV.

Instead of plotting lines for all the possible body types (SUV/MPV/Cabriolet) I want arrows showing in which the "baseline" would shift with arrows in the size of the effect.

Is this possible in GGPLOT?

I added a (very bad) picture see for exaple , that shows what I want. I want arrows on the line the size of the beta coefficients (b2, b3,b4).

0 Answers
Related