When a note is long enough, clicking a line will cause the page to move up. Below is an example. I paste it in the sandbox vault. Clicking lines from ~40 will cause the page to move up strangely. For example, You can alternate between clicking on line 45 and line 47, which will continuously scroll the page upward, even moving the cursor out of the viewport.
===The content starts here===
aliases:
tags:
sorting-spec: |
date-created: 2023-05-20T21:26:03++0800
date-modified: 2023-05-20T21:26:03++0800
Fisher’s exact test is a statistical test used to determine the significance of the association between two categorical variables in a 2x2 [[Contingency table|contingency table]]. It was developed by Sir [[Ronald Fisher]] in the early 20th century.
To perform Fisher’s exact test, you start with
$$
\begin{array}{|r|c|c|}
\hline & \text { B1 } & \text { B2 } \
\hline \text { A1 } & a & b \
\hline \text { A2 } & c & d \
\hline
\end{array}
$$
They hypothesis is
$$
H_0: \text{no association} \text{ v. s. } H_a: \text{there’s association}
$$
一般来说, 我们进一步扩展这个联表
$$
\begin{array}{|r|c|c|c|}
\hline & \text { B1 } & \text { B2 } & \text { Total } \
\hline \text { A1 } & a & b & a+b \
\hline \text { A2 } & c & d & c+d \
\hline \text { Total } & a+c & b+d & n=a+b+c+d \
\hline
\end{array}
$$
- 扩展出的 $a+b$ 等项称为 [[Marginal total|marginal totals]], 而
- $n$ 称为 [[Grand total|grand total]].
在 Fisher’s exact test 中, 在零假设成立的前提下, a 符合[[超几何分布]]
$$p=\frac{\left(\begin{array}{c} a+b \ a \end{array}\right)\left(\begin{array}{c} c+d \ c \end{array}\right)}{\left(\begin{array}{c} n \ a+c \end{array}\right)}=\frac{\left(\begin{array}{c} a+b \ b \end{array}\right)\left(\begin{array}{c} c+d \ d \end{array}\right)}{\left(\begin{array}{c} n \ b+d \end{array}\right)}=\frac{(a+b)!~(c+d)!~(a+c)!~(b+d)!}{a!~b!~c!~d!~n!}$$
这就直接给出了 p-value.
CALCULATIONS WITH R
Pearson's Chi-squared test with Yates' continuity correction
data: counts
X-squared = 5.5646, df = 1, p-value = 0.01833
Fisher's Exact Test for Count Data
data: counts
p-value = 0.02552
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.9918169 15.9604612
sample estimates:
odds ratio
5.039206
Warning message:
In chisq.test(counts) : Chi-squared近似算法有可能不准
FEATURES
- Fisher’s Exact Test的一个主要优点是,与其他一些用于列联表的统计方法(如卡方检验)相比,它不需要对数据的分布做出任何假设。这使得它在样本量较小的情况下特别有用。
- 然而,对于较大的样本或者类别较多的分类变量,计算Fisher’s Exact Test的p值可能会非常复杂和耗时。
REFERENCES
RELATED NOTES
- [[Chi-squared test]]
- [[P-value]]
===The content ends here===