Group: | Statistical Data Analysis |
Topic: | Nonparametric Methods |
See also: | sker isoreg rmed lowess |
Function: | l1line | |
Description: | l1line computes the least absolute deviation line from scatterplot data. It gives the estimate b0 and b1 that minimizes sum_i=1,n |y_i - b0 - b1 x_i |. |
Usage: | b = l1line (x, y) | |
Input: | ||
x | n x 1 vector | |
y | n x 1 vector | |
Output: | ||
b | 2 x 1 vector |
; read the geyser data x = read("geyser") y=x[,2] x=x[,1] ; compute the estimate b = l1line(x, y) b
gives coefficient b0=34.73 and b1=10.417.
; compute the least square line yh =(matrix(rows(x))~x[,1])*b ; create a display for plotting d = createdisplay(1,1) ; show the data and the fitted line x = read("geyser") show(d, 1, 1, x~y, x~yh)
n/a