# Calculating the trimmed mean as an estimator

My book provides the following steps to calculate the $$100 \alpha$$ percent trimmed mean for a sample data of $$n$$ measurments:

1-Order the measurments.
2-Discard the smallest $$100\alpha$$ percent and the largest $$100\alpha$$ percent of the measurments.
3-Compute the arthimetic mean of the remaining measurments.

Could one explain these steps preferably with an example.

• The data are 51 3 4 1 2. Order them 1 2 3 4 51. The 20% trimmed mean ignores 1 and 51 and is the mean of 2 3 4, so 3. – Nick Cox Oct 23 '20 at 18:31
• Discarding an equal fraction in each tail is a common choice but not fundamental to the idea. There is literature on trimmed means with discarding in one tail only. – Nick Cox Oct 23 '20 at 18:32
• In your example, do we multiply $20 \%$ by $n = 5$ to know that we need to discard just one value from each side? @NickCox – Positron12 Oct 23 '20 at 18:34
• That's correct. – Nick Cox Oct 23 '20 at 18:41
• Alright thank you ! @NickCox should I delete the post? – Positron12 Oct 23 '20 at 18:42

Using R, to illustrate a 10% trimmed mean of a sample of size $$n = 20$$ from $$\mathsf{Pois}(\lambda = 30).$$

set.seed(2020)
x = rpois(20, 30)
mean(x)
[1] 30.75


The regular (untrimmed) sample mean is $$\bar X = 30.75.$$

x.sort = sort(x)
x.sort
[1] 21 23 24 26 27 28 28 30 30 30
[11] 31 31 32 32 32 33 34 36 37 50


10% of $$n = 20$$ is 2, so temporarily disregard the first two and the last 2 observations:

x.temp = x.sort[3:18]
x.temp
[1] 24 26 27 28 28 30 30 30 31 31
[11] 32 32 32 33 34 36


Take the mean of the remaining (central) sixteen observations.

mean(x.temp)
[1] 30.25


So the 10% trimmed mean of the sample x is $$30.25.$$

Finally, all in one step, with trim parameter:

mean(x, trim=.1)
[1] 30.25


However, the original sample x remains unchanged:

length(x)
[1] 20
mean(x)
[1] 30.75


Notes: (1) The 50% trimmed mean is the median:

median(x)
[1] 30.5
mean(x, trim=.5)
[1] 30.5


(2) Caution: If the 'trimming fraction' of the sample does not amount to an integer number of observations to ignore, then R will down-weight an extreme value at each end. [You should know that this happens, in case you get unexpected results. But trying to emulate the exact result by hand computation might be frustrating.]

mean(x, trim=.08);  mean(x, trim=.1)
[1] 30.22222
[1] 30.25