[R] problems using lqs()
ripley at stats.ox.ac.uk
Mon Feb 10 16:54:03 CET 2003
On Mon, 10 Feb 2003, Luca Scrucca wrote:
> I found a strange behaviour in the lqs function.
Why is this strange? It *is* covered in the Note on the help page: please
read it and the reference there.
> Suppose I have the following data:
> Now, instead of using the formula, I want to provide the design matrix and
> the response, then:
> X <- cbind(1, x1, x2)
> mod2 <- lqs.default(X, y, intercept=F, method="lms", nsamp="exact")
> x1 x2
> 35.4217275 0.4276641 -1.2834731
>  6 14 15
> The results are not the same (?!). Furthermore, if I create the design
> matrix without the column of 1's for the intercept:
Right, it's not the same algorithm.
> X <- cbind(x1, x2)
> mod3 <- lqs.default(X, y, intercept=T, method="lms", nsamp="exact")
> I get the same result I had using the formula (see mod1).
> This is confusing me!
That *is* the same algorithm.
> Another small problem appears if I re-fit the first model using the
> formula and asking to return the x-matrix and the response:
> lqs(y ~ x1 + x2, method="lms", nsamp="exact", x.ret=T, y.ret=T)
> Error in model.frame(formula, rownames, variables, varnames, extras,
> extranames, :
> variable lengths differ
> Does anyone know what's going on?
No, but R has debugging tools for you to find out ....
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help