Get startedGet started for free

Effect size for categorical variables

You saw in the City of Austin employee data that job titles have an unequal distribution of genders. But does the same thing hold for ethnicities? And to what extent does ethnicity relate to the job title chosen? In this exercise you'll dig in and answer that question.

A DataFrame of comparing job titles and ethnicities (employees_df) has been loaded for you, as have the packages pandas as pd, NumPy as np, and stats from SciPy.

This exercise is part of the course

Foundations of Inference in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Compute the chi-squared statistic
chi2, p, d, expected = stats.____(____)

# Compute the DOF using the number of rows and columns
dof = min(____.shape[0] - 1, ____.shape[1] - 1)

# Compute the total number of people
n = np.sum(____.values)

# Compute Cramer's V
v = np.____((____ / ____) / ____)

print("Cramer's V:", v, "\nDegrees of freedom:", dof)
Edit and Run Code