Chi-square & Fisher’s Test

Chi-square test of independence and Fisher’s exact test in R — from a 2×2 table to a p-value, with the expected counts and when to use each.

Are two categorical variables associated? Test it with a contingency table.

Run the code

Everything in the video — edit it and press Run Code to run real R right here, or copy it:

Download this R script  ·  ▶ Open the full playground

When to use it. Use chi-square for large samples; check the expected counts and switch to Fisher’s exact test when any expected count is small (below ~5).

Try the chi-square calculator · read chi-square in R.

Next: Odds Ratio, Relative Risk & NNT →