I was trying to simulate the Central Limit Theorem in R. Unfortunately, even in large samples (e.g., 80), the Anderson–Darling test could not recognize normality. Therefore, I wrote the following code to see when the p-values become large enough so that the null hypothesis is not rejected.
The results were quite peculiar...
Firstly, it seems that the ability to reject the null hypothesis is rare.
Secondly, there appears to be periodicity in the p-values that are not significant. This periodicity persists even when I remove or modify set.seed(i+n_s*j)
.
Why does this happen?
This is my code:
library(nortest)
# Number of experiments for recording p-values
n_e <- 70
# Creating a list for the p-values
a_d <- rep(0, n_e)
# Number of samples to be examined
n_s <- 1000
# Size of each sample
s_s <- 30:(30+n_e-1)
for (j in 1:n_e){
# Creating a list for sample means
s_m <- rep(0, n_s)
for (i in 1:n_s) {
# Specifying the sample distribution
set.seed(i+n_s*j)
r_n <- rexp(s_s[1], 8)
# Sample mean
m <- mean(r_n)
# Populating the list with sample means
s_m[i] <- m
}
# Populating the list with p-values
a_d[j] <- ad.test(s_m)$p.value
}
plot(s_s, a_d)
boxplot(a_d)