Skip to content
Back to formatted view

Raw Message

Message-ID: <6rd7oxlkgl.fsf@franz.stat.wisc.edu>
Date: 2000-03-14T14:01:14Z
From: Douglas Bates
Subject: fittin a regression line
In-Reply-To: sht103's message of "Tue, 14 Mar 2000 13:48:13 +0000"

sht103 <sht103 at york.ac.uk> writes:

> I have tried to find a command to fit(plot) a regression line but I
> haven't found any command on the html.help.  My question is if I am
> using a regression for instance reg<-lm(y~x) and I would like to
> make a regression line, to see how well my data is fit.  Can you
> please help me with this??

A simple linear regression line can be added to a plot with abline.
For more complicated models, you should generate a sequence of x
values at which you wish to evaluate the model and use the predict
method to get the y values.

The simple case looks like

 plot( y ~ x )
 fm <- lm( y ~ x)
 abline( fm )
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._