The sample median is an example of what is called atrimmed mean; it trims all but one or two values. The sample mean represents the other extreme: zero trimming.
No specific amount of trimming is always best, but for various reasons, 20% trimming is often a good choice. This means that the smallest 20% and the largest 20% are trimmed and the average of the remaining data is computed.
In symbols, first compute 0.2n, round down to the nearest integer, call this result g, in which case the 20% trimmed mean is given by
\overline{X} = \frac{1}{n - 2g} (X_{(g+1)} + \cdots + X_{(n-g)})
1 | trimmed_mean(x, trim = 0.2, na.rm = FALSE)
|
x |
An R object. Currently there are methods for
numeric/logical vectors and date,
date-time and time interval objects. Complex vectors
are allowed for |
trim |
the fraction (0 to 0.5) of observations to be
trimmed from each end of |
na.rm |
a logical value indicating whether |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.