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
(G =2*sum(of*log(of/ef))) # observed value of G
(df =k-1-2) # degrees of freedom
1-pchisq(G,df) # P-value
Gives something like this:
Except where otherwise specified, all text and images on this page are copyright InfluentialPoints, all rights reserved. Images not copyright InfluentialPoints credit their source on web-pages attached via hypertext links from those images.