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!
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.
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?
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.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With