Skip to contents

This function computes the *interquartile mean* of the x values. See the **Details** section below for further information.

Usage

IQM(x, i = NULL, na.rm = T)

Arguments

x

(named) numerical vector

i

(optional) numerical vector giving the position in x or character vector matching the names in x. If missing or i = NULL, the entire x is considered for the computation of the score

na.rm

unused argument, provided for consistency with other functions. NA values are always removed from x before computation

Value

A numerical value representing the computed measure. A default NA value is returned if the score can't be computed.

Details

The *interquartile mean* is a statistical measure of central tendency based on the truncated mean of the interquartile range. It is computed as:

$$IQM(x) = \frac{2}{n}\sum_{i=\frac{n}{4}+1}^{\frac{3n}{4}} x_{i}$$

where \(x_{i}\) is the \(i\)-th element of the ordered vector.

Like the median it is insensitive to outliers.

References

https://en.wikipedia.org/wiki/Interquartile_mean

Author

Alessandro Barberis

Examples

#Dataset size divisible by four
x = c(5,8,4,38,8,6,9,7,7,3,1,6)
IQM(x)#6.5
#> [1] 6.5

#Dataset size not divisible by four
x = c(1,2,3,4,5)
IQM(x = x)#3
#> [1] 3

x = c(1,3,5,7,9,11,13,15,17)
IQM(x)#9
#> [1] 9