I am conducting the G test in both R and Python and I am getting different results, the results I am getting in Python being wrong. Somehow I am misapplying the formula.
The data are:
prfs
Sex F M
Pref
B 29 17
A 2 12
The R Code is :
library(RVAideMemoire)
G.test(prfs)
G-test
data: prfs
G = 11.025, df = 1, p-value = 0.0008989
The Python code is :
stats.power_divergence(prfs, lambda_ = 'log-likelihood')
Power_divergenceResult(statistic=array([28.14366538, 0.86639163]), pvalue=array([1.12635722e-07, 3.51956200e-01]))
stats.power_divergence(prfs, lambda_ = 'log-likelihood', axis = None, ddof = 2)
Power_divergenceResult(statistic=29.07673602201342, pvalue=6.956736686069527e-08)