Plot Regression Line
Plots a regression line on a scatterplot; the line is plotted between the minimum and maximum x-values.
reg.line(mod, col=palette(), lwd=2, lty=1,...)
- a model, such as produced by
lm, that responds to the
coefficientsfunction by returning a 2-element vector, whose elements are interpreted respectively as the intercept and slope of a regresison line.
- color for points and lines; the default is the second entry
in the current color palette (see
- line width; default is
- line type; default is
1, a solid line (see
- optional arguments to be passed to the
In contrast to
abline, this function plots only over
the range of the observed x-values. The x-values are extracted from
mod as the second column of the model matrix.
NULL. This function is used for its side effect: adding a line to the plot.
data(Davis) attach(Davis) mod.M<-lm(repwt~weight, subset=sex=="M") mod.F<-lm(repwt~weight, subset=sex=="F") plot(weight, repwt, pch=c(1,2)[sex]) reg.line(mod.M) reg.line(mod.F, lty=2)