lad: Least absolute deviations regression

Description Usage Arguments Details Value Examples

View source: R/lad.R

Description

Finds the values of beta0 and beta1 that minimize the sum of least absolute deviations for given vectors x and y.

Usage

1
lad(x, y, ...)

Arguments

x

A numeric vector of observations

y

A numeric vector of observations

...

further arguments passed to or from other methods

Details

lad minimizes the sum of least absolute deviations and finds the corresponding estimates of beta0 and beta1.

Value

An object of class "lad" is a list containing the following components:

coefficients named regression coefficients

fitted values vector of predicted values for the given x

residuals vector of difference between actual and predicted values of y

Examples

1
2
3
4
5
6
7
v = lad(x = area$land, y = area$farm)
print(v)
plot(area$land, area$farm, main = "Farm Area vs Land Area", xlab = "Land Area (sq. miles)", ylab = "Farm Area (sq. miles)")
abline(reg = lm(area$farm ~ area$land), col = "red")
abline(reg = v, col = "blue")
legend("topleft", legend = c("lm()", "lad()"), col = c("red", "blue"), lty = c("solid", "solid"), cex = .9)
points(quantile(area$land), predict(v, quantile(area$land)), col = "green", pch = 16)

Addison-McGhee/existingToGitHub documentation built on Dec. 17, 2021, 7:39 a.m.