-
Notifications
You must be signed in to change notification settings - Fork 10
G test of independence
Maurice HT Ling edited this page Aug 14, 2021
·
1 revision
Purpose: To test whether 2 categorical variables (defining the rows and columns) are independent
Null hypothesis: There is no relationship between between the 2 categorical variables; that is, the 2 categorical variables are not independent.
Alternate hypothesis: There is a relationship between the 2 categorical variables; that is, the 2 categorical variables are not independent.
Code:
>>> from scipy import stats
>>> table = [[77, 404],
... [16, 122]]
>>> result = stats.chi2_contingency(table, lambda_="log-likelihood")
>>> print("G = %.3f" % result[0])
G = 1.368
>>> print("p-value = %.3f" % result[1])
p-value = 0.242
Reference:
- Cressie N, Read TRC. 1984. Multinomial Goodness-of-Fit Tests. Journal of the Royal Statistical Society Series B 46(3), 440-464.
Copyright (c) 2008-2024, Maurice HT Ling
Refereed Publications and Technical Reports
Abstracts and Other Un-Refereed Works
Autobiographic Verses (Poems that I wrote) and My Sayings