The abline function works fine for simple linear regression because there
is only 1 line, but with multiple linear regression there are an infinite
number of lines and you need to decide which to plot (or find a way to plot
t he plane/hyperplane/surface/etc.).
One option is to use the Predict.Plot and TkPredict functions in the
TeachingDemos package. These will plot the relationship between the
response and 1 of the predictors conditioned on values of the other
predictors.
On Wed, Feb 13, 2013 at 3:02 PM, Craig O'Connell
wrote:
> Hello,
>
> My name is Craig and I need help plotting a "line" for a multiple linear
> regression in R.
>
> Here is my sample data (filename: convis.txt)
>
> Output of convis.txt is (vis and density being predictors of either
> avoidance or entrance):
>
> vis den avoid entrance
> 1 10 1 0.0000 0.0000
> 2 10 3 0.8750 0.0000
> 3 8 3 0.8180 0.0300
> 4 8 3 0.6670 0.0667
> 5 8 1 0.2110 0.0000
> 6 6 1 0.2500 0.0000
> 7 10 1 0.3000 0.0000
> 8 10 1 0.1050 0.0000
> 9 8 1 0.7000 0.1000
> 10 3 5 0.1176 0.0588
> 11 3 5 0.3077 0.1150
> 12 3 9 0.9090 0.0900
> 13 3 7 0.7778 0.1110
> 14 3 5 0.5560 0.1110
> 15 3 1 0.5710 0.0000
> 16 3 4 0.5710 0.0000
>
> In order to do the multiple regression, I used the following coding:
>
>
> double=read.table("convis.txt",header=TRUE)
> attach(double)
> double
> stem(vis)
> stem(den)
> stem(avoid)
> stem(entrance)
> plot(entrance,vis*den) *as means to see how the interaction between
> visibility and density may impact entrance behaviors
> model6=lm(entrance~vis*den)
> model6
> summary(model6)
> *abline(model6) *Here is the issue as I used this for my simple linear
> regression technique, but do not know what to use for a multiple
> regression*
>
> If anybody can provide some feedback on this, it would be greatly
> appreciated.
>
> Kind Regards,
>
> Craig
>
> --
> <>< <>< <><
> Craig O'Connell
> University of Massachusetts Dartmouth
> Marine Biologist
> www.youtube.com/craigpoconnell
> craigosea.blogspot.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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.
538280@gmail.com
[[alternative HTML version deleted]]