# Taming of the skew… Why are there so many skew functions?

I am hoping to have more insight on the four types of skew from this community.

The types I refer to are mentioned in the http://www.inside-r.org/packages/cran/e1071/docs/skewness help page.

The old method was not mentioned in the help page, but I include it nonetheless.

require(moments)
require(e1071)

x=rnorm(100)
n=length(x)
hist(x)

###############type=1
e1071::skewness(x,type=1)
sqrt(n) * sum((x-mean(x))^3)/(sum((x - mean(x))^2)^(3/2)) #from e1071::skewness source
m_r=function(x,r) {n=length(x); sum((x - mean(x))^r/n);} ##from e1071::skewness help
g_1=function(x) m_r(x,3)/m_r(x,2)^(3/2)
g_1(x) ##from e1071::skewness help
moments::skewness(x) ##from e1071::skewness help
(sum((x - mean(x))^3)/n)/(sum((x - mean(x))^2)/n)^(3/2) ##from moments::skewness code, exactly as skewness help page

###############type=2
e1071::skewness(x,type=2)
e1071::skewness(x,type=1) * sqrt(n * (n - 1))/(n - 2) #from e1071::skewness source
G_1=function(x) {n=length(x); g_1(x)*sqrt(n*(n-1))/(n-2);} #from e1071::help
G_1(x)
excel.skew=function(x) { n=length(x); return(n/((n-1)*(n-2))*sum(((x-mean(x))/sd(x))^3));}
excel.skew(x)

###############type=3
e1071::skewness(x,type=3)
e1071::skewness(x,type=1) * ((1 - 1/n))^(3/2) #from e1071::skewness source
b_1=function(x) {n=length(x); g_1(x)*((n-1)/n)^(3/2); }  #from e1071::skewness help page
b_1(x);
prof.skew=function(x) sum((x-mean(x))^3)/(length(x)*sd(x)^3);
prof.skew(x)

###############very old method that fails in weird cases
(3*mean(x)-median(x))/sd(x)
#I found this to fail on certain data sets as well...


Here is the paper that the author of e1071 refers to: http://onlinelibrary.wiley.com/doi/10.1111/1467-9884.00122/pdf Joanes and C. A. Gill (1998), Comparing measures of sample skewness and kurtosis.

From my reading of that paper, they suggest that type #3 has the least error.

Here are examples of the skewness from the above code:

e1071::skewness(x,type=1)
-0.1620332
e1071::skewness(x,type=2)
-0.1645113
e1071::skewness(x,type=3)
-0.1596088
#old type:
0.2694532


I also noticed that the author of e1071 wrote the skew function different from the notes in the help page. Notice the sqrt:

sqrt(n) * sum((x-mean(x))^3)/(sum((x - mean(x))^2)^(3/2)) #from e1071::skewness source

(sum((x - mean(x))^3)/n)/(sum((x - mean(x))^2)/n)^(3/2) #from moments and e1071 help page


Any ideas why the sqrt(n) is in the first equation? Which equation handles overflow/underflow better? Any other ideas why they are different (but produce the same results)?

• Your question mentions "the four types of skew" ... but then gives a link and launches into a bunch of code (which language you don't even mention). So people don't have to read a link to discover what you're asking, and for the benefit of the people who don't read R, and those who find reading code unhelpful in conveying understanding, it would help to define which four measures of skewness you mean before (or preferably instead of) a swathe of code. [When you say "the four", rather than say "these four", why do you think there are exactly four rather than five or seven or some other number?] – Glen_b -Reinstate Monica Jun 29 '15 at 0:34
• I've attempted to give some form of answer to the specific questions I could find in your post and addressed a number of issues along the way, but outside of that "hoping to have more insight" is too vague to respond to. Can you more clearly identify what things you want insight about? There are many questions on our site relating to skewness. – Glen_b -Reinstate Monica Jun 29 '15 at 4:56
• Thank you Glen, for your posts. I included R for illustrative purposes and to show the formulas. Also I do not know Latex. :( – Chris Jun 29 '15 at 13:54

## 1 Answer

Let's start with the one you describe as "an old method"; this is the second Pearson skewness, or median-skewness; in fact the moment-skewness and that are of broadly the same vintage (the median skewness is actually a bit younger since the moment skewness precedes Pearson's efforts).

A little discussion of some of the history can be found here; that post may also throw a little light on a couple of your other questions.

If you search our site using second Pearson skewness you'll hit quite a few posts that contain some discussion of the behavior of this measure.

It's not really any weirder than the moment skewness measures in my mind; they both sometimes do some odd things that don't match people's expectations of a skewness measure.

The usual form of $b_1$ is discussed in Wikipedia here; as it says, it's a method of moments estimator, and a natural thing to use given the population calculation in terms of standardized third moment.

If one uses $s_n$ for $s_{n-1}$ (i.e. without Bessel correction) you get the $g_1$ type you mention; either of those are what I'd call "method of moments". It's not clear to me there's much point trying to unbias the denominator since that doesn't necessarily unbias the ratio; it may make sense to do it so that the calculation matches what people might expect to do by hand.

However, there's a second (equivalent) way to define population skewness, in terms of cumulants (see the above Wikipedia link), and if for a sample skewness you used unbiased estimates of those, you get $G_1$.

[Note further that multiplying the numerator in $b_1$ by $\frac{n^2}{(n-1)(n-2)}$ unbiases it, so that can be another reason people look at that form. If one attempts to unbias both the third and second moment calculations, one obtains a slightly different factor in $n,(n-1)$ and $(n-2)$ coming out the front.]

All three of those are simply slightly different variations on third-moment skewness. In very large samples there's really no difference which you use. In smaller samples they all have slightly different biases and variance.

The forms discussed here don't exhaust the definitions of skewness (I've seen about a dozen, I think - the Wikipedia article lists quite a few, but even that doesn't cover the gamut), nor even the definitions related to third-moment skewness, of which I've seen more than the three you raise here.

Why are there many measures of skewness?

So (treating all those third-moment skewnesses as one for a moment) why so many different skewnesses? Partly it's because skewness as a notion is actually quite hard to pin down. It's a slippery thing you can't really pin down to a single number. As a result, all the definitions are less than adequate in some way, but nevertheless usually accord with our broad sense of what we think a skewness measure should do. People keep trying to come up with better definitions, but the old measures, like QWERTY keyboards, aren't going anywhere.

Why are there several measures of skewness based on the 3rd moment?

As for why so many third-moment skewnesses, that's simply because there's more than one way to turn a population-measure into a sample measure. We saw two routes based on moments and one based on cumulants. We could construct still more; we might for example try to get a (small-sample) unbiased measure under some distributional assumption, or a minimum-mean-square-error measure or some other such quantity.

You might find some of the posts on site relating to skewness enlightening; there are some that show examples of distributions which are not symmetric but have zero third moment skewness. There's some that show the Pearson median-skewness and the third moment skewness can have opposite signs.

Here are links to a few posts relating to skewness:

Does mean = median imply that a unimodal distribution is symmetric?

In left skewed data, what is the relationship between mean and median?

how to determine skewness from histogram with outliers?

In relation to your final question about the calculation of $b_1$:

$\sqrt{n} \cdot \frac{\sum{(x-\bar{x})^3}}{(\sum({x - \bar{x}})^2)^{3/2}}\qquad$ #from e1071::skewness source

$\frac{\sum(x - \bar{x})^3/n}{(\sum(x - \bar{x})^2/n)^{3/2}}\qquad$ #from moments and e1071 help page

The two forms are algebraically identical; the second is clearly written in the form "third moment on second moment to power $\frac32$, while the first just cancels out terms in $n$ and brings the leftovers out the front. I don't think it was done for reasons of avoiding overflow/underflow; I imagine it was done because it was thought to be a little faster. [If overflow or underflow are a concern one would probably arrange the calculations differently.]