Re: [R] least median squares

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 22 Oct 2006 - 05:09:37 GMT

Try this using builtin data set BOD:

medsq <- function(p, DF) median((p[1] + p[2] * DF[[1]] - DF[[2]])^2) init <- coef(lm(demand ~ Time, BOD))
optim(init, medsq, DF = BOD)

library(MASS)
lqs(demand ~ Time, BOD, method = "lms")

On 10/22/06, Pedro Mardones <mardones.p@gmail.com> wrote:
> Does anyone can provide a code to implement least median squares
> regression in R (not using the lqs function or calling C functions)?
> Reason: teaching/learning purposes
> Thanks
> PM
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun Oct 22 15:15:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 22 Oct 2006 - 05:30:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.