I'm running a chi-squared test in R, for a 2x2 contingency table. When I simulate the p-values using a Monte Carlo simulation, it outputs the degrees freedom for the test as 'NA' (but not when I run the test without the simulation).
Why does that happen, and what should I report for the df in this case?
The code:
cont_table <- matrix(
c(0, 1000, 20, 1020),
nrow=2, ncol=2
)
print(chisq.test(cont_table, simulate.p.value = FALSE, correct = FALSE))
print(chisq.test(cont_table, simulate.p.value = TRUE, correct = FALSE))
The output:
> print(chisq.test(cont_table, simulate.p.value = FALSE, correct = FALSE))
Pearson's Chi-squared test
data: cont_table
X-squared = 19.421, df = 1, p-value = 1.048e-05
> print(chisq.test(cont_table, simulate.p.value = TRUE, correct = FALSE))
Pearson's Chi-squared test with simulated p-value (based on 2000 replicates)
data: cont_table
X-squared = 19.421, df = NA, p-value = 0.0004998