Search this site

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

mean=73.8; sd=19.4 of=c(7,6,15,26,38,43,32,68,69,105,127,121,94,97,85,34,25,21,13,1,17) k=length(of); n=sum(of) ub=c(seq(from=25,to=120,by=5),Inf) lb=c(-Inf,ub[-k]) ef=(pnorm(ub,mean,sd)-pnorm(lb,mean,sd))*n (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.