fisher_test() performs Fisher's exact test for independence in a
contingency table. Use this instead of chi_square() when your
sample is small or when expected cell frequencies are below 5.
Think of it as:
An exact alternative to the chi-square test of independence
Best for small samples where the chi-square approximation may be inaccurate
SPSS automatically reports Fisher's Exact Test for 2x2 tables
The test tells you:
Whether two categorical variables are related (exact p-value)
The contingency table of observed frequencies
Results that are valid even with very small samples
Value
Test results showing whether two categorical variables are related, including:
Exact p-value (two-sided)
Contingency table of observed frequencies
Sample size (N)
Details
Understanding the Results
P-value: If p < 0.05, the variables are likely related (not independent)
p < 0.001: Very strong evidence of relationship
p < 0.01: Strong evidence of relationship
p < 0.05: Moderate evidence of relationship
p >= 0.05: No significant relationship found
Unlike the chi-square test which uses a large-sample approximation, Fisher's exact test computes the exact probability of observing the given table (or a more extreme one) under the null hypothesis of independence.
For tables larger than 2x2, the Fisher-Freeman-Halton extension is used.
When to Use This
Use Fisher's exact test when:
Any expected cell frequency is less than 5
Your total sample size is small (typically N < 30)
You have a 2x2 table (Fisher's exact is standard here)
You want an exact p-value rather than an approximation
Relationship to Other Tests
For large samples with all expected frequencies >= 5: Use
chi_square()insteadFor paired binary data (before/after): Use
mcnemar_test()insteadFor testing a single proportion: Use
binomial_test()instead
References
Fisher, R. A. (1922). On the interpretation of chi-square from contingency tables, and the calculation of P. Journal of the Royal Statistical Society, 85(1), 87-94.
Freeman, G. H., & Halton, J. H. (1951). Note on an exact treatment of contingency, goodness of fit and other problems of significance. Biometrika, 38(1/2), 141-149.
See also
chi_square for chi-square test of independence (large samples).
mcnemar_test for paired proportions.
Other hypothesis_tests:
ancova(),
binomial_test(),
chi_square(),
chisq_gof(),
factorial_anova(),
friedman_test(),
kruskal_wallis(),
mann_whitney(),
mcnemar_test(),
oneway_anova(),
t_test(),
wilcoxon_test()
Examples
# Load required packages and data
library(dplyr)
data(survey_data)
# Basic 2x2 Fisher test
survey_data %>%
fisher_test(row = gender, col = region)
#> Fisher's Exact Test: gender x region
#> p = 0.5435 , N = 2500
#> Use summary() for detailed output.
# Fisher test for larger table
survey_data %>%
fisher_test(row = gender, col = interview_mode)
#> Fisher's Exact Test: gender x interview_mode
#> p = 0.6782 , N = 2500
#> Use summary() for detailed output.
# With weights
survey_data %>%
fisher_test(row = gender, col = region, weights = sampling_weight)
#> Fisher's Exact Test: gender x region [Weighted]
#> p = 0.4867 , N = 2516
#> Use summary() for detailed output.
# Grouped analysis
survey_data %>%
group_by(education) %>%
fisher_test(row = gender, col = region)
#> [education = 1]
#> Fisher's Exact Test: gender x region
#> p = 0.9315 , N = 841
#> [education = 2]
#> Fisher's Exact Test: gender x region
#> p = 0.4170 , N = 629
#> [education = 3]
#> Fisher's Exact Test: gender x region
#> p = 0.9181 , N = 631
#> [education = 4]
#> Fisher's Exact Test: gender x region
#> p = 0.9003 , N = 399
#> Use summary() for detailed output.
