lundi 16 mars 2020

Calculating the power of the four different normality tests and which test is the most powerful?

To compute the power of a normality test I should generate the data using a non-normal distribution, correct? So does anyone know which code to use for a t-distribution with degrees of freedom n = 30, 15, 8, 4 and sample sizes T=10,30,50,100,500.

It is useful to conduct the analysis to see which test is the most powerful, but how?

The four tests I'm doing are the following (here only for T=10):

sw10 <- shapiro.test(rnorm(10))
jb10_1 <- JarqueBeraTest(rnorm(10), robust = FALSE)
jb10_2 <- JarqueBeraTest(rnorm(10), robust = FALSE, method ="mc", N = 1000)
Lf10 <- LillieTest(rnorm(10))

My coding is different every time, I am trying to improve it every day, the method I found to work as well was the following:

Normality tests

Sequence to follow for each sample size to find columns

remove(reject1, reject2, reject3, reject4)
reject1 <- FALSE
reject2 <- FALSE
reject3 <- FALSE
reject4 <- FALSE
sample.size <- 500 #here I change the sample sizes resp. 10,30,50,100,500
x <- 0.01 #here I change the significance level resp. 10%, 5%, 1% 
for (i in 1:1000)
{
  simulation <- rnorm(sample.size)
  sw <- shapiro.test(simulation)
  jb1 <- JarqueBeraTest(simulation, robust=FALSE)
  jb2 <- JarqueBeraTest(simulation, robust=FALSE, method = "mc", N = 1000)
  Lf <- LillieTest(simulation)
  reject1 <- cbind(reject1, sw["p.value"]<x)
  reject2 <- cbind(reject2, jb1["p.value"]<x)
  reject3 <- cbind(reject3,jb2["p.value"]<x)
  reject4 <- cbind(reject4, Lf["p.value"]<x)
}

Best regards




Aucun commentaire:

Enregistrer un commentaire