
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How To Perform Dunnís Test In Python?
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.
What is Dunn’s Test?
Dunn's test is a statistical analysis used to compare the means of numerous samples. It is a form of multiple comparison test used to compare the means of more than two samples to identify which samples differ substantially from one another.
When the assumption of normality is violated, Dunn's test is sometimes used with the non-parametric Kruskal−Wallis test to compare the means of several samples. If there are any notable differences between the sample means, the Kruskal−Wallis test is employed to find them. The means of the samples are compared pairwise to identify which samples are substantially different from one another and if there are significant differences. Dunn's test is then used to compare the means of the samples.
Performing Dunn’s test in Python
To run Dunn's test in Python, we can use the scikit-posthocs library's posthoc dunn() method.
The code below demonstrates how to use this function −
Syntax
sp.posthoc_dunn(data, p_adjust = 'bonferroni')
Bartlett's test statistic and the p-value are returned by this function after it receives an array of data.
Parameters
p_adjust is a p−value adjustment method
To demonstrate the test in Python, consider the following scenario: Researchers want to discover if three different fertilizers result in various degrees of plant growth. They choose 30 different plants at random and divide them into three groups of ten, each with a different fertilizer. They measure the height of each plant at the end of one month.
Algorithm
Installing scikit-posthocs library
Specifying the data of growth of 10 plants groupwise
Merging all the 3 groups in one data
Performing Dunn's test using a Bonferonni correction for the p-values
Example
Using the scikit-posthocs lib to run Dunn’s test is demonstrated here −
!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')
Output
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.
Conclusion
Dunn's test is widely used in a number of domains, including biology, psychology, and education, where the means of numerous samples must be compared to discover whether samples are substantially different from one another. It is especially beneficial when the assumption of normalcy is violated because it is a non-parametric test that does not rely on this assumption.
Dunn's test can be used in education to compare the means of many samples of data from various schools or classes in order to find whether schools or classrooms have substantially different means. It might be used, for example, to compare the average test scores of different schools or the average grades of different classrooms.
- Related Articles
- How to Perform Bartlettís Test in Python?
- How to Perform Grubbs Test in Python
- How to Perform an F-Test in Python
- How to Perform a Brown ñ Forsythe Test in Python
- How to perform fisher test in R?
- How to perform Friedman test in R?
- How to Perform a Chi-Square Goodness of Fit Test in Python
- How to perform one sample Kolmogorov-Smirnov test in R?
- How to perform post hoc test for Kruskal-Wallis in R?
- How to perform paired t test for multiple columns in R?
- How to perform chi square test for goodness of fit in R?
- C++ Program to Perform Fermat Primality Test
- How To Perform An Ancova In Python?
- How To Perform Welchís Anova In Python?
- How to perform homogeneity of variance test for two-way anova in R?
