Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hypothesis Testing Skewness and/or Kurtosis in R

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!

like image 847
Starbucks Avatar asked Jun 26 '16 02:06

Starbucks


People also ask

How do you test for skewness and kurtosis in R?

We use the skewness function in R with the argument type=2 to obtain skewness based on the moments formula and the kurtosis function with the argument type=2 to obtain kurtosis based on the moments formula. Here we can see that the skewness for the Growth variable is 1.59, indicating a positively skewed distribution.

How do you test for kurtosis in R?

Base R does not contain a function that will allow you to calculate kurtosis in R. We will need to use the package “moments” to get the required function. The kurtosis measure describes the tail of a distribution – how similar are the outlying values of the distribution to the standard normal distribution?

Which test use skewness and kurtosis to check for normality?

To overcome this problem, a z-test is applied for normality test using skewness and kurtosis. A Z score could be obtained by dividing the skewness values or excess kurtosis value by their standard errors. For small sample size (n <50), z value ± 1.96 are sufficient to establish normality of the data.


1 Answers

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
}
like image 101
Hack-R Avatar answered Oct 29 '22 13:10

Hack-R