13 Measures of Variability
13.0.1 Variability of Nominal Variables
For most purposes, the visual inspection of a frequency distribution table or bar plot is all that is needed to understand a nominal variable’s variability. I have never needed a statistic that measures the variability of a nominal variable, but if you need one, there are many from which to choose. For example, Wilcox (1973) presented this analog to variance for nominal variables:
\text{VA} = 1-\frac{1}{n^2}\frac{k}{k-1}\sum_{i=1}^k\left(f_i-\frac{n}{k}\right)^2
The qualvar package (Gombin, 2018) can compute the primary indices of qualitative variation presented by Wilcox.
library(qualvar)
# Frequencies
frequencies = c(A = 60, B = 10, C = 25, D = 5)
# VA
VA(frequencies)[1] 0.7533333
In all of these indices of qualitative variation, the lowest value is 0 when every data point belongs to the same category (See Figure 13.1, left panel). Also, the maximum value is 1 when the data points are equally distributed across categories (See Figure 13.1, right panel).
13.0.2 Interquartile Range
As with nominal variables, a bar plot or frequency distribution table can tell you most of what you want to know about the variability of an ordinal variable. If you need a quantitative measure of how much an ordinal variable varies, you have many options. The most important of these is the interquartile range.
When median is a good choice for our central tendency measure, the interquartile range is usually a good choice for our variability measure. Whereas the median is the category that contains the 50th percentile in a distribution, the interquartile range is the distance between the categories that contain the 25th and 75th percentile. That is, it is the range of the 50 percent of data in the middle of the distribution. For example, in Figure 13.2, the shaded region is the space between the 25th and 75th percentiles in a normal distribution. The IQR is the width of the shaded region, about 20.2.
In ordinal data, there is no distance between categories, thus we cannot report the interquartile range per se. However, we can report the categories that contain the 25th and 75th percentiles. In Figure 13.3, the interquartile range has its lower bound at Disagree and its upper bound at Slightly Agree.”
The median and the interquartile range are displayed in box and whiskers plots like Figure 13.4. The height of the box is the interquartile range, and the horizontal line is the median. The top “whisker” extends no higher than 1.5 × IQR above the 75th percentile. The bottom “whisker” extends no lower than 1.5 × IQR below the 25th percentile. Any data points outside the whiskers can be considered outliers.
13.0.3 Variance
A deviation is computed by subtracting a score from its mean:
X-\mu
We would like to know the typical size of the deviation X-\mu. To do so, it might seem intuitively correct to take the average (i.e., expected value) of the deviation, but this quantity is always 0:
\begin{aligned} \mathcal{E}(X-\mu)&=\mathcal{E}(X)-\mathcal{E}(\mu)\\ &=\mu-\mu\\ &=0 \end{aligned}
Because the average deviation is always 0, it has no utility as a measure of variability. It would be reasonable to take the average absolute value of the deviations, but absolute values often cause algebraic difficulties later when we want to use them to derive other statistics. A more mathematically tractable solution is to make each deviation positive by squaring them.
Variance \left(\sigma^2\right) is the expected value of squared deviations from the mean \left(\mu\right):
\sigma^2=\mathcal{E}\!\left(\left(X-\mu\right)^2\right) \tag{13.1}
If all elements of a population with mean \mu are known, the population variance is calculated like so:
\sigma^2=\frac{\sum_i^n{\left(x_i-\mu\right)^2}}{n}
Notice that the population variance’s calculation requires knowing the precise value of the population mean. Most of the time, we need to estimate the population mean \mu using a sample mean m. A sample variance \left(s^2\right) for a sample size n can be calculated like so:
s^2=\frac{\sum_i^n{\left(x_i-m\right)^2}}{n-1}
Image Credits
Unlike with the population variance, we do not divide by the sample size n to calculate the sample variance. If we divided by n, the sample variance would be negatively biased (i.e., it is likely to underestimate the population variance). In what is known as Bessel’s correction (i.e, dividing by n-1 instead of by n), we get an unbiased estimate of the variance. Is it merely coincidence that dividing by n-1 happens to be the right amount of correction? Why a nice friendly integer like 1 and not some intimidating unrounded decimal like 1.2101274? A hint is that we had to calculated the sample mean before calculating the sample variance. This sample mean puts a constraint on how freely the numbers in the sample can vary.
Variance is rarely used for descriptive purposes because it is a squared quantity with no direct connection to the width of the distribution it describes. We mainly use variance as a stepping stone to compute other descriptive statistics (e.g., standard deviations and correlation coefficients) and as an essential ingredient in inferential statistics (e.g., analysis of variance, multiple regression, and structural equation modeling). However, Figure 13.6 attempts a visualization of what variance represents. Along the X-axis, the values of a normally distributed variable X are plotted as points. The Y-axis represents the deviations of variable X from \mu, the mean of X. For each value of X, we can create a square with sides as long as the deviations from \mu. The red squares have a positive deviation and the blue squares have a negative deviation. The darkness of the color represents the magnitude of the deviation. The black square has an area equal to the average area of all the squares. Its sides have a length equal to the standard deviation, the square root of variance.
The values of variable X are plotted with the deviations of X. Each square is a deviation from the mean of X. Darker squares have larger deviations. The area of the thick black square is the variance—the average size of the squared deviations.
13.0.4 Standard Deviation
The standard deviation is by far the most common measure of variability. The standard deviation \sigma is the square root of the variance \sigma^2.
\begin{aligned} \sigma&=\sqrt{\sigma^2}=\sqrt{\frac{\sum_i^n{\left(x_i-\mu\right)^2}}{n}}\\ s&=\sqrt{s^2}=\sqrt{\frac{\sum_i^n{\left(x_i-m\right)^2}}{n-1}} \end{aligned}
Although it is not an arithmetic average of the deviations, it can be thought of as representing the typical size of the deviations. Technically, it is the square root of the average squared deviation.
In a normal distribution, the standard deviation is the distance from the mean to the two inflection points in the probability density curve (see Figure 13.7).
13.0.5 Average Absolute Deviations
Average absolute deviations summarize the absolution values of deviations from a central tendency measure. There are many kinds of average absolute deviations, depending which central tendency each value deviates from and then which measure of central tendency summarizes the absolute deviations. With three central tendency measures, we can imagine nine different “average” absolute deviations:
\text{The}~\begin{bmatrix}mean\\ median\\ modal\end{bmatrix}~\text{absolute deviation around the}~\begin{bmatrix}mean\\ median\\ mode\end{bmatrix}.
That said, two of these average absolute values are used more than the others: the median deviation around the median and mean deviation around the mean. One struggles to imagine what uses one might have for the others (e.g, the modal absolute deviation around the median or the mean absolute deviation around the mode).
13.0.5.1 Median Absolute Deviation (around the Median)
Suppose that we have a random variable X, which has a median of \tilde{X}. The median absolute deviation (MAD) is the median of the absolute values of the deviations from the median:
\text{Median Absolute Deviation (around the Median)}=\mathrm{median}\left(\left|X-\tilde{X}\right|\right)
A primary advantage of the MAD over the standard deviation is that it is robust to the presence of outliers. For symmetric distributions, the MAD is half the distance of the interquartile range.
13.0.5.2 Mean Absolute Deviation (around the Mean)
If the mean of random variable X is \mu_X, then:
\text{Mean Absolute Deviation (around the Mean)}=\mathcal{E}\left(\left|X-\mu_X\right|\right)
For normal distributions, the mean absolute deviation around the mean is smaller than the standard deviation by a factor of \sqrt{2\pi^{-1}}\approx 0.7979 (Geary, 1935).
The primary advantage of this statistic is that it is easy to explain to people with no statistical training. In a straightforward manner, it tells us how far each score is from the mean, on average. All else equal, when statisticians need to ensure that values are positive, they prefer to square values (as with variance) instead of taking absolute values. The absolute value often makes equations harder to manipulate algebraically and differentiate with calculus.
13.1 Skewness
(Unfinished)
Skewness refers to how lopsided the a distribution is. Skewness can range from negative to positive infinity. When a distribution has more extreme values on the upper end of its distribution (i.e., has a long right tail), it is positively skewed. When a distribution has more extreme values on the lower end of its distribution (i.e., has a long left tail), it is negatively skewed. A perfectly symmetrical distribution has a skewness of 0.
There are many alternate types of skewness, each with their own formulas. The most commonly used definition has a simple formula when calculating population skewness: the average of cubed z-scores.
\mathcal{E}\left(z^3\right)=\mathcal{E}\left(\left(\frac{x-\mu}{\sigma}\right)^3\right)
There are a variety of sample skewness estimators, but the default in R’ e1071 package is:
\mathcal{E}\left(z^3\right)=\mathcal{E}\left(\left(\frac{x-m}{s}\right)^3\right)
Where m and s are the sample mean and sample standard deviation, respectively.
Warning in mean.default(x): argument is not numeric or logical: returning NA
Warning in Ops.factor(left, right): '-' not meaningful for factors
[1] NA
13.2 Kurtosis
(Unfinished)
14 Moments, Cumulants, and Descriptive Statistics
We can define random variables in terms of their probability mass/density functions. We can also define them in terms of their moments and cumulants.
14.1 Raw Moments
The first raw moment \mu'_1 of a random variable X is its expected value:
\mu'_1=\mathcal{E}(X)=\mu_X
The second raw moment \mu'_2 is the expected value of X^2:
\mu'_2=\mathcal{E}(X^2)
The nth raw moment \mu'_n is the expected value of X^n:
\mu'_n=\mathcal{E}(X^n)
14.2 Central Moments
The first raw moment, the mean, has obvious significance and is easy to understand. The remaining raw moments do not lend themselves to easy interpretation. We would like to understand the higher moments after accounting for the lower moments. For this reason, we can discuss central moments, which are like raw moments after subtracting mean.
One can evaluate a moment “about” a constant c like so:1
1 Alternately, we can say that this is the nth moment referred to c.
\text{The }n\text{th moment of }X\text{ about }c=\mathcal{E}\left(\left(X-c\right)^n\right)
A central moment \mu_n is a moment about the mean (i.e., the first raw moment):
\mu_n=\mathcal{E}\left(\left(X-\mu_X\right)^n\right)
The first central moment \mu_1 is not very interesting, because it always equals 0:
\begin{aligned}\mu_1&=\mathcal{E}\left(\left(X-\mu_X\right)^1\right)\\ &=\mathcal{E}\left(\left(X-\mu_X\right)\right)\\ &=\mathcal{E}\left(X\right)-\mathcal{E}\left(\mu_X\right)\\ &=\mu_X-\mu_X\\ &=0 \end{aligned}
Of note, the second central moment \mu_2 is the variance:
\mu_2=\mathcal{E}\left(\left(X-\mu_X\right)^2\right)=\sigma_X^2
14.3 Standardized Moments
A standardized moment2 is the raw moment of a variable after it has been “standardized” (i.e., converted to a z-score):
2 Standardized moments are also called normalized central moments.
Standardizing a variable by converting it to z-score is accomplished like so: z=\frac{X-\mu_X}{\sigma_X}
\text{The }n\text{th standardized moment} = \mathcal{E}\left(\left(\frac{X-\mu_X}{\sigma_X}\right)^n\right)=\frac{\mu_n}{\sigma^n}
The first two standardized moments have little use because they are always the same for every variable. The first standardized moment is the expected value of a z-score, which is always 0.
\mathcal{E}\left(\left(\frac{X-\mu_X}{\sigma_X}\right)^1\right)=\mathcal{E}\left(\frac{X}{\sigma_X}\right)-\mathcal{E}\left(\frac{\mu_X}{\sigma_X}\right)=\frac{\mu_X}{\sigma_X}-\frac{\mu_X}{\sigma_X} = 0 The second standardized moment is the expected value of a z-score squared, which is always 1.
\mathcal{E}\left(\left(\frac{X-\mu_X}{\sigma_X}\right)^2\right)=\frac{\mathcal{E}\left(\left(X-\mu_X\right)^2\right)}{\sigma_X^2} =\frac{\sigma_X^2}{\sigma_X^2}= 1
The third standardized moment is the expected value of a z-score cubed, which is one of several ways to define skewness.
The idea that skewness is the third standardized moment (i.e., the expected value of the z-score cubed) allows for an interesting interpretation of skewness. To begin, the z-score by itself is a measure of the overall level of the score. The z-score squared is a measure of variability. Thus, skewness can be seen as the relationship between deviation and variability.
\text{Skewness}=\mathcal{E}\left(z^3\right) = \mathcal{E}\left(\underbrace{z}_{\text{Level}}\cdot \underbrace{z^2}_{\text{Variability}}\right)
Thus a positively skewed variable can be described having a tendency to be become more variable (more sparse) as its value increases.
The fourth standardized moment is the expected value of the z-score raised to the fourth power. Conceptually this quantity represents the relationship between the extremity of the score and the variability of the score. When the fourth standardized moment is large, it means that scores become more variable as they become extreme at both ends of the distribution. That is, both tails of the distribution are thick, meaning that when there are outliers, they will be more extreme. When the fourth standardized moment is small, it means that scores become less variable at the extremes. In this case, the tails of the distribution will be thin such that outliers will be less extreme.
\mathcal{E}\left(\left(\frac{X-\mu}{\sigma}\right)^4\right)=\mathcal{E}\left(z^4\right)=\mathcal{E}\left(\underbrace{z^2}_{\text{Extremity}}\cdot \underbrace{z^2}_{\text{Variability}}\right)
The kurtosis statistic is the fourth standardized moment minus three. Like the fourth standardized moment, it is a measure of the thickness of a distributions tails.
\text{Kurtosis}=\mathcal{E}\left(\left(\frac{X-\mu}{\sigma}\right)^4\right)-3
Because the normal distribution has a fourth standardized moment of 3, its kurtosis is 0. Thus, kurtosis can be seen as a measure of how thick the tails of the distribution are compared to the tail thickness of the normal distribution. Kurtosis has no upper bound, but it does have a lower bound. The Bernoulli distribution with probability of .5 is either 0 or 1 with equal probability. This distribution has, essentially, no tails at all. The variability at its extremes is none whatsoever. The kurtosis of this distribution is −2, which is the lowest possible value this statistic can take.