How to plot the regression line of multivariable linear model?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to plot the regression line of multivariable linear model?

mavavilj
I'm having a bit of trouble plotting the regression line of
multivariable linear model.

Specifically my model has one response and two predictors, i.e. it's of
the form

Y = b_0+b_1*X_1+b_2*X_2

Plotting the regression line for a single predictor model

Y = b_0+b_1*X_1

is simple enough, just call abline() with the coefficients returned by
lm().

However, I don't know if this can be adapted to multivariable linear
models.

I also know about curve(), but I don't know how am I supposed to input
the multivariable model's coefficients into it.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to plot the regression line of multivariable linear model?

Ismail SEZEN

> Specifically my model has one response and two predictors, i.e. it's of the form
>
> Y = b_0+b_1*X_1+b_2*X_2
>
> Plotting the regression line for a single predictor model
>
> Y = b_0+b_1*X_1
>
> is simple enough, just call abline() with the coefficients returned by lm().

Single variable linear model has only 1 regression line.
For two predictors, your regression line! is a surface. (it is not a line anymore)
For 3 predictors, your regression line! is a volume etc…

>
> However, I don't know if this can be adapted to multivariable linear models.

Yes, but in a limited manner. Assume your model is Y ~ x1 + x2 + x3

set x2 and x3 constant  (for instance, to median of the series) predict (predict.lm) Y.predicted values against x1. Order x1 and  Y.predicted values and plot them by lines command on Y ~ x1 scatter plot.

Do same thing for other variables.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to plot the regression line of multivariable linear model?

glsnow
In reply to this post by mavavilj
You might consider the Predict.Plot and TkPredict functions in the
TeachingDemos package.  These help you explore multiple linear
regression models by plotting the "line" relating the response to one
of the predictors at given values of the other predictors.  These
lines can be combined in a single plot (Predict.Plot) or changed
interactively (TkPredict).  See the examples in the help page.

On Sun, Sep 18, 2016 at 9:26 AM, mviljamaa <[hidden email]> wrote:

> I'm having a bit of trouble plotting the regression line of multivariable
> linear model.
>
> Specifically my model has one response and two predictors, i.e. it's of the
> form
>
> Y = b_0+b_1*X_1+b_2*X_2
>
> Plotting the regression line for a single predictor model
>
> Y = b_0+b_1*X_1
>
> is simple enough, just call abline() with the coefficients returned by lm().
>
> However, I don't know if this can be adapted to multivariable linear models.
>
> I also know about curve(), but I don't know how am I supposed to input the
> multivariable model's coefficients into it.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.