Hypothesis Testing Skewness and/or Kurtosis in R

Starbucks picture Starbucks · Jun 26, 2016 · Viewed 10.4k times · Source

How do I specifically test the null and alternative hypothesis of the skewness and/or Kurtosis of a variable in hypothesis testing? Would I have to use a formula in t.test?

    t.test(data$variable, y = Null)

Any help is appreciated. Thanks!

Answer

Hack-R picture Hack-R · Jun 26, 2016

You have many options. Two of the best ways to test skewness and kurtosis using the moments or e1071 package:

duration <- data$variable # I'm going to call it duration

library(moments)
kurtosis(duration)
skewness(duration)

library(e1071)                    
skewness(duration)  
kurtosis(duration) 

I should mention that skewness and kurtosis are almost always present (only in an absolutely perfectly normal distribution would it not be) and they are interpreted as more of a gradient. Small values are approximately normal and larger values mean it's from some other distribution like Weibull, etc, etc.

So, you normally don't "test" for it in the sense of getting a p-value, so much as you "measure" it and interpret the coefficients to see which distribution it most closely represents. Having said that, if you wanted to you could test for it by using Galton's measures instead of Pearson's, then testing for siginficant difference from zero. But I don't think that would be really helpful as almost all empirical data would have some significant skewness and kurtosis, thus it's really just a matter of how much (i.e. is it enough to make the data look more like another distribution or is the data still closest to the normal distribution).

In case you want to use Galton's measures you can either find a prepacked implementation, I believe moments provides it, or do a custom function like this:

galtonskew.proc <- function(x){
  #
  #  Compute Galton's skewness measure for x
  #  NOTE: this procedure assumes no x values are missing
  #
  quarts <- as.numeric(quantile(x, probs = c(0.25, 0.5, 0.75)))
  num <- quarts[1] + quarts[3] - 2*quarts[2]
  denom <- quarts[3] - quarts[1]
  gskew <- num/denom
  gskew
}