[R-SIG-Finance] how to winsorize data

Gabor Grothendieck ggrothendieck at gmail.com
Wed Sep 16 19:23:39 CEST 2009


Try this:

pmax(pmin(x, quantile(x, .95)), quantile(x, .05))

On Wed, Sep 16, 2009 at 12:24 PM, Geoffrey Smith <gps at asu.edu> wrote:
> Hello, is there any kind of function that can winsorize a vector of numeric
> data?  I realize that the function mean(x, trim=...) will calculate
> winsorized means, but I would like to winsorize the actual data.  That is, I
> would like to actually change the extreme values to the 95% and 5%
> percentile values.  Thank you.
>
> --
> Geoffrey Smith
> Visiting Assistant Professor
> Department of Finance
> W. P. Carey School of Business
> Arizona State University
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list