Skip to content
Prev 173323 / 398502 Next

chisq.test: decreasing p-value

soeren.vogel at eawag.ch wrote:
This is a combination of user error and an infelicity in chisq.test.

You are sapply'ing over a list with one element, so essentially you are
doing

chisq.test(v, p=c(rep.int(40, 6)),
 rescale.p=T, simulate.p.value=T, B=r)$p.value

Now B is supposed to be a single integer, so the above cannot be
expected to do anything sensible, but you might have hoped for an error
message. Instead, it seems that you get the result of r[1] replications
divided by r+1:
B=r)$p.value
[1] 0.636363636 0.069306931 0.013972056 0.006993007 0.003498251 0.001399720
[1] 0.636363636 0.069306931 0.013972056 0.006993007 0.003498251 0.001399720

What you really wanted was
rescale.p=T, simulate.p.value=T, B=x)$p.value })
[1] 0.9090909 0.8118812 0.7964072 0.7672328 0.8025987 0.7932414