0% found this document useful (0 votes)
445 views26 pages

One-Way ANOVA & Kruskal-Wallis Test: DR Elaine Chan Wan Ling

The document discusses one-way ANOVA and Kruskal-Wallis tests. One-way ANOVA is used to compare the means of three or more groups and tests if they are equal. It has assumptions of normality and equal variances. Kruskal-Wallis is a non-parametric alternative that compares medians instead of means and does not assume normality. An example uses chick weight data to demonstrate a one-way ANOVA comparing feed types, checking assumptions, and finding a significant difference between groups. A soils dataset demonstrates a Kruskal-Wallis test comparing nitrogen levels across contour types, which finds no significant difference.

Uploaded by

lim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
445 views26 pages

One-Way ANOVA & Kruskal-Wallis Test: DR Elaine Chan Wan Ling

The document discusses one-way ANOVA and Kruskal-Wallis tests. One-way ANOVA is used to compare the means of three or more groups and tests if they are equal. It has assumptions of normality and equal variances. Kruskal-Wallis is a non-parametric alternative that compares medians instead of means and does not assume normality. An example uses chick weight data to demonstrate a one-way ANOVA comparing feed types, checking assumptions, and finding a significant difference between groups. A soils dataset demonstrates a Kruskal-Wallis test comparing nitrogen levels across contour types, which finds no significant difference.

Uploaded by

lim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

One-way ANOVA & Dr Elaine Chan Wan Ling

Kruskal-Wallis Test
One-way ANOVA (1)

• used to test the claim that three or more population means are equal
• Recall that T Test is for 2 samples comparison

• Null : μ1 = μ2 = μ3
• Alternative : μ1 ≠ μ2 ≠ μ3

• Factor = Categorical variables that defines group


• Eg. Treatments, Gender, Shape etc

• Responding variables = The variables used for comparison (continuous)


• E.g. blood sugar concentration, hormone level, weight etc
One-way ANOVA
(2)
• Analysis of variance
• Compare variance between groups vs
within group

↑ F value, ↓ P value
• Significant when variance between
groups > variance within group
Compare the household income
between Johor, Malacca and
Selangor

Example of
• Household income = Responding variables
• State = Factor

one-way
ANOVA
Compare the sodium level of Chips
Brand X, Y and Z

• Sodium level = Responding variables


• Brand of chips = Factor
Assumption of ANOVA
• Parametric Test
• Data is normally distributed
o Can be tested using Anderson-Darling Test
• H0: The data follows the normal distribution
• H1: The data do not follow the normal distribution
If the p value is low (e.g., <=0.05), you conclude that the data do
not follow the normal distribution.

• Variance is equal
o Can be tested using Levene Test
A resulting p-value under 0.05 means that variances are not equal 

• The data are randomly sampled

• Able to accept unequal sample size per group


Univariate – can only test for one parameter
at a given time

Can only test for one factor

Limitation of • Example:
• Difference of IQ across gender <- One-way ANOVA
One-way • Difference of IQ across gender and age group <-
Factorial ANOVA
ANOVA
ANOVA is an omnibus test
• Significant P imply that at least one pairing is different,
but the test will not tell which pair(s) is/are different
• E.g A vs B; B vs C; Avs C <- At least one pairing is
different, Need post hoc test
ANOVA using Rcmdr

• Remember that one way ANOVA is used to test


the hypothesis that there is at least one groups
different in the mean of the responding variables.
Data

Find “datasets” package and Load “chickwts” data

“chickwts” data recorded the chicken weight under different type of feeds
Check for normality

Anderson-Darling Test
Anderson-Darling Test
p-values adjusted by the Holm method:
unadjusted adjusted
casein 0.31428 1.00000
horsebean 0.50740 1.00000
linseed 0.90782 1.00000 > 0.05, Data is normally
distributed
meatmeal 0.88799 1.00000
soybean 0.53242 1.00000
sunflower 0.14775 0.88649
Check for equal variances

Levene Test
Levene’s Test
> leveneTest(weight ~ feed, data=chickwts, center="median")
Levene's Test for Homogeneity of Variance (center = "median")
Df F value Pr(>F)
group 5 0.7493 0.5896 > 0.05, Variance is equal

65
One-way ANOVA (1)
One-way ANOVA (2)

Pairwise Test

If Levene is significant
Result (1)
• > summary(AnovaModel.1) At least one group is
• Df Sum Sq Mean Sq F value Pr(>F) significant

• feed 5 231129 46226 15.37 5.94e-10 ***


• Residuals 65 195556 3009
• ---
• Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Result (2)
> with(chickwts, numSummary(weight, groups=feed, statistics=c("mean",
"sd")))
mean sd data:n
casein 323.5833 64.43384 12
horsebean 160.2000 38.62584 10
linseed 218.7500 52.23570 12 Summary

meatmeal 276.9091 64.90062 11


soybean 246.4286 54.12907 14
sunflower 328.9167 48.83638 12
Results (3)
Linear Hypotheses:
Estimate Std. Error t value Pr(>|t|)
horsebean - casein == 0 -163.383 23.485 -6.957 < 0.001 ***
linseed - casein == 0 -104.833 22.393 -4.682 < 0.001 ***
meatmeal - casein == 0 -46.674 22.896 -2.039 0.33195
soybean - casein == 0 -77.155 21.578 -3.576 0.00834 **
sunflower - casein == 0 5.333 22.393 0.238 0.99989 Pairs that are
linseed - horsebean == 0 58.550 23.485 2.493 0.14114 significant
meatmeal - horsebean == 0 116.709 23.966 4.870 < 0.001 ***
soybean - horsebean == 0 86.229 22.710 3.797 0.00430 **
sunflower - horsebean == 0 168.717 23.485 7.184 < 0.001 ***
meatmeal - linseed == 0 58.159 22.896 2.540 0.12741
soybean - linseed == 0 27.679 21.578 1.283 0.79297
sunflower - linseed == 0 110.167 22.393 4.920 < 0.001 ***
soybean - meatmeal == 0 -30.481 22.100 -1.379 0.73879
sunflower - meatmeal == 0 52.008 22.896 2.271 0.22047
sunflower - soybean == 0 82.488 21.578 3.823 0.00391 **
Boxplot
Kruskal-Wallis Test

• A non-parametric version of ANOVA


• Used when the data is not normally
distributed
• Test on the medium of “rank” rather than
mean
Testing using
Rcmdr
• Import “Soils” dataset from Car
Null: There is no
difference in soil
nitrogen across
contour
Alternative: There is a
difference in soil
nitrogen across
contour

Hypothesis
Test for normality
• Conduct Anderson-Darling Test

p-values adjusted by the Holm method:


unadjusted adjusted
Depression 0.0079325 0.016333
Slope 0.0054444 0.016333
Top 0.0745249 0.074525
Kruskal-Wallis Test
Results (1)
> with(Soils, tapply(N, Contour, median, na.rm=TRUE))
Depression Slope Top
0.0615 0.0845 0.0970

> kruskal.test(N ~ Contour, data=Soils)


Significant
Kruskal-Wallis rank sum test

data: N by Contour
Kruskal-Wallis chi-squared = 2.5739, df = 2, p-value = 0.2761
Result (2)
• Accept null
• No difference in soil N between top, slope, and depression.
Thank you

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy