I found out that the chi square test in R may not be working. I don't know where I am doing it wrong.
1) test two similar distribution
# create a sequence from 0 to 1000, seperated by 10
x <- seq(0,1000,10)
# create two similar gaussian distribution
r1<- rnorm(x, 1000,100)
r2 <- rnorm(x, 1000,100)
# run the chi square test
chisq.test(r1,r2,simulate.p.value = TRUE)
The result is:
Pearson's Chi-squared test with simulated p-value (based on 2000 replicates)
data: r1 and r2
X-squared = 10100, df = NA, p-value = 0.0004998
2) Test two different distribution
# create two different gaussian distribution
r1<- rnorm(x, 500,100)
r2 <- rnorm(x, 1000,100)
# run the chi square test
chisq.test(r1,r2,simulate.p.value = TRUE)
Result:
Pearson's Chi-squared test with simulated p-value (based on 2000 replicates)
data: r1 and r2
X-squared = 10100, df = NA, p-value = 0.0004998
This suggests that whether the distributions I tested are different or not, the chi sq test will say that they are not the same.
The result is the same whether of not simulate.p.value
is TRUE
.