From P.Dalgaard at biostat.ku.dk  Thu Oct 25 15:25:16 2007
From: P.Dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Thu, 25 Oct 2007 15:25:16 +0200
Subject: [Rd] meaning of "trim" in mean()
In-Reply-To: <39B6DDB9048D0F4DAD42CB26AAFF0AFA04D88433@usctmx1106.merck.com>
References: <39B6DDB9048D0F4DAD42CB26AAFF0AFA04D88433@usctmx1106.merck.com>
Message-ID: <4720993C.5030105@biostat.ku.dk>

Liaw, Andy wrote:
> (I see this in both R-patched r43124 and R-devel r43233.)
> In the Argument section of ?mean:
>
> trim     the fraction (0 to 0.5) of observations to be trimmed from each
> end of x before the mean is computed. Values outside that range are
> taken as the nearest endpoint.  
>
> Then in the Value section:
>
> If trim is non-zero, a symmetrically trimmed mean is computed with a
> fraction of trim observations deleted from each end before the mean is
> computed.
>
> The description in "trim" to me sounds like Windsorizing, rather than
> trimming.  Should that be edited?
>
>   
I think so:

> x <- sort(rnorm(10))
> mean(x,trim=.1)
[1] -0.6387413
> mean(x[2:9])
[1] -0.6387413
> mean(x[c(2,2:9,9)]) # Winsorizing
[1] -0.6204222

So yes, it is trimming, not Winsorizing, and the last sentence in the
description of "trim" is misleading and should be, well..., trimmed.

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



[Rd] meaning of "trim" in mean()
Peter Dalgaard