【发布时间】:2017-05-02 21:12:45
【问题描述】:
CPAN 中是否有任何模块可以提供计算 Fishers 精确检验的方法?
R 中的示例:
在 2x2 列联表中,例如:
17 12
8842559 10003821
fisher.test(matrix(data = c(17,8842559,12,10003821), nrow = 2))
Fisher's Exact Test for Count Data
data: counts
p-value = 0.2642
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.7213591 3.6778630
sample estimates:
odds ratio
1.602697
我使用了Text::NSP::Measures::2D::Fisher 模块,但我不确定它是否与上述相同。
use Text::NSP::Measures::2D::Fisher::twotailed;
my $npp = 10003821;
my $n1p = 8842559;
my $np1 = 12;
my $n11 = 17;
my $twotailed_value = calculateStatistic(
n11 => $n11,
n1p => $n1p,
np1 => $np1,
npp => $npp,
);
if( (my $errorCode = getErrorCode()) ) {
print STDERR $errorCode, " - ", getErrorMessage();
} else {
print getStatisticName, "value for bigram is ", $twotailed_value, "\n";
}
但它没有给我任何东西
【问题讨论】:
-
模块的单行描述:Text::NSP::Measures::2D::Fisher - Perl 模块,提供计算 Fisher 精确检验的方法。 也许你可以包含您在使用模块时使用的代码,并显示其结果与您的预期有何不同。如果您不确定结果是否匹配,那么您最适合进行测试并获得保证。
-
@DavidO 谢谢,我添加了我的代码
-
该代码确实为我产生了输出:“202 - ngram 'n11' 的频率值不得超过边际总数。”它也应该适合你。当我在 Text::NSP 中查找该错误消息时,它显示“其中一个频率值 (n11) 超过了二元组的总数 (npp) 或边际总数 (n1p, np1)。 i>”,这对我来说没有任何意义,但对于需要这个模块的人来说应该是有意义的。
-
...但这可能是因为
$n11在您的代码中设置为 17,大于设置为 12 的$np1。也许您只是输入了错误的值进入错误的位置。如果我在您的代码中交换 12 和 17,我会得到“Two Tailed Fishervalue for bigram is 0.0393735436982673” -
是的,给定图表,
np1和n1p都必须是>= n11,npp必须是>=这三个。
标签: perl statistics