I want to measure the magnitude and direction of a relation between two nominal variables: profession and hood. I choose to use Cramer's V based on this explanation.

import pandas as pd
import numpy as np
import scipy.stats as scis

# compute cramer's stat
def cramers_stat(contingency_table):
    chi2 = scis.chi2_contingency(contingency_table)
    print('chi2 p-value: ', chi2[1])
    if chi2[1] < 0.05:
        n = contingency_table.values.sum()
        return np.sqrt(chi2[0] / (n*(min(contingency_table.shape)-1)))
        return 'no relation'

# create df
hoods = pd.DataFrame({
    'profession': np.random.choice([
    ], 200, p=[.2,.4,.4])

# fill hood value with trends
def hood(value):
    if value == 'painter':
        return np.random.choice(['Uptown', 'Downtown', 'Burbs'], p=[.8,.1,.1])
    elif value == 'plumber':
        return np.random.choice(['Uptown', 'Downtown', 'Burbs'], p=[.3,.5,.2])
    elif value == 'statistician':
        return np.random.choice(['Uptown', 'Downtown', 'Burbs'], p=[.2,.7,.1])

hoods['hood'] = hoods.profession.apply(hood)


pd.crosstab(hoods.profession, hoods.hood)

#hood          Burbs  Downtown  Uptown
#painter           4         4      35
#plumber          12        46      25
#statistician      3        55      16


cramers_stat(pd.crosstab(hoods.hood, hoods.profession))

#chi2 p-value:  4.17294374904e-11

Question 1

This V statistic tells me that there is a relation between profession and hood. Without other V statistics for context, how do I tell how strong this is? What is the plain english statement I can make about the statistic magnitude and direction?

Question 2

Does this statistic allow me to make statements about the strength of individual hoods and individual professions? For example, "painters are significantly more likely to live in Uptown (Cramer's V=0.35, p=4.7e-10)"?


2 Answers 2


Edit: Answer to Question 1: The Cramer's V statistic doesn't show direction. On a 2 x 2 table, phi shows direction with positive or negative sign, but directionality doesn't make much sense in a larger table of nominal categories.

There is no absolute interpretation of an effect size statistic like Cramer's V. It is always relative to the discipline and the expectations of the experiment. For a couple of points about this, see the comments to my answer at this link. That being said, the interpretations from Cohen 1988 are often used as typical interpretations. There is a table of interpretations here.

Edit: Answer to Question 2: To answer the question of which Profession is associated with which Hood, there a few approaches. One is to simply look at the percentage of counts within, say, each Profession. If Painter is 10% Uptown, 20% Downtown, and 70% Burbs, that is helpful information. Sometimes standardized residuals or odds ratio is used for this purpose. You could also break the table into smaller components, such as a 1 x 3 table for each profession, and look at p-value and effect size statistics for each. Graphical representation (spine plot, mosaic plot, bar plot) is also helpful.

It doesn't make much sense to use the omnibus Cramer's V statistic as evidence for e.g. the association within a specific profession.

Edit:Note It appears that the function to calculate Cramer's V works correctly.

  • $\begingroup$ are you saying that cramers v should not be used to make statements about relations between individual professions and hoods? $\endgroup$ Apr 10, 2018 at 13:35
  • $\begingroup$ It COULD be used in this way, but you would need to calculate it for the individual profession, that is the 1 x 3 table for each Profession.... I see you updated you question with new results. I will look at them. $\endgroup$ Apr 10, 2018 at 13:45
  • $\begingroup$ Okay. My answer updated in light of new results. $\endgroup$ Apr 10, 2018 at 14:07

Maybe a comment to add to the answer provided by Sal Mangiafico: in fact, Cramer's V does not tell the direction of the association (as you asked for in Question 1), but for this purpose you can user Theil's U. In contrast to Cramer's V, Theil's U is an asymmetric measure, and it tells you the direction of the association between two categorical variables. Check this post for more information. ;)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.