Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

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

Note:

Example:
; read the geyser data
x = read("geyser")
y=x[,2]
x=x[,1]
; compute the estimate
b = l1line(x, y)
b

Result:
gives coefficient b0=34.73 and b1=10.417.
Example:
; 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)

Result:
n/a



(C) MD*TECH Method and Data Technologies, 05.02.2006