Hypothesis Testing Skewness and/or Kurtosis in R

孤街醉人 提交于 2019-12-05 11:43:33

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
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!