分类:P值和样本大小的关系

来自Big Physics


问题背景

在有实验组和对照组的对比实验设计中,往往我们需要通过预实验来确定样本大小。而样本大小的确定通常可以通过分析预实验的数据,通过计算显著性和样本大小的关系,也就是p值和N的关系,画图,做延拓,来估计所需要的最小N值。

但是,是否存在着这样的情况,无论实验组和对照组的差别多么小,只要通过增加样本大小N,总是可以得到统计上显著的结果?如果有,那这个实验设计的思路,原则上有逻辑漏洞。

理论研究

假定我们的两组数据[math]\displaystyle{ \left(\left\{x^{a}_{i=1...N_{a}}\right\},\left\{x^{b}_{i=1...N_{b}}\right\}\right) }[/math]分别来自于两个正态分布[math]\displaystyle{ N(\mu^{a}, \sigma^{a}) }[/math][math]\displaystyle{ N(\mu^{b},\sigma^{b}) }[/math]。现在我们来从这两组数据估计出来这两个分布函数有差别的概率。其中一种定义有差别的方式是:从两个分布中随机各自取出来一个新的样本[math]\displaystyle{ \left(x^{a}_{*},x^{b}_{*}\right) }[/math],其中一个大于另一个的概率,[math]\displaystyle{ P\left(x^{a}_{*}\gt x^{b}_{*}\right)=P\left(x^{a}_{*}-x^{b}_{*}\gt 0\right)\gt p_{*} }[/math]

我们先在参数[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]全都已知的条件下把这个公式推导出来,然后,再来解决如何从样本数据[math]\displaystyle{ \left(\left\{x^{a}_{i=1...N_{a}}\right\},\left\{x^{b}_{i=1...N_{b}}\right\}\right) }[/math]中估计出来这些参数的问题,以及估计出来以后如何更好地给出来[math]\displaystyle{ P\left(x^{a}_{*}-x^{b}_{*}\gt 0\right) }[/math]的问题。注意,后者由于估计出来的量[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]都有误差,因此,会比直接代入以[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]表达的公式要复杂一些。

[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]得到[math]\displaystyle{ P\left(x^{a}_{*}-x^{b}_{*}\gt 0\right) }[/math]

[math]\displaystyle{ X=x^{a}-x^{b} }[/math]的分布函数是[math]\displaystyle{ N(\mu^{a}-\mu^{b},\sqrt{\left(\sigma^{a}\right)^{2}+\left(\sigma^{b}\right)^{2}}) }[/math]。也就是说,只要这四个参数满足下面的条件,两个分布函数就有区别,

[math]\displaystyle{ \int_{0}^{\infty} d\xi \frac{1}{\sqrt{2\pi}}e^{-\frac{\left(\xi-\left(\mu^{a}-\mu^{b}\right)\right)^{2}}{2\left(\sigma^{a}\right)^{2}+2\left(\sigma^{b}\right)^{2}}}\geq p_{*} }[/math].

这个概率实际上,由两个分布函数的均值和方差四个参数一起决定的。就算两个均值相差很大,但是方差也比较大的时候,两个分布函数重叠的地方特别多,则仍然这个概率会很小,不一定能够达到大于阈值[math]\displaystyle{ p_{*} }[/math]。用通常的p值的语言,可以重新表述为

[math]\displaystyle{ p=1-\int_{0}^{\infty} d\xi \frac{1}{\sqrt{2\pi}}e^{-\frac{\left(\xi-\left(\mu^{a}-\mu^{b}\right)\right)^{2}}{2\left(\sigma^{a}\right)^{2}+2\left(\sigma^{b}\right)^{2}}}=\int_{-\infty}^{0} d\xi \frac{1}{\sqrt{2\pi}}e^{-\frac{\left(\xi-\left(\mu^{a}-\mu^{b}\right)\right)^{2}}{2\left(\sigma^{a}\right)^{2}+2\left(\sigma^{b}\right)^{2}}} }[/math].

也可以类似地讨论[math]\displaystyle{ X=\left|x^{a}-x^{b}\right| }[/math]的分布函数,然后把统计检验构建在这个分布函数之上,不过这里暂时不展开讨论。

[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]到样本数据

假设我们已知一个正态分布[math]\displaystyle{ N\left(\mu, \sigma\right) }[/math]我们来看看从中得到的大小为[math]\displaystyle{ N }[/math]的样本数据[math]\displaystyle{ \left\{x_{i=1...N}\right\} }[/math]的统计性质。

首先

[math]\displaystyle{ \left\langle\bar{x}\right\rangle=\frac{1}{N}\sum_{i=1}^{N}\left\langle x_{i} \right\rangle=\mu }[/math]

其中[math]\displaystyle{ \bar{x}^{a}=\frac{1}{N_{a}}\sum_{i=1}^{N_{a}}x^{a}_{i} }[/math][math]\displaystyle{ s^{a,2}_p=\frac{1}{N_{a}}\sum_{i=1}^{N_{a}}\left(x^{a}_{i}-\bar{x}\right)^2 }[/math],也被称为样本方差。

注意,这里有个非常微妙的地方,参数[math]\displaystyle{ \mu^{a} }[/math]的估计误差不是直接就是样本方差[math]\displaystyle{ s^{a,2}_p }[/math],而是[math]\displaystyle{ \sigma_{N_{a}} }[/math],其额外还增加了一个[math]\displaystyle{ \frac{1}{\sqrt{N_{a}}} }[/math]的系数。这也是合理的,样本数量越多,对参数的估计就更准确。

从样本数据到[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]

从样本数据[math]\displaystyle{ \left(\left\{x^{a}_{i=1...N_{a}}\right\},\left\{x^{b}_{i=1...N_{b}}\right\}\right) }[/math],通过极大似然估计(或者别的估计方法),我们可以得到参数值[math]\displaystyle{ \mu^{a}, \sigma^{a}, \mu^{b},\sigma^{b} }[/math]以及每个参数的估计误差,例如(先暂时写成一个[math]\displaystyle{ \sigma }[/math]的形式,如果需要转化成95%置信区间,则需要做相应转换),

[math]\displaystyle{ \mu^{a}=\bar{x}^{a}\pm \sigma_{N_{a}} = \bar{x}^{a}\pm \frac{1}{\sqrt{N_{a}}}s^{a}_{p} }[/math]

其中[math]\displaystyle{ \bar{x}^{a}=\frac{1}{N_{a}}\sum_{i=1}^{N_{a}}x^{a}_{i} }[/math][math]\displaystyle{ s^{a,2}_p=\frac{1}{N_{a}}\sum_{i=1}^{N_{a}}\left(x^{a}_{i}-\bar{x}\right)^2 }[/math],也被称为样本方差。

注意,这里有个非常微妙的地方,参数[math]\displaystyle{ \mu^{a} }[/math]的估计误差不是直接就是样本方差[math]\displaystyle{ s^{a,2}_p }[/math],而是[math]\displaystyle{ \sigma_{N_{a}} }[/math],其额外还增加了一个[math]\displaystyle{ \frac{1}{\sqrt{N_{a}}} }[/math]的系数。这也是合理的,样本数量越多,对参数的估计就更准确。


从ks检验来看,好像不会出现上面提到的现象。ks检验实际上对比的是两个分布函数之间的差。因此,从逻辑上说,ks检验先从实际数据中拟合出来分布函数,然后,计算两个分布函数的最大区别。因此,增加样本量只能使得分布函数估计的更加准确,但是不会增加那个最大区别。

从正态分布的双样本t检验的角度来看,似乎有可能随着样本数量的增加,显著性提高,毕竟来自于同一个分布函数的样本的样本均值标准差会随着数量增加而减小[math]\displaystyle{ \sigma_{N}=\frac{\sigma}{\sqrt{N}} }[/math],其中[math]\displaystyle{ \sigma }[/math]是原分布函数的标准差。

t检验实际上计算的统计量是[math]\displaystyle{ t = \frac{(\overline{x}_1 -\overline{x}_2)}{s_p\sqrt{1/N_1 + 1/N_2}} }[/math],其中[math]\displaystyle{ s_p^2 = \frac{((N_1 - 1)s_1^2) + ((N_2 - 1)s_2^2)} {N_1 + N_2 - 2} }[/math]

数值实验

在那之前,可以做一下数值实验。

下一步工作

  1. 文献调研,看一下,这个问题其他人是否已经回答过,是否已经有好的答案。
  2. 数值实验
    1. 选择一个分布函数,例如正态分布,调整两者的均值和方差(可以暂时不调整),使得两者分别处于有显著区别和没显著区别的状态(用KS检验来判断)
    2. 从每个分布函数中产生样本,给定样本数N
    3. 对这两组样本做各种统计检验,得到p值,看是否统计显著
    4. 画p-N曲线,看是否随着N增加,p减小
  3. 选择一组足够大的实际数据,有实验组和对照组的,分开具有显著不同的和没有显著不同的,做bootstrap抽象,大小为N
    1. 做统计检验,得到p值
    2. 画p-N曲线,看是否随着N增加,p减小
  4. 如果确实随着N增加,p减小,思考这个结果的统计学意义,尤其是联系[1],看看是不是两组样本之间只能做大小为N的群体的比较,而不是个体比较。

参考文献

  1. Zhesi Shen, Liying Yang, Zengru Di, Jinshan Wu. Large enough sample size to rank two groups of data reliably according to their means. Scientometrics 118: 653-671 (2019). https://doi.org/10.1007/s11192-018-2995-0

本分类目前不含有任何页面或媒体文件。