SlideShare a Scribd company logo
1 of 11
Kruskal-Wallis Test in R
W Roseybala Devi,
PG Bioinformatics, First Year
JSS Academy of Higher Education and Research, Mysore.
Non-parametric test
• Non parametric tests are used when our data isn't normal. If the data
is approximately normal, then we can use parametric statistical tests.
• Therefore the key is to figure out if we have normally distributed data.
• Nonparametric tests are sometimes called distribution-free tests
because they are based on fewer assumptions (e.g., they do not
assume that the outcome is approximately normally distributed).
• nonparametric tests are methods of statistical test/analysis that do
not require a distribution to meet the required assumptions to be
analyzed.
Examples of non-parametric test
• Wilcoxon Rank sum Test
• Mann-Whitney U test
• Spearman correlation
• Kruskal Wallis Test
Kruskal-Wallis Test
• The Kruskal–Wallis test was developed in1952 by Kruskal, W.H. and
Wallis, W.A..
• The Kruskal-Wallis rank-sum test is a non-parameteric method for
testing whether samples originate from the same distribution
• its parametric equivalent is One-way ANOVA. This test is useful for
cases where the data does not meet the assumptions for ANOVA.
Assumptions in Kruskal-Wallis test
• dependent variable should be measured at the ordinal or continuous
level (i.e., interval or ratio).
• independent variable should consist of two or more categorical,
independent groups.
• should have independence of observations, which means that there is
no relationship between the observations in each group or between
the groups themselves.
Hypotheses
• H₀ : All k populations have the same distribution.
• H₁ : Not all k populations have the same distribution.
Computation of Kruskal-Wallis Test in R
Step 1: Import the data into R.
my_data <- read.csv (file.choose()) for comma separated values
my_data <- read.delim (file.choose()) for files with delimiters or
text files
We will use in inbuilt data called PlantGrowth which contains the weight of plants
obtained under a control and two different treatment conditions.
The data PlantGrowth is imported using:
my_data <- PlantGrowth
Step 2: Check the data
check the head of the data using: head (my_data)
Output:
• In R terminology, the column “group” is called factor and the different categories
are named factor levels. The levels are ordered alphabetically.
• To check group levels: (my_data$group)
[1] "ctrl" "trt1" "trt2"
Step 3: Computing Kruskal-Wallis Test
The test can be performed using the function kruskal.test( ) as follow:
Output:
Step 4: Interpretation of results:
The value of the test statistic is 7.9882. If the calculated value is less than the critical
chisquared value, then the null hypothesis cannot be rejected.
here, 7.988 > 5.99
The p-value is less than the significance level 0.05, we can conclude that there are
significant differences between the treatment groups.
we reject the null hypothesis.
Kruskal Wallis Test in R

More Related Content

What's hot

Research method ch07 statistical methods 1
Research method ch07 statistical methods 1Research method ch07 statistical methods 1
Research method ch07 statistical methods 1
naranbatn
 

What's hot (20)

Analysis of variance (ANOVA) everything you need to know
Analysis of variance (ANOVA) everything you need to knowAnalysis of variance (ANOVA) everything you need to know
Analysis of variance (ANOVA) everything you need to know
 
Testing Hypothesis
Testing HypothesisTesting Hypothesis
Testing Hypothesis
 
regression and correlation
regression and correlationregression and correlation
regression and correlation
 
Hypothesis Testing
Hypothesis TestingHypothesis Testing
Hypothesis Testing
 
Descriptive and Inferential Statistics
Descriptive and Inferential StatisticsDescriptive and Inferential Statistics
Descriptive and Inferential Statistics
 
non parametric statistics
non parametric statisticsnon parametric statistics
non parametric statistics
 
Chi square Test Using SPSS
Chi square Test Using SPSSChi square Test Using SPSS
Chi square Test Using SPSS
 
The mann whitney u test
The mann whitney u testThe mann whitney u test
The mann whitney u test
 
Anova , ANCOVA, MANOVA and MANCOVA for the very beginners
Anova , ANCOVA, MANOVA and MANCOVA for the very beginners Anova , ANCOVA, MANOVA and MANCOVA for the very beginners
Anova , ANCOVA, MANOVA and MANCOVA for the very beginners
 
Research method ch07 statistical methods 1
Research method ch07 statistical methods 1Research method ch07 statistical methods 1
Research method ch07 statistical methods 1
 
Chi square test
Chi square testChi square test
Chi square test
 
Inferential vs descriptive tutorial of when to use - Copyright Updated
Inferential vs descriptive tutorial of when to use - Copyright UpdatedInferential vs descriptive tutorial of when to use - Copyright Updated
Inferential vs descriptive tutorial of when to use - Copyright Updated
 
Kruskal Wall Test
Kruskal Wall TestKruskal Wall Test
Kruskal Wall Test
 
Mann Whitney U test
Mann Whitney U testMann Whitney U test
Mann Whitney U test
 
Spearman Rank Correlation - Thiyagu
Spearman Rank Correlation - ThiyaguSpearman Rank Correlation - Thiyagu
Spearman Rank Correlation - Thiyagu
 
Lecture 4: Statistical Inference
Lecture 4: Statistical InferenceLecture 4: Statistical Inference
Lecture 4: Statistical Inference
 
Anova (f test) and mean differentiation
Anova (f test) and mean differentiationAnova (f test) and mean differentiation
Anova (f test) and mean differentiation
 
t-TEst. :D
t-TEst. :Dt-TEst. :D
t-TEst. :D
 
Mann Whitney U Test | Statistics
Mann Whitney U Test | StatisticsMann Whitney U Test | Statistics
Mann Whitney U Test | Statistics
 
Null hypothesis for a chi-square goodness of fit test
Null hypothesis for a chi-square goodness of fit testNull hypothesis for a chi-square goodness of fit test
Null hypothesis for a chi-square goodness of fit test
 

Similar to Kruskal Wallis Test in R

3Nonparametric Tests power point presentationpdf
3Nonparametric Tests power point presentationpdf3Nonparametric Tests power point presentationpdf
3Nonparametric Tests power point presentationpdf
MitikuTeka1
 
Statistical concepts
Statistical conceptsStatistical concepts
Statistical concepts
Carlo Magno
 
PR1 Module 5-Methodology-Ppt.ppt
PR1 Module 5-Methodology-Ppt.pptPR1 Module 5-Methodology-Ppt.ppt
PR1 Module 5-Methodology-Ppt.ppt
jeonalugon1
 

Similar to Kruskal Wallis Test in R (20)

Non parametric test
Non parametric testNon parametric test
Non parametric test
 
Non parametric study; Statistical approach for med student
Non parametric study; Statistical approach for med student Non parametric study; Statistical approach for med student
Non parametric study; Statistical approach for med student
 
Introduction to Data Management in Human Ecology
Introduction to Data Management in Human EcologyIntroduction to Data Management in Human Ecology
Introduction to Data Management in Human Ecology
 
F unit 5.pptx
F unit 5.pptxF unit 5.pptx
F unit 5.pptx
 
non parametric test.pptx
non parametric test.pptxnon parametric test.pptx
non parametric test.pptx
 
biostat__final_ppt_unit_3.pptx
biostat__final_ppt_unit_3.pptxbiostat__final_ppt_unit_3.pptx
biostat__final_ppt_unit_3.pptx
 
Ins and outs of clinical trials
Ins and outs of clinical trialsIns and outs of clinical trials
Ins and outs of clinical trials
 
Sampling procedure and sample I Quantitative Research
Sampling procedure and sample I Quantitative ResearchSampling procedure and sample I Quantitative Research
Sampling procedure and sample I Quantitative Research
 
UNIT 5.pptx
UNIT 5.pptxUNIT 5.pptx
UNIT 5.pptx
 
Kruskal wallis test
Kruskal wallis testKruskal wallis test
Kruskal wallis test
 
Nonparametric tests assignment
Nonparametric tests assignmentNonparametric tests assignment
Nonparametric tests assignment
 
Non parametric test 8
Non parametric test 8Non parametric test 8
Non parametric test 8
 
Friedman Test- A Presentation
Friedman Test- A PresentationFriedman Test- A Presentation
Friedman Test- A Presentation
 
3Nonparametric Tests power point presentationpdf
3Nonparametric Tests power point presentationpdf3Nonparametric Tests power point presentationpdf
3Nonparametric Tests power point presentationpdf
 
Introduction to Data Analysis With R and R Studio
Introduction to Data Analysis With R and R StudioIntroduction to Data Analysis With R and R Studio
Introduction to Data Analysis With R and R Studio
 
Statistical concepts
Statistical conceptsStatistical concepts
Statistical concepts
 
PR1 Module 5-Methodology-Ppt.ppt
PR1 Module 5-Methodology-Ppt.pptPR1 Module 5-Methodology-Ppt.ppt
PR1 Module 5-Methodology-Ppt.ppt
 
Statistics and prob.
Statistics and prob.Statistics and prob.
Statistics and prob.
 
satatistics Presentation.pptx
satatistics Presentation.pptxsatatistics Presentation.pptx
satatistics Presentation.pptx
 
Statistics for Anaesthesiologists
Statistics for AnaesthesiologistsStatistics for Anaesthesiologists
Statistics for Anaesthesiologists
 

Recently uploaded

Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Sérgio Sacani
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
PirithiRaju
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
Sérgio Sacani
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
gindu3009
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Areesha Ahmad
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
AlMamun560346
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Sérgio Sacani
 

Recently uploaded (20)

Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 

Kruskal Wallis Test in R

  • 1. Kruskal-Wallis Test in R W Roseybala Devi, PG Bioinformatics, First Year JSS Academy of Higher Education and Research, Mysore.
  • 2. Non-parametric test • Non parametric tests are used when our data isn't normal. If the data is approximately normal, then we can use parametric statistical tests. • Therefore the key is to figure out if we have normally distributed data. • Nonparametric tests are sometimes called distribution-free tests because they are based on fewer assumptions (e.g., they do not assume that the outcome is approximately normally distributed). • nonparametric tests are methods of statistical test/analysis that do not require a distribution to meet the required assumptions to be analyzed.
  • 3. Examples of non-parametric test • Wilcoxon Rank sum Test • Mann-Whitney U test • Spearman correlation • Kruskal Wallis Test
  • 4. Kruskal-Wallis Test • The Kruskal–Wallis test was developed in1952 by Kruskal, W.H. and Wallis, W.A.. • The Kruskal-Wallis rank-sum test is a non-parameteric method for testing whether samples originate from the same distribution • its parametric equivalent is One-way ANOVA. This test is useful for cases where the data does not meet the assumptions for ANOVA.
  • 5. Assumptions in Kruskal-Wallis test • dependent variable should be measured at the ordinal or continuous level (i.e., interval or ratio). • independent variable should consist of two or more categorical, independent groups. • should have independence of observations, which means that there is no relationship between the observations in each group or between the groups themselves.
  • 6. Hypotheses • H₀ : All k populations have the same distribution. • H₁ : Not all k populations have the same distribution.
  • 7. Computation of Kruskal-Wallis Test in R Step 1: Import the data into R. my_data <- read.csv (file.choose()) for comma separated values my_data <- read.delim (file.choose()) for files with delimiters or text files We will use in inbuilt data called PlantGrowth which contains the weight of plants obtained under a control and two different treatment conditions. The data PlantGrowth is imported using: my_data <- PlantGrowth
  • 8. Step 2: Check the data check the head of the data using: head (my_data) Output: • In R terminology, the column “group” is called factor and the different categories are named factor levels. The levels are ordered alphabetically. • To check group levels: (my_data$group) [1] "ctrl" "trt1" "trt2"
  • 9. Step 3: Computing Kruskal-Wallis Test The test can be performed using the function kruskal.test( ) as follow: Output:
  • 10. Step 4: Interpretation of results: The value of the test statistic is 7.9882. If the calculated value is less than the critical chisquared value, then the null hypothesis cannot be rejected. here, 7.988 > 5.99 The p-value is less than the significance level 0.05, we can conclude that there are significant differences between the treatment groups. we reject the null hypothesis.