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

G test


The R code below does a G-test from first principles. To obtain the code for a more general log-likelihood test function goto https://stat.ethz.ch/pipermail/r-help/2001-September/015290.html

Gives something like this:

> (G =2*sum(of*log(of/ef))) # observed value of G [1] 66.64209 > (df =k-1-2) # degrees of freedom [1] 18 > 1-pchisq(G,df) # P-value [1] 1.657333e-07