christopher compeau
2009-Nov-05 23:10 UTC
[R] partitioning chi-square statistic (g squared)
hi all - is there a package or library that contains a function for partitioning the chi-square statistic of an I X J contingency table into its respective independent parts? i looked around for this, but i didn't find anything. perhaps there's another name for this sort of analysis? i know it as "g-squared". thanks, chris. [[alternative HTML version deleted]]
christopher compeau wrote:> hi all - > > is there a package or library that contains a function for partitioning the > chi-square statistic of an I X J contingency table into its respective > independent parts?Do you mean the chisquare contribution from each cell in the table? If so, just square the 'residuals' component of the output: x <- sample(5:20, 12, replace=TRUE) m <- matrix(x, nr=3) chtest <- chisq.test(m) residuals(chtest)^2 See the 'Value' section of ?chisq.test. If you mean the "G-test" (Wikipedia), you can extract the 'observed' and 'expected' components of the chisq.test output to calculate G. Use the chisquare distribution to obtain a p-value. -Peter Ehlers> > i looked around for this, but i didn't find anything. perhaps there's > another name for this sort of analysis? i know it as "g-squared". > > thanks, > chris. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >