In: Statistics and Probability
FiveThirtyEight, a website that tells interesting stories based on statistical analysis, recently published an article about candy rankings. To compare the sugar amounts in different types of candies, researchers randomly selected six brand name candies for three different types of candies: chocolate only, fruit‑flavored, and chocolate and nougat. The table lists the sugar percentages.
Chocolate Only | Fruit‑Flavored | Chocolate and Nougat |
---|---|---|
0.732 | 0.906 | 0.604 |
0.197 | 0.270 | 0.604 |
0.465 | 0.732 | 0.546 |
0.127 | 0.046 | 0.604 |
0.430 | 0.732 | 0.732 |
0.430 | 0.732 | 0.604 |
To find out whether the sugar percentages for these three types of candies are different, researchers conducted a Kruskal‑Wallis hypothesis test. State the distribution of the Kruskal‑Wallis test statistic, H, and use software to determine the value of .H. You might find some software manuals useful.
The sampling distribution for the Kruskal‑Wallis test statistic is approximately
with
degrees of freedom.
Calculate the test statistic. Round to three decimal places.
H=
H0: Sugar percentages for these three types of candies are same.
H1: Sugar percentages for these three types of candies are different.
Degree of freedom = Number of columns - 1 = 3 - 1 = 2
The sampling distribution for the Kruskal‑Wallis test statistic is approximately Chi Square distribution with 2 degrees of freedom.
Use the below code in R to run the Kruskal‑Wallis test.
# Load the data
sugar <- c(0.732,0.197,0.465,0.127,0.430,0.430,
0.906,0.270,0.732,0.046,0.732,0.732,
0.604,0.604,0.546,0.604,0.732,0.604)
# Create vectors of factors (5 levels) for Lake varieties
candies=factor(c(rep(1,6),rep(2,6),rep(3,6)))
# Run the Kruskal-Wallis test
kruskal.test(sugar~candies)
The output of the code is,
Kruskal-Wallis rank sum test
data: sugar by candies
Kruskal-Wallis chi-squared = 3.2985, df = 2, p-value = 0.1922
From the output, the test statistic H = 3.299
p-value = 0.1922
Since p-value is greater than the significance level of 0.05, we fail to reject the null hypothesis and conclude that there is no significant evidence that sugar percentages for these three types of candies are different.