Question
If data is truly normal, it should have a skewness value of 0 and a kurtosis value of 3. Write an R function that conducts
If data is truly normal, it should have a skewness value of 0 and a kurtosis value of 3. Write an R function that conducts a normality test as follows: it takes as input a data set, calculates a bootstrap confidence interval for the skewness, calculates a bootstrap confidence interval for the kurtosis, then sees if 0 is in the skewness interval and 3 is in the kurtosis interval. If so, your routine prints that the data is normally distributed, otherwise your routine should print that the data is not normally distributed. Test your routine on random data from normal (rnorm), uniform (runif), and exponential (rexp) , with sample sizes of n=10,30,70 and 100. (R programming)
Here is my coding, I don't why it doesn't return correct answer, please help!! Thank you
```{r} library(moments)
mynormtest = function(x){ CIskew <- quantile(replicate(10000, skewness(x)), c(0.025, .975),names=FALSE) CIkur <- quantile(replicate(10000, kurtosis(x)), c(0.025, .975),names=FALSE) if(( CIskew[1]<=0 & CIskew[2]>=0) & (CIkur[1]<= 3 & CIkur[2]>=3)) { return('The data is normally distributed') } else { return('the data is not normally distributed') } } mynormtest(rnorm(10000)) mynormtest(rnorm(10)) mynormtest(rnorm(30)) mynormtest(rnorm(70)) mynormtest(rnorm(100)) mynormtest(runif(10)) mynormtest(runif(30)) mynormtest(runif(70)) mynormtest(runif(100)) mynormtest(rexp(10)) mynormtest(rexp(30)) mynormtest(rexp(70)) mynormtest(rexp(100))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started