In the case of multiple regression where I have dependent variable Y and two predictors X1 and X2 I would like to make a plot of their relationship before fitting a regression, however the plot function only allows the plotting of two variables at a time. for example plot(x, y)
how can I look at the overall data then?
Solved – Plotting regression predictors
data visualizationrregression
Best Answer
In an instance like this, I would probably use ggplot2, as it excels at this kind of thing.
Assuming that your variables are Y, X1 and X2.
That will plot X1 against Y with different colours representing values of X2. You can also call
geom="smooth", method="lm"
to get a plot of the regression line, and loess smoothers are also available. HTH.