Re: [R] weighted m-estimator

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu 08 Dec 2005 - 20:29:04 EST

On Thu, 8 Dec 2005, Daniel Metzler wrote:

> Dear R listers,
>
> I'm trying use Huber's m-estimator on a dataset, which works fine so
> far.

Huber's M-estimator of what? Location, scale, regression, AR coefficients .... What software are you using to do so?

> In the next step I would like to assign a (frequency) weight to the
> observations.
> It seemed straight forward to me to replicate the rows according to
> their count variable.
>
> Unfortunately, a solution provided by jim holtman on Wed 19 Oct 2005
> in this list doesn't work for me:
>
> > y <- unlist(lapply(seq(nrow(x)), function(.row)rep(.row, x$count
> [.row])))
> # replicate the row numbers
> > y
> > result <- x[y,] # pick out the rows
> > result$count <- 1 # set the count to 1
> > result
>
> R keeps crashing. I presume because of 800,000 rows, which should be
> produced.

R should not `crash', but the posting guide does ask you not to use that word but give the exact messages received. Running out of memory is not a `crash'.

> Does a smarter solution exist for weighting the observations
> according to their frequency than manually replicating rows when
> using the huber function?

Yes. I have no idea what you are trying to do, but if it is regression, rlm in package MASS has case weights. (Location estimation is a special case of regression.)

Please do read the posting guide and try to give us the information needed to answer your question. In particular, do give credit if you are using a contributed package (including the recommended contributed package).

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
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
Received on Thu Dec 08 20:37:02 2005

This archive was generated by hypermail 2.1.8 : Thu 08 Dec 2005 - 23:36:26 EST