如何在Python中执行Dunn's检验?

WBOY
WBOY 转载
2023-08-22 14:41:06 403浏览

如何在Python中执行Dunn\'s检验?

Dunn's test is a statistical technique for comparing the means of several samples. When it's required to compare the means of numerous samples to identify which ones are noticeably different from one another, Dunn's test is frequently employed in a range of disciplines, including biology, psychology, and education. We shall examine Dunn's test in−depth in this article, along with a python implementation.

Dunn's Test是什么?

Dunn的检验是一种用于比较多个样本均值的统计分析方法。它是一种多重比较检验方法,用于比较超过两个样本的均值,以确定哪些样本之间存在显著差异。

当正态性假设被违反时,有时会使用Dunn的非参数Kruskal−Wallis检验来比较多个样本的均值。如果样本均值之间存在显著差异,就会使用Kruskal−Wallis检验来找出这些差异。对样本的均值进行两两比较,以确定哪些样本之间存在显著差异。然后使用Dunn的检验来比较样本的均值。

在Python中进行Dunn's检验

要在Python中运行Dunn's测试,我们可以使用scikit-posthocs库的posthoc dunn()方法。

下面的代码演示了如何使用这个函数 -

语法

sp.posthoc_dunn(data, p_adjust = 'bonferroni')
<p>Bartlett's test statistic和p值是在此函数接收到一个数据数组后返回的

参数

  • p_adjust是一种p值调整方法

为了在Python中演示测试,请考虑以下情景:研究人员希望发现三种不同的肥料是否会导致植物生长的不同程度。他们随机选择了30棵不同的植物,并将它们分成三组,每组十棵植物,每组使用不同的肥料。他们在一个月结束时测量每棵植物的高度。

算法

  • 安装scikit-posthocs库

  • 按组指定10个植物的生长数据

  • 将所有3个组合并为一个数据

  • 使用Bonferonni校正对p值进行Dunn's检验

Example

在这里演示了使用scikit-posthocs库运行Dunn's测试。

!pip install scikit-posthocs

#specify the growth of the 10 plants in each group
group1 = [9, 10, 16, 9, 10, 5, 7, 13, 10, 9]
group2 = [16, 19, 15, 17, 19, 11, 6, 17, 11, 9]
group3 = [7, 9, 5, 8, 8, 14, 11, 9, 14, 8]
data = [group1, group2, group3]

#perform Dunn's test using a Bonferonni correction for the p-values
import scikit_posthocs as sp
sp.posthoc_dunn(data, p_adjust = 'bonferroni')

输出

The adjusted p-value for the distinction between groups 1 and 2 is 0.115458.
The adjusted p-value for the distinction between groups 1 and 3 is 1.000000.
The adjusted p-value for the distinction between groups 2 and 3 is 0.27465.

结论

Dunn的检验在许多领域广泛应用,包括生物学、心理学和教育,其中需要比较多个样本的均值,以发现样本之间是否存在显著差异。当正态性假设被违反时,它尤其有益,因为它是一种不依赖于这一假设的非参数检验。

Dunn's test可以在教育领域中使用,用于比较来自不同学校或班级的许多样本数据的均值,以确定学校或教室的均值是否存在显著差异。例如,可以使用它来比较不同学校的平均考试成绩或不同教室的平均分数。

以上就是如何在Python中执行Dunn's检验?的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除