Skip to content

robust regression

5 messages · Rafael Bertola, Brian Ripley, Martin Maechler +1 more

#
Is there a command in R that make the same regression like l1fit in
S-plus?
#
You can use the quantreg package.

However, neither l1fit nor that do `robust regression', so you need to 
think more carefully about what you really want.  There are almost always 
better alternatives than L1 fits.
On Wed, 25 Jun 2003, Rafael Bertola wrote:

            

  
    
#

        
BDR> On Wed, 25 Jun 2003, Rafael Bertola wrote:
>> Is there a command in R that make the same regression
    >> like l1fit in S-plus?

    BDR> You can use the quantreg package.  

This is an quite-FAQ, really.  Maybe we need a list of "quite
frequently asked questions" or rather extend the FAQ?

Specifically, I wonder if it wasn't worth to add something like
the following to the quantreg package

l1fit <- function(x,y, intercept = TRUE) 
{
      warning("l1fit() in R is just a wrapper to rq().  Use that instead!")
      if(intercept)  rq(y ~ x, tau = 0.5)
      else  rq(y ~ x - 1, tau = 0.5)
}

(and an \alias{l1fit} to the rq.Rd help page)
So at least all who have quantreg installed will find l1fit


    BDR> However, neither
    BDR> l1fit nor that do `robust regression', so you need to
    BDR> think more carefully about what you really want.  There
    BDR> are almost always better alternatives than L1 fits.

I "fervently" agree.

Most notably, the
     rlm()    {Robust Linear Models}

in package MASS (Venables and Ripley)!
Martin
#
On Thu, 26 Jun 2003, Martin Maechler wrote:

            
I'd be happy to add such a function, but I rather doubt that it would reduce
the incidence of such questions.  Putting a function like Martin's in base with the
warning replaced by require(quantreg) might be more effective.
Of course, in Splus lifit returns only coefficients and residuals without
any attempt to do any inference, so one might also want to further restrict the output
of rq() for full compatibility.
Without wanting to get involved in any religious wars about robustness, I would simply
observe that Brian's comment applies to life in general: there are almost
always better alternatives to  [any specified procedure].  So until someone
produces a very convincing argument for the universal applicability of one particular
procedure for robust regression, I would plea for "letting 100 flowers bloom
and 100 schools of thought contend."

url:	www.econ.uiuc.edu	Roger Koenker		Dept. of Economics UCL,
email	rkoenker at uiuc.edu	Department of Economics Drayton House,
vox: 	217-333-4558		University of Illinois	30 Gordon St,
fax:   	217-244-6678		Champaign, IL 61820	London,WC1H 0AX, UK
#

        
Roger> On Thu, 26 Jun 2003, Martin Maechler wrote:
>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk>
     >>>>>     on Wed, 25 Jun 2003 20:06:49 +0100 (BST) writes:
BDR> On Wed, 25 Jun 2003, Rafael Bertola wrote:
>> Is there a command in R that make the same regression
       >> like l1fit in S-plus?

      BDR> You can use the quantreg package.
     MM>
     MM> This is an quite-FAQ, really.  Maybe we need a list of
     MM> "quite frequently asked questions" or rather extend the FAQ?
     MM>
     MM> Specifically, I wonder if it wasn't worth to add something
     MM> like the following to the quantreg package
     MM>
     MM>l1fit <- function(x,y, intercept = TRUE)
     MM> {
     MM>   warning("l1fit() in R is just a wrapper to rq().  Use that instead!")
     MM>   if(intercept)  rq(y ~ x, tau = 0.5)
     MM>   else  rq(y ~ x - 1, tau = 0.5)
     MM> }
     MM>
     MM> (and an \alias{l1fit} to the rq.Rd help page) So at least
     MM> all who have quantreg installed will find l1fit

    Roger> I'd be happy to add such a function, but I rather
    Roger> doubt that it would reduce the incidence of such
    Roger> questions.  Putting a function like Martin's in base
    Roger> with the warning replaced by require(quantreg) might
    Roger> be more effective.

I agree this would be even more effective.
I'm not sure the R core team would on doing this.
require()ing packages {apart from base+recommended} is not liked
for other good reasons.

    Roger> Of course, in Splus l1fit returns
    Roger> only coefficients and residuals without any attempt
    Roger> to do any inference, so one might also want to
    Roger> further restrict the output of rq() for full
    Roger> compatibility.

I wouldn't want to do this.  l1fit() is really from the days of
"S 2", i.e. no formulae, no (S3) classes/methods.
Telling users to upgrade their code from using l1fit() to using
rq() seems better to me.

OTOH, if you (or anyone else would provide code (*.R) and
documentation (*.Rd) for such an l1fit(), we'd probably accept
it, for the "modreg" package probably (rather than "base").


      BDR> However, neither l1fit nor that do `robust regression',
      BDR> so you need to think more carefully about what you
      BDR> really want.  There are almost always better
      BDR> alternatives than L1 fits.

     MM> I "fervently" agree.
     MM>
     MM> Most notably, the
     MM>     rlm() {Robust Linear Models}
     MM>
     MM> in package MASS (Venables and Ripley)!

    Roger> Without wanting to get involved in any religious wars
    Roger> about robustness, I would simply observe that Brian's
    Roger> comment applies to life in general: there are almost
    Roger> always better alternatives to [any specified
    Roger> procedure].  So until someone produces a very
    Roger> convincing argument for the universal applicability
    Roger> of one particular procedure for robust regression, I
    Roger> would plea for "letting 100 flowers bloom and 100
    Roger> schools of thought contend."

(since we don't want to get into any religious wars .... I keep shut)

Martin