Description Usage Arguments Details Value Examples
Finds the values of beta0 and beta1 that minimize the sum of least absolute deviations for given vectors x and y.
1 |
x |
A numeric vector of observations |
y |
A numeric vector of observations |
... |
further arguments passed to or from other methods |
lad
minimizes the sum of least absolute deviations and finds the corresponding
estimates of beta0 and beta1.
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
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.