Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 26

CLASS IX

Hypothesis Testing – III


Analysis of Variance
Where we’re headed: Bivariate relationships
 We’ll be talking about bivariate relationships
over the next several weeks
 Bivariate = two variables
 We’ll practice identifying the variables and the
values of each variable.
 Level of measurement will be important
 You’ll ask yourself: What are the variables? What’s
the level of measurement for each?
 Bivariate relationships can be:
 Grouped/ grouped
 Grouped/ continuous
 Continuous /continuous
In fact, we’ve already started talking about
bivariate relationships
Is there a difference in waiting times between the two clinics?
WESTSIDE CLINIC: NW = 100; XW = 34 minutes; sW = 4
EASTSIDE CLINIC : NE = 100; XE = 30 minutes; sE = 3

Clinic location Waiting time

Grouped Continuous
2 values

Do teens who receive summer job training earn more than teens who do not
receive summer job training?
TEENS WITH TRAINING: NT = 15; XT = $5,500; sT = 600
COMPARISION GROUP: NC = 20; XC = $5,200; sC = 1,000

Training (Y/N) Earnings

Grouped Continuous
2 values
Did the Family Planning Intervention decrease the proportion of young
women who gave birth to another child within 18 months?
Women who received post-partum education: NE = 300; PSE = .32
Comparison group of women: NC = 200; PSC = .36

Intervention (Y/N) Birth within 18 mos (Y/N)


Grouped Grouped
2 values 2 values
Today, we extend grouped/ continuous, to
include grouped variables with more than 2
values
Last class …..
Is there a difference in waiting times between the two clinics?
WESTSIDE CLINIC: NW = 100; XW = 34 minutes; sW = 4
EASTSIDE CLINIC : NE = 100; XE = 30 minutes; sE = 3
Clinic location Waiting time
Grouped Continuous
2 values

This class …..


Is there a difference in waiting times between the three clinics?

WESTSIDE CLINIC: NW = 100; XW = 34 minutes; sW = 4


EASTSIDE CLINIC : NE = 100; XE = 30 minutes; sE = 3
SOUTHSIDE CLINIC: NS = 100; XS = 28 minutes, ss = 5
Clinic location Waiting time

Grouped
3 values Continuous
ANOVA (ANalysis Of Variance)
is used to analyze bivariate relationships
between grouped/ continuous variables

VARIABLE 1 VARIABLE 2
Grouped Continuous
many values
EXAMPLES OF QUESTIONS THAT CAN BE
ADDRESSED BY ANOVA:

• I am exploring the relationship of obesity to


race/ethnicity. If I want to compare the average Body-Mass
Index (BMI) of Blacks and Whites, I can use a t-test or
ANOVA (we will compare these two tests later!). But if I
want to to compare Blacks, Whites, and Latinos, I would
need to use ANOVA.

• I would like to know whether average waiting time for the


subways varies by time of the day. I can compare rush hour
to non-rush hour waiting times using t-tests or ANOVA, but if
I want to compare weekend hours, weekday rush hours, and
weekday nights, I would turn to ANOVA.

• I am curious as to whether crime rates vary across urban,


suburban, and rural locales. ANOVA would let me look for
such a relationship.
THE INTUITION BEHIND ANOVA

When there are true differences between groups, the


variability between the groups is much larger than
variability within the groups.
OUR INTUITION, AS THE B:W RATIO

“.. When there are true differences between


groups, the variability between the groups is much
larger than variability within the groups….”

Let’s let B stand for variability between the groups, and


W stand for variability within the groups
ANOVA NOTATION

In ANOVA problems:

There are k groups


Each of the groups has Nk observations
Each group has a mean of Xk (the “group mean”)

In the whole sample, there are a total of N observations


Each observation in the sample can be called Xi
In the whole sample, the mean is X (the “grand mean”)

For example, does the number of siblings differ in the


Zoom breakout groups?
BREAKOUT EXERCISE TO UNDERSTAND THE NOTATION FOR ANOVA

 We will break out into k groups


 Each group will choose a captain
 Captain records:
 k (the Zoom group number for the group)
 Nk (the number of people in kth group)
 Captain asks each group member the number of siblings
they have (each group member provides their X i)
 Captain calculates Xk, the mean for the kth group
 Captain summarizes for_the group what she has done
 When we return, each captain reports their group’s k,
Nk, Xk

_
Breakout #1
BREAKOUT EXERCISE
WITH GROUP REPORT-OUTS

_
k Nk Xk (all the Xi’s)

_
The mean for the whole class (the grand mean) X = __
ANOVA LANGUAGE: “SUM OF SQUARES”

SST = SSW + SSB

In the siblings example:


(You - Class mean) = (You - Group mean) + (Group mean – Class mean)

Some algebra that you’ll see in formulas:

SST =  (Xi – X )2 ; or Xi2 – NX2

SSW =  (Xi – Xk)2

SSB =  Nk (Xk – X)2


AGAIN …. OUR INTUITION, AS THE B:W RATIO

“.. When there are true differences between


groups, the variability between the groups is much
larger than variability within the groups….”

Let’s let B stand for variability between the groups, and


W stand for variability within the groups
ANOVA AND STATISTICAL SIGNIFICANCE
How do we know if the difference between groups is statistically
significant?
If SSB is large relative to SSW, the ratio of between/within will be
greater than 1.

Mean square between Note an error in your text, Table 10.4 #6


Fobt = should say MSB/MSW.
Mean square within

Mean square between = SSB / dfb


dfb stands for degrees of freedom between, or k – 1
(the number of categories minus 1)

Mean square within = SSW / dfw


dfw stands for degrees of freedom within, or N – k
(the number of cases minus the number of categories)

We compare Fobt to Fcrit to tell us if between/within ratio is


sufficiently large (sufficiently greater than 1) to be “statistically
F-TABLE
APPENDIX D

This gives us
Fcrit
THE F DISTRIBUTION

NOTE THAT THE SHAPE IS A FUNCTION OF (N 1, N2)


That is, there is a family of F-distributions
For discussion:
Where is the probability highest? Why?
Where is the probability lowest? Why?
Steps to calculating the F ratio (Fobtained)

1. Calculate SST using a computational formula for SST:


SST = X2 – NX2

2. Calculate SSB:
SSB =  Nk (Xk – X)2

3. Calculate SSW:
SSW = SST – SSB

4. Calculate the degrees of freedom:


dfb = k – 1
dfw = N – k

5. Calculate Mean Square Within (MSW) and Mean Square Between (MSB):
MSW = SSW/dfw
MSB = SSB/dfb

6. Find the F obtained:


Fobtained = MSB / MSW
ANOVA – AN EXAMPLE:

Does the distribution of body weight (or Body Mass Index) differ by mode
of commuter transportation? We looked at a random sample of 15 New
Yorkers. Here are the data and necessary calculations. (Note: a BMI of 25
or more is considered overweight)

Walkers Subway/Bus Car


X X2 X X2 X X2
19 361 21 441 31 961
26 676 26 676 25 625
22 484 25 625 25 625
25 625 22 484 24 576
22 484 25 625 20 400
 X= 114 119 125
X2= 2630 2851 3187

Xk = 22.8 23.8 25
X = 23.866666 =
23.8667
Finding the F ratio (Fobtained), for the example
At your desk: connect the calculations below with the
numbers on the previous slide
SST = X2 – NX2
= (2630 + 2851 + 3187) – (15)(23.8667) 2
= 8668 – (15)(569.6194)
= 123.7333

SSB =  Nk (Xk – X)2


= (5)(22.8 – 23.8667)2 + (5)(23.8 – 23.8667)2 +
(5)(25 – 23.8667)2
= (5 * 1.1378) + (5 * 0.0044) + (5 * 1.2844)
= 12.1333

SSW = SST – SSB


= 123.7333 – 12.1333 = 111.6000

dfw = N – k = 15 – 3 = 12
dfb = k – 1 = 2

Mean Square Within = SSW/dfw = 111.6000 / 12 = 9.2994


Mean Square Between (MSB) = SSB/dfb = 12.1333 / 2 = 6.0667

F(obtained) = MSB / MSW = 6.0667 / 9.2994 = 0.6515 = 0.65


USING THE FIVE-STEP MODEL OF HYPOTHESIS TESTING
– ANOVA EXAMPLE -
• Step 1 --- Make assumptions

Independent random samples


Level of measurement is interval-ratio
Populations are normally distributed
Population variances are equal

• Step 2 --- Stating the hypotheses

H0: 1 = 2 = 3
H1: At least one of the population means are different

• Step 3 --- Selecting the sampling distribution and establishing the critical region

F distribution,  = .05
dfw = 12 dfb = 2
F(critical) = 3.88

• Step 4 --- Computing the test statistic

F(obtained) = 0.65

•Step 5 --- Making a decision… F(obtained) < F(critical)


Because Fobtained does not fall within the critical region, we cannot
reject Ho.
Conclude that there is insufficient evidence that BMI differs significantly
by mode of transportation.
Two ways to approach a two-group difference of means

When just two groups are being compared, you could use
•t- or z-test (Week 7)
H0: 1 = 2

•ANOVA (this week)


H0: 1 = 2

These are the same null hypotheses. Are the results of the
significance tests the same?
•Yes, if the t- or z- test is 2-tailed (H1: 1 ≠ 2)
•No, if the test is 1-tailed (H1: 1 = 2 or H1: 1 > 2)

Bottom line: Results of the significance tests are the same if


the t- or z-test is 2-tailed.
SOME LIMITATIONS TO ANOVA

• You must have an interval level dependent measure.

•The model assumptions… especially regarding the normal


distribution of the population… are not often upheld in practice.

With roughly equal sample sizes, the assumptions can be slightly


violated. But in cases where the underlying distribution is not
normal and/or the population variances are not equal, ANOVA
should not be used.

•Even when ANOVA finds a statistically significant difference, it does


not specify which differences (that is, between which categories or
groups) are significant.

A post-hoc analysis can help address this limitation. Post-hoc


tests compare the means of all possible pairs of categories and
tell us which combinations of means contribute the most to a
significant F ratio. Since making many comparisons of sample
means increases the probability of chance errors, one must use
higher significance levels to compensate.
Encore!
In Stat 1 this week
 This week’s lab is important
 There are two videos to watch in advance, covering
material from Classes 6, 7 and 9. Note that videos & lab
also cover material beyond the Healey text (p values).
 Homework this week is Stata intensive – allocate
a good chunk of time to complete it
 Before class next week
 Do your usual preparation: video, reading, mini-quiz
 Review the final assignment document: we will review
it during lecture and lab.
Practice
problem

You might also like