I want to observe the effect of a treatment variable on my outcome Y. I did a multiple regression: fit <- lm (Y ~ x1 + x2 + x3)
. x1
is the treatment variable and x2
, x3
are the control variables. I used the predict function holding x2
and x3
to their means. I plotted this predict function.
Now I would like to add a line to my plot similar to a simple regression abline
but I do not know how to do this.
I think I have to use line(x,y) where y = predict
and x
is a sequence of values for my variable x1
. But R tells me the lengths of y
and x
differ.