Resistant line or Tukey line

Most elements explained here applied to regression-type functions; please read it as an introduction to these functions.

line() produces a Tukey line>

line(urb,infmor)

When you execute this command line, you will see this output that contains the regression coefficients.

Call: line(x, y) Coefficients: [1] 60.5868 -0.1157

You can also store the object:

resline = line(urb,infmor)

an then examine this object with str(resline) to display:

List of 4 $ call : language line(x, y) $ coefficients : num [1:2] 60.587 -0.116 $ residuals : num [1:183] -42.47 -2.36 -24.24 -12.12 29.99 ... $ fitted.values: num [1:183] 60.5 60.4 60.2 60.1 60.0 ... - attr(*, "class")= chr "tukeyline"

The function creates an object of type "tukeyline" which is a regression type object; a series of functions let you extract this information from it for their specific purpose.

- coef(resline) Slope and the intercept
- fitted(resline)Fitted values
- residuals(resline)Residuals

The same information can also be retrieved using resline$coefficients, resline$residuals or resline$fitted.

You can use this directly in various functions, e.g.

- abline(resline$coefficients) (abline(resline) is also ok ) adds the resistant line to the current plot.
- plot(resline$residuals) produces a residual plot
- plot(residuals(resline) ~ fitted(resline)) plots the residuals against the fitted values.

Note that you can also write: plot(line(urb~infmor)$residuals))

See also

- rline in library LearnEDA it displays the Half slope ratio (first half slope diveded by the second).
- Regression
- Regression and residuals