Print
Chi-Square Test: Visualization
Read It: Visualizing Chi-Square Distributions
When creating visualizations for chi-square tests, you need to provide three key pieces of information: (1) the randomization distirbution of chi-square statistics, (2) the sample chi-square statistic, and (3) the idealized chi-square distribution. In the video below, we walk you through adding each of these parts to a single ggplot graph.
Watch It: Video - Visualization (7:06 minutes)
Try It: GOOGLE COLAB
- Click the Google Colab file used in the video here.
- Go to the Colab file and click "File" then "Save a copy in Drive", this will create a new Colab file that you can edit in your own Google Drive account.
- Once you have it saved in your Drive, try to edit the follwoing code to create a visualization of the data you collected in the previous DataCamp exercise.
Note: You must be logged into your PSU Google Workspace in order to access the file.
# Copy your data from the previosu DataCamp exercise table = pd.DataFrame({'Suit' : ['Diamonds', 'Hearts', 'Clubs', 'Spades'], 'Count' : [0,0,0,0]}) # Rerun randomization procedure code # Create Visualization deg_f = ... chisq_df['x_pdf'] = ... chisq_df['y_pdf'] = ... (ggplot(chisq_df) + geom_histogram(...) + geom_vline(...) + geom_line(...) )
Once you have implemented this code on your own, come back to this page to test your knowledge.