Last data update: 2014.03.03

R: Minimum absolute residual (L1) regression
l1fitR Documentation

Minimum absolute residual (L1) regression

Description

Performs an L1 regression on a matrix of explanatory variables and a vector of responses.

Usage

l1fit(x, y, intercept = TRUE, tolerance = 1e-07, print.it = TRUE)

Arguments

x

vector or matrix of explanatory variables. Each row corresponds to an observation and each column to a variable. The number of rows of x should equal the number of data values in y, and there should be fewer columns than rows. Missing values are not allowed.

y

numeric vector containing the response. Missing values are not allowed.

intercept

logical flag. If TRUE, an intercept term is included in the regression model.

tolerance

numerical value used to test for singularity in the regression.

print.it

logical flag. If TRUE, then warnings about non-unique solutions and rank deficiency are given.

Details

The Barrodale-Roberts algorithm, which is a specialized linear programming algorithm, is used.

Value

list defining the regression (compare with function lsfit).

coefficients

vector of coefficients.

residuals

residuals from the fit.

message

vector of one or two character strings stating whether a non-unique solution is possible, or if the x matrix was found to be rank deficient.

References

Barrodale, I., and Roberts, F.D.K. (1973). An improved algorithm for discrete L1 linear approximations. SIAM Journal of Numerical Analysis 10, 839-848.

Barrodale, I., and Roberts, F.D.K. (1974). Solution of an overdetermined system of equations in the L1 norm. Communications of the ACM 17, 319-320.

Bloomfield, P., and Steiger, W.L. (1983). Least Absolute Deviations: Theory, Applications, and Algorithms. Birkhauser, Boston, Mass.

Examples

l1fit(stack.x, stack.loss)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(L1pack)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/L1pack/l1fit.Rd_%03d_medium.png", width=480, height=480)
> ### Name: l1fit
> ### Title: Minimum absolute residual (L1) regression
> ### Aliases: l1fit
> ### Keywords: regression
> 
> ### ** Examples
> 
> l1fit(stack.x, stack.loss)
$coefficients
   Intercept     Air.Flow   Water.Temp   Acid.Conc. 
-39.68985367   0.83188403   0.57391310  -0.06086957 

$minimum
[1] 42.08116

$fitted.values
 [1] 36.939131 37.000000 31.571015 20.365218 19.217392 19.791305 20.000001
 [8] 20.000001 16.463769 14.020290 13.472464 12.959421 13.898551 13.802899
[15]  6.817392  7.000001  8.426088  8.000001  8.513044 13.382609 24.481160

$residuals
 [1]  5.0608706  0.0000000  5.4289861  7.6347828 -1.2173911 -1.7913042
 [7] -1.0000000  0.0000000 -1.4637681 -0.0202896  0.5275363  0.0405799
[13] -2.8985507 -1.8028984  1.1826082  0.0000000 -0.4260873  0.0000000
[19]  0.4869561  1.6173913 -9.4811592

$rank
[1] 4

$numIter
[1] 7

$info
[1] 1

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>