Biology, images, analysis, design...
Use/Abuse Principles How To Related
"It has long been an axiom of mine that the little things are infinitely the most important" (Sherlock Holmes)

Search this site



Pearson's chi square goodness of fit test - using R

Pearson's chi square goodness of fit test

The following code assumes the expected frequencies were not estimated, but predicted a priori. Notice that, to avoid rounding errors, we calculate the total frequency as sum(x) rather than sum(y).

Gives something like this:

Chi-squared test for given probabilities data: x X-squared = 293.4632, df = 5, p-value < 2.2e-16 Warning message: Chi-squared approximation may be incorrect in: chisq.test(x, p = y/sum(x))