line
Robust Line Fitting

### Description

Fits a tukey line.

### Usage

    line(x, y = NULL)
    ## S3 method for class 'tukeyline':
    print(x, digits = max(3L, getOption("digits") - 3L), ...)

### Arguments

x | the x coordinates of points. If y is missing, x should be an object implicitly containing x-y data: a 2-column matrix, a list with components named x and y, a complex vector, a ts object, or a numeric vector. See xy.coords for more details. For the print method, x is an object of class "tukeyline", typically producted by line.
y | the y coordinates of points.
digits | the maximum number of (significant) digits to use for coefficients of tukey line.
... | other optional arguments passed to generic function.

### Details

line fits a line through the points using a simple robust algorithm that Tukey described in reference Exploratory Data Analysis. The slope is the slope of the line passing through the x and y medians of the left and right thirds of the data; the intercept is chosen so that the median residual is 0.
Value
line returns a list of class "tukeyline" with following components:

call | system call of this function.
coefficients | the coefficients, intercept then slope, of the fitted line.
residuals | the actual y values minus the fitted values.

fitted.values | the y values on the fitted line at the observed x values.

print.tukeyline, like other print methods, returns its x argument invisibly.
References
Tukey, J. W. 1977. Exploratory Data Analysis. Reading, MA: Addison-Wesley Pub.
See Also
lm, lm.fit, xy.coords.
Examples

    tukey.line <- with(Sdatasets::fuel.frame, line(Weight, Fuel))
    tukey.line
    coefficients(lm(Fuel ~ Weight, data=Sdatasets::fuel.frame))

Package stats version 6.1.5-18
Package Index