[R] problems using lqs()

Luca Scrucca luca at stat.unipg.it
Mon Feb 10 18:44:45 CET 2003


Many thanks to Kjetil Halvorsen for explaining me the reason I got
different results.
Regarding the second point, Both Kjetil and Brian Ripley suggest to go
through debugging and see what the reason for the message.
I'm not so expert to fully understand why, but I have found a patch that
makes the function works. It is based on the behaviour of the lm function.

The original function is:

lqs.formula <- function (formula, data, ..., method = c("lts", "lqs",
"lms", "S", "model.frame"), subset, na.action = na.fail, model = TRUE,
x.ret = FALSE, y.ret = FALSE, contrasts = NULL)
{
    method <- match.arg(method)
...
    if (x.ret)
        fit$x <- x
    if (y.ret)
        fit$y <- y
    fit
}

I only changed the name of the arguments (x.ret to x, y.ret to y) as in
lm():

lqs.formula <- function (formula, data, ..., method = c("lts", "lqs",
"lms", "S", "model.frame"), subset, na.action = na.fail, model = TRUE, x =
FALSE, y = FALSE, contrasts = NULL)
{
    ret.x <- x
    ret.y <- y
    method <- match.arg(method)
...
    if (ret.x)
        fit$x <- x
    if (ret.y)
        fit$y <- y
    fit
}

Note that we need also to replace the 'x' with something else in:

lqs <- function(what, ...) UseMethod("lqs")

Now

mod <- lqs(y ~ x1 + x2, x=T, y=T)

and mod$x and mod$y returns what expected. The x-matrix is without the
enventual column of 1's. Maybe we may want to add it if required.

I hope this may help to fix the problem.

Best,

Luca

+-----------------------------------------------------------------------+
| Dr. Luca Scrucca                                                      |
| Dipartimento di Scienze Statistiche      tel. +39 - 075 - 5855278     |
| Universita' degli Studi di Perugia       fax. +39 - 075 - 43242       |
| Via Pascoli - C.P. 1315 Succ. 1                                       |
| 06100 PERUGIA  (ITALY)                                                |
|                                                                       |
| E-mail:   luca at stat.unipg.it                                          |
| Web page: http://www.stat.unipg.it/luca                               |
+-----------------------------------------------------------------------+




More information about the R-help mailing list