InfluentialPoints.com
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

Below are 2 ways of doing this test.

Gives something like this:

> (df =k-1-1) # degrees of freedom [1] 2 > # 1) working from first principles: > (X2 =sum((of-efpois)^2/efpois)) # observed value of X2 [1] 49.66858 > 1-pchisq(X2,df) # p-value [1] 1.6391e-11 > # 2) using R's function > (X2=chisq.test(of,p=efpois/sum(efpois))$statistic[[1]]) [1] 49.66858 > # now do it with the right df > 1-pchisq(X2,df) [1] 1.6391e-11