Fisher Exact and McNemar Test Calculator
Type a 2x2 table and get Fisher's exact test for two independent groups or McNemar's test for paired yes/no results, with every p-value, odds ratios, intervals and the working.
Tarayıcınızda çalışır. Dosyalarınız cihazınızdan asla çıkmaz. Nasıl kontrol edeceğinizi görün
…
Nasıl yapılır
- 1Choose the test
Pick Fisher for two independent groups or McNemar for paired data.
- 2Fill the table
Type the four counts and name the rows and columns, or count them from a CSV.
- 3Set the levels
Choose the confidence level and the significance level.
- 4Read the result
Check the p-values, odds ratio, interval and the plain-language summary.
- 5See the working
Open the steps and the null distribution chart.
- 6Export
Print the report, download the table or copy the result.
Bu araç hakkında
Two tests cover most small yes/no comparisons. Fisher's exact test asks whether two independent groups differ in the share with an outcome, for example infection in a treated and an untreated group, and it stays valid however small the counts are. McNemar's test is for paired data: the same people asked twice, two tests on the same patients, or matched case-control pairs. It looks only at the pairs that changed. This calculator has both in one editable 2x2 table with your own row and column names, and it can count the table from a CSV with one row per person or pair. For Fisher's test it lists every table with the same margins, its hypergeometric probability and whether it falls in the two-sided p-value. It gives the two-sided p by the minimum-likelihood rule used by R, both one-sided p-values, the less conservative mid-p, the conditional maximum-likelihood odds ratio with its exact interval, the ordinary odds ratio with a Woolf interval, the risk ratio, and the Yates chi-square for comparison with a warning about small expected counts. For McNemar's test it gives the chi-square with and without continuity correction, the exact binomial p-value, the mid-p, the paired odds ratio with exact and Wald intervals and the difference between the paired proportions. A bar chart shows the null distribution, and a plain-language sentence states the result.
Fisher or chi-square, McNemar or Fisher
Use Fisher's test when the groups are independent, especially when any expected count is below 5, where the chi-square approximation breaks down. Use McNemar's test whenever each row of data is a pair: running Fisher's or a chi-square test on paired data ignores the pairing and gives the wrong answer. For McNemar, the exact binomial p-value is preferred when fewer than about 25 pairs are discordant.
Worked example
In Fisher's tea-tasting experiment a lady was given 8 cups, 4 with the milk poured first, and correctly picked 3 of the 4. The margins are fixed at 4 and 4, so a can be 0 to 4 with probabilities 1/70, 16/70, 36/70, 16/70 and 1/70. The observed table has probability 16/70 = 0.229. Tables as likely or less likely add up to 34/70, so the two-sided p = 0.4857 and the one-sided p for better than chance is 17/70 = 0.2429. The conditional odds ratio is 6.41 with an exact 95% interval from about 0.21 to 626: three out of four is not evidence of skill. In the McNemar sample 100 people answered a question before and after a campaign; 16 switched from no to yes and 4 from yes to no. χ² = (4 − 16)²/20 = 7.2 (p = 0.0073), 6.05 with continuity correction (p = 0.0139), and the exact p is 0.0118. The paired odds ratio is 4/16 = 0.25 (exact interval 0.061 to 0.775), and the share answering yes rose from 34% to 46%.
Limits
Both tests are for a single 2x2 table; larger tables need the Freeman-Halton extension or a chi-square test, and stratified data need a Mantel-Haenszel analysis. Fisher's test conditions on both margins, which makes it slightly conservative; the mid-p is a common compromise but is not exact. A p-value does not measure the size of an effect, so report the odds ratio and its interval as well.
Çözümlü örnek
Tea tasting, 3 of 4 cups right: Fisher two-sided p = 0.486. Campaign survey, 16 switched to yes and 4 to no: McNemar exact p = 0.012.
Kısaca
- Kategori: Matematik ve bilim
- Tarayıcınızda çalışır, kayıt yok, yükleme yok.
- Girdiğiniz bilgiler cihazınızda kalır.
- İngilizce olarak mevcut.
- İçeriğin son gözden geçirilmesi:
- Resmî kaynak: McNemar, Note on the sampling error of the difference between correlated proportions, Psychometrika (1947)
Sık sorulan sorular
When should I use Fisher's exact test instead of chi-square?
When any expected cell count is below 5, or the total is small. Fisher's test is valid at any sample size, so it is also fine for large tables, although the chi-square then gives almost the same answer.
What is the mid-p value?
It counts only half of the probability of the observed table. Exact tests on counts are conservative because the p-value jumps in steps; the mid-p corrects much of that and is recommended by many statisticians for reporting.
Why does McNemar ignore the pairs that agree?
Pairs that gave the same answer both times carry no information about a change. Only the discordant pairs show whether changes in one direction outnumber changes in the other.
Why does the odds ratio from Fisher's test differ from ad/bc?
Fisher's test reports the conditional maximum-likelihood estimate, which accounts for the fixed margins. The sample odds ratio ad/bc is shown too; the two are close in larger tables.
Can I enter raw data instead of counts?
Yes. Open the raw data section, paste or import a CSV with one row per person or pair, choose the two columns and the tool counts the table.
What does an infinite upper limit mean?
When a count sits at the edge of what the margins allow, such as zero events in one group, the data cannot rule out an arbitrarily large odds ratio in that direction, so one limit is 0 or infinity.
