R Fisher Test Calculate Confidence Interval
The Fisher's Exact Test is a statistical test used to determine if there are non-random associations between two categorical variables. This calculator helps you calculate the confidence interval for the odds ratio from a 2×2 contingency table.
What is the Fisher's Exact Test?
The Fisher's Exact Test is an alternative to the chi-square test of independence for small sample sizes. It calculates the exact probability of observing the given contingency table under the null hypothesis of no association between the variables.
This test is particularly useful when sample sizes are small or when expected cell counts are less than 5, as the chi-square test may not be valid in such cases.
Key Concepts
- Contingency Table: A table showing the frequency distribution of variables
- Odds Ratio: The ratio of the odds of an event occurring in one group to the odds of it occurring in another group
- Null Hypothesis: Assumes no association between the variables
- Alternative Hypothesis: Assumes an association exists
Calculating Confidence Interval
The confidence interval for the odds ratio from the Fisher's Exact Test provides a range of values that is likely to contain the true odds ratio. This interval helps assess the precision of the estimate.
Confidence Interval = (Lower Bound, Upper Bound)
Where:
- Lower Bound = Odds Ratio × (1 - (1 - Confidence Level)^(1/n))
- Upper Bound = Odds Ratio × (1 + (1 - Confidence Level)^(1/n))
- n = Sample size
Steps to Calculate
- Construct a 2×2 contingency table with your data
- Calculate the odds ratio from the table
- Determine the confidence level (typically 95%)
- Calculate the lower and upper bounds using the formulas above
- Interpret the resulting interval
Worked Example
Consider a study examining the relationship between smoking and lung cancer:
| Lung Cancer | No Lung Cancer | Total | |
|---|---|---|---|
| Smokers | 20 | 80 | 100 |
| Non-smokers | 10 | 90 | 100 |
| Total | 30 | 170 | 200 |
Using the calculator with these values:
- Odds Ratio = 2.2
- 95% Confidence Interval = (1.5, 3.2)
This means we are 95% confident that the true odds ratio lies between 1.5 and 3.2.
Interpreting Results
The confidence interval provides several important insights:
- Precision: A narrow interval indicates a more precise estimate
- Significance: If the interval does not include 1, the association is statistically significant
- Direction: The interval's position relative to 1 indicates the direction of the association
Always consider the context of your study when interpreting confidence intervals. A statistically significant result may not be clinically significant.
FAQ
When should I use the Fisher's Exact Test instead of chi-square?
Use Fisher's Exact Test when your sample size is small or when expected cell counts are less than 5. The chi-square test may not be valid in these cases.
What does a confidence interval of (1.5, 3.2) mean?
This means we are 95% confident that the true odds ratio lies between 1.5 and 3.2. Since 1 is not in this interval, we can conclude there is a statistically significant association.
How do I interpret an odds ratio of 2.2?
An odds ratio of 2.2 means that the odds of developing lung cancer are 2.2 times higher for smokers compared to non-smokers.
What if my confidence interval includes 1?
If your confidence interval includes 1, it suggests there is no statistically significant association between the variables at your chosen confidence level.