{"id":250,"date":"2021-04-14T11:18:52","date_gmt":"2021-04-14T11:18:52","guid":{"rendered":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ziyang-yang\/?p=250"},"modified":"2021-04-30T12:14:13","modified_gmt":"2021-04-30T12:14:13","slug":"statistics-in-social-science3-step-by-step-tutorial-on-one-way-anova-test","status":"publish","type":"post","link":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ziyang-yang\/2021\/04\/14\/statistics-in-social-science3-step-by-step-tutorial-on-one-way-anova-test\/","title":{"rendered":"Statistics in Social Science(3): Step-by-Step tutorial on One-way ANOVA test"},"content":{"rendered":"\n
This blog will explain the one-way ANOVA test in detail (including assumptions, implementing situation and explanation), and an example analysed by R will be shown at the end.<\/span><\/p>\n\n\n\n You may be familiar with the t-test and some other nonparametric test used to test if there is a difference in the mean between two groups (e.g., if there is a difference in mean score between two classes; if one treatment is better than another treatment). The one-way analysis of variance (ANOVA) is used to determine if there is a significant difference among the means of three or more independent groups<\/strong>. For example, the application situation could be:<\/p>\n\n\n\n There is no free lunch. To implement the one-way ANOVA test, it should satisfy three assumptions:<\/p>\n\n\n\n All three test will be tested before implementing one-way ANOVA test. Now, let’s look at how to implementing ANOVA test through R.<\/p>\n\n\n\n Let’s use the dataset in R called ‘PlantGrowth’. It includes the weight of 30 plants with three groups (10 plants will not receive any treatment (control group), 10 plants receive treatment A, and 10 plants receive treatment B). And our purpose is to find if there is a difference in the mean effect among the three groups?<\/p>\n\n\n\n Firstly, lets draw a boxplot to see the data graphically.<\/p>\n\n\n\n From the boxplot, we could conclude that treatment 1 has a lower effect than the control group, but the difference is not too large. And plants received treatment 3 has a larger weight than the other two groups.<\/p>\n\n\n\n Next, we measure the difference through One-way ANOVA, and we got the result:<\/p>\n\n\n\n Under a 5% significance level, the P-value of the test is less than 0.05 (P=0.0159<0.05). So we could conclude there is a significant difference among groups. <\/p>\n\n\n\n However, we could only say there is a significant difference among groups, but we don\u2019t know which pairs of groups are different. To understand if there is a difference between specific pairs of groups, we could implement Tukey multiple pairwise-comparisons:<\/p>\n\n\n\n Under a 5% significance level, we could conclude that treatment 2 is significantly better than treatment1 on the mean weight of the plant. However, there is no statistical evidence that treatment 2 is better than treatment 1, and treatment 1 is worse than receiving no treatment.<\/p>\n\n\n\n Now lets check the assumptions:<\/p>\n\n\n\n That’s all done! This blog references the blog which including specific R code:<\/p>\n\n\n\n http:\/\/mathsbox.com\/notebooks\/python-utilities.html<\/a><\/p>\n\n\n\n Besides, I also found useful blogs which using SPSS to do one-way ANOVA test:<\/p>\n\n\n\nWhat is this test for?<\/h2>\n\n\n\n
Assumptions:<\/h2>\n\n\n\n
How to do it and explain it (An example in R)<\/h2>\n\n\n\n
<\/figure><\/div>\n\n\n\nres.aov <- aov(weight ~ group, data = data)\n# Summary of the analysis\nsummary(res.aov)\n Df Sum Sq Mean Sq F value Pr(>F) \ngroup 2 3.766 1.8832 4.846 0.0159 *\nResiduals 27 10.492 0.3886 \n---\nSignif. codes: 0 \u2018***\u2019 0.001 \u2018**\u2019 0.01 \u2018*\u2019 0.05 \u2018.\u2019 0.1 \u2018 \u2019 1<\/code><\/pre>\n\n\n\nInterpretation<\/h5>\n\n\n\n
TukeyHSD(res.aov)\n Tukey multiple comparisons of means\n 95% family-wise confidence level\nFit: aov(formula = weight ~ group, data = data)\n$group\n diff lwr upr p adj\ntrt1-ctrl -0.371 -1.0622161 0.3202161 0.3908711\ntrt2-ctrl 0.494 -0.1972161 1.1852161 0.1979960\ntrt2-trt1 0.865 0.1737839 1.5562161 0.0120064<\/code><\/pre>\n\n\n\nChecking the assumptions<\/h4>\n\n\n\n
<\/figure><\/div>\n\n\n\nshapiro.test(x = residuals(res.aov) )\n\n\tShapiro-Wilk normality test\n\ndata: residuals(res.aov)\nW = 0.96607, p-value = 0.4379<\/code><\/pre>\n\n\n\n
<\/figure><\/div>\n\n\n\nleveneTest(weight ~ group, data =data)\nLevene's Test for Homogeneity of Variance (center = median)\n Df F value Pr(>F)\ngroup 2 1.1192 0.3412\n 27 <\/code><\/pre>\n\n\n\n