Posts for the month of June 2014

R tip: G-Test G-Statistic G^2 likelihood ratio, or whatever else you might want to call it.

When analyzing categorical data, sometimes Chi-Square just isn't the right distribution for testing goodness-of-fit or testing Independence. So many people recommend a G test instead.  http://www.biostathandbook.com/chiind.html

Being a user of  R, obviously I'd like to also run this test along with my other tests. A little searching the web, and answers are littered with, "R doesn't have g-test built in, here's code to do it yourself..." Which is 1/2 true, unlike the chisq.test the base R does not appear to have a g-test. I'd rather leave coding of standard statistics to people who really know the ins and outs of the formulas and have a good way to verify the answer.

So, a few hours later I find  Deducer has  likelihood.test So we're all good, right?

Well then when I got significant results I started looking for Post-hoc tests. In doing so it turns out that the following also do G-tests as part of their Measures of Association tests (typically used as post-hoc tests):

So there, base R doesn't have it, but at least 3 packages do so people don't need to keep re-writing it.

FYI  http://www.rdocumentation.org/ is awesome if you haven't seen it yet.