1 / 16

Bivariate Testing (ANOVA) for Multiple Categories Comparison

Explore how to use ANOVA to compare the value of a quantitative variable across multiple categories. Learn about assumptions, hypotheses, and test statistics.

evelyns
Télécharger la présentation

Bivariate Testing (ANOVA) for Multiple Categories Comparison

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HMI 7530– Programming in R STATISTICS MODULE: Bivariate Testing (ANOVA) Jennifer Lewis Priestley, Ph.D. Kennesaw State University

  2. STATISTICS MODULE • Basic Descriptive Statistics and Confidence Intervals • Basic Visualizations • Histograms • Pie Charts • Bar Charts • Scatterplots • Ttests • One Sample • Paired • Independent Two Sample • Proportion Testing • ANOVA • Chi Square and Odds • Regression Basics 2 2 2

  3. STATISTICS MODULE: ANOVA What if we have more than two categories across which we want to compare the value of some quantitative variable? For example, lets say that we wanted to compare the mean weight loss of subjects who were put on one of four diet plans. For ease of discussion, lets call these plans A, B, C and D. 3

  4. STATISTICS MODULE: ANOVA The following approach would be tempting… H0: PlanA = PlanB H1: plan A  Plan B H0: PlanB = PlanC H1: plan B  Plan C H0: PlanC = PlanD H1: plan C  Plan D H0: PlanA = Plan C H1: plan A  Plan C H0: PlanA = PlanD H1: plan A  Plan D H0: PlanB = PlanD H1: plan B  Plan D 4

  5. STATISTICS MODULE: ANOVA …but wrong. Apart from being very cumbersome, there is a critical problem – we are inflating our probability of making a type 1 error. Think about that – lets use alpha = .05. If we ran 6 separate tests, that would generate a cumulative probability of a type 1 error of .3. We could lower the alpha value to .05/6 – I hear you saying. But this has its own problems – what happens if the number of tests increase to 8 or 10? Our alpha value would become so low, we would almost never reject the null (recall Power). 5

  6. STATISTICS MODULE: ANOVA Lets discuss how to use ANOVA to test a hypothesis by returning to our dieters… In this instance there are four levels (diet plans) to a single factor (weight loss). The hypothesis statements would look like this: H0: All level means are equal. In other words, all four of the diet plans generate approximately the same amount of weight loss. H1: Not all of the level means are equal. In other words, at least one of the plans’ weight loss mean is statistically significant different from the other plans’ means. 6

  7. STATISTICS MODULE: ANOVA Prior to executing the test, we must check for three important assumptions about our data: • All the groups are normally distributed. • All the populations sampled have approximately equal variance (you can check this by generating side-by-side boxplots). The rule of thumb is that the largest std is <2x the smallest std. • The samples of the groups are independent of each other and subjects within the groups were randomly selected. As with most, but not all, statistical tests, if our samples are large, we can relax our assumptions and work around non normal data. 7

  8. STATISTICS MODULE: ANOVA Lets examine the hypothesis statements in more detail: H0: µa = µb = µc =µd H1: µa ≠ µb ≠ µc ≠µd Consider – what would the hypothesized distributions look like under H0 and H1? 8

  9. STATISTICS MODULE: ANOVA Ok. We understand the concept, we have the hypotheses, we have the assumptions – we need a test statistic. In ANOVA, we use the F-distribution. In the science of statistics, whenever you need to evaluate a ratio of variances you will be using an F-statistic. The ratio in question here is: The variation BETWEEN the groups The variation WITHIN the groups Question – what kind of value would indicate difference versus no difference?

  10. STATISTICS MODULE: ANOVA PLAN Mean PLAN A 14 14 20 22 26 27 20.50 PLAN B 15 18 23 25 28 30 23.17 PLAN C 32 36 40 42 45 45 40.00 PLAN D 33 38 42 44 46 47 41.67 OVERALL MEAN 31.33 Returning to the diet plans… 10

  11. STATISTICS MODULE: ANOVA Our hypotheses statements would be: H0: The four diets plans have the same results (the mean weight loss is the same) H1: At least one of the diet plans has a different result (the mean weight loss is different) We will now calculate our test statistic: The variation BETWEEN the groups The variation WITHIN the groups 11

  12. STATISTICS MODULE: ANOVA To calculate the F-Statistic, we use the following table: 12

  13. STATISTICS MODULE: ANOVA For those who are interested: SST = SSW + SSB ij(Xij-X)2 = ij(Xij-Xj)2 +nj(Xj-X)2 _ _ _ 13

  14. STATISTICS MODULE: ANOVA For the present problem: 1 SSB = 6(10.832 + 8.172 + 8.672 +10.332) 2SSW = (159.50 + 166.83 + 134 + 141.33) = 601.67

  15. STATISTICS MODULE: ANOVA Now…what to do with an F-statistic of 24.33? This is a fairly strong statistic – recall that as the variance ratio approaches 1, the null is true. As the variance ratio grows larger than 1, we can more confidently reject the null. As with all test statistics, this result will translate into a p-value. The p-value associated with this statistic is less than .001. Based upon this result, we can confidently reject the null hypothesis and conclude that at least one of the results is different.

  16. STATISTICS MODULE: ANOVA We are going to use some simple ANOVA code: a1 <- aov (y ~ x) Where y is the quantitative continuous variable and x is the categorical variable with more than 3 levels. a1 summary(a1) require(graphics) summary(a1 <- aov((y ~ x)) TukeyHSD(a1, “x", ordered = TRUE) plot(TukeyHSD(a1, “x"))

More Related