L4 Anova

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

8/16/23

BES
1

Business and Economics Statistics


Lecture 4:
One-way Analysis of Variance

Intro One-way ANOVA technique Case study

BES
2

Outline

• A problem context
• One-way ANOVA technique
• Case study

Intro One-way ANOVA technique Case study

BES
3

A problem context
Which of two incentive packages will lead to higher use of a bank’s
credit cards? The bank designs a randomized comparative
experiment to compare two populations. Credit card customers are
assigned at random to receive one or the other incentive offer. After
six months, the bank compares the amounts charged.
For this problem:
• What are the populations to be compared?
• What inference technique should be considered?
change in 2 population (amt)
Mean (v)
Variance (v) / SD
Intro One-way ANOVA technique Case study
Proportion

1
8/16/23

BES
4

A problem context
Which of three incentive packages will lead to higher use of a bank’s
credit cards? The bank designs a randomized comparative
experiment to compare three populations. Credit card customers are
assigned at random to receive one of the three incentive offers. After
six months, the bank compares the amounts charged.
For this problem:
• What are the populations to be compared?
• Should we use the same inference technique as for the previous
problem?
1, Ha M1 =/= M2
2, M1 =/= M3
3, M2 =/= M3
Intro One-way ANOVA technique Case study

BES
5

Objective of ANOVA

ANOVA objective: to compare 2 or more population


means using 1 hypothesis test (the F test)

Intro One-way ANOVA technique Case study

BES
6

Terms and Notations


Factor: categorical variable used to define the groups
Factor levels: values of a factor (also called treatments or
groups)
Outcome variable: variable being compared

Please note that if the notations of slides and textbooks


differ, then follow your slides.

Intro One-way ANOVA technique Case study

2
8/16/23

BES
7

Terms and Notations


A researcher wishes to know whether different running-pacing
strategies (slow-fast/ fast-slow/ constant) affect the time to
complete a marathon.

Intro One-way ANOVA technique Case study

BES
8

Terms and Notations


Population 1 Population 2 Population k
Mean = µ1 Mean = µ2 Mean = µk
Variance =𝜎!" Variance =𝜎"" … Variance =𝜎#"
x11 x12 x1k
x21 x22 x2k Sample
. Sample . Sample …
. . size: nk
. size: n1 size: n2 .
. . %
.
xn1,1 xn2,2 𝑛 = & 𝑛# xnk,k
#$!

Mean =𝑥! Mean =𝑥" … Mean =𝑥#


Variance = 𝑠!" Variance = 𝑠"" Variance = 𝑠#"

Intro One-way ANOVA technique Case study

BES
9

One-way ANOVA hypotheses

ANOVA Hypotheses:
• Ho: µ1= µ2=…= µk
• Ha: At least 2 population means differ

We need to assess difference among population means

Intro One-way ANOVA technique Case study

3
8/16/23

BES
10

Comparing population means


Assessing difference among 3 population means

µ1 µ2 µ3

Ho: M1 = M2 = M3
Ha: at least 2 populations mean are differs
Estimate Estimate Estimate

Variation

𝑥' 𝑥( 𝑥)
Xbar1 = Xbar2 = Xbar3 --> Variance = 0
Intro One-way ANOVA technique Case study

10

BES
11

Measuring variation

• Case 1: we have only 2 numbers: e.g. 7 and 5

• Case 2: If we have a sample of more than 2 values,


for example: 3, 5, 10

• Recall how to calculate the sample variance:

∑%"#$(𝑥" − 𝑥)! 𝑆𝑢𝑚 𝑜𝑓 𝑠𝑞𝑢𝑎𝑟𝑒𝑑 𝑑𝑒𝑣𝑖𝑎𝑡𝑖𝑜𝑛𝑠


𝑠! = =
𝑛−1 𝑑𝑒𝑔𝑟𝑒𝑒𝑠 𝑜𝑓 𝑓𝑟𝑒𝑒𝑑𝑜𝑚

Intro One-way ANOVA technique Case study

11

BES
12

Measuring variation between sample means


𝑥̿

Variation
𝑥' 𝑥( 𝑥)

We measure variation 'between sample means by:


𝑆𝑆𝐺 = 9 𝑛& (𝑥& − 𝑥)̿ !
&#$

Intro One-way ANOVA technique Case study

12

4
8/16/23

BES
13

Measuring variation between sample means


• For k = 3, we have:

𝑆𝑆𝐺 = 𝑛$ (𝑥$ − 𝑥)̿ ! +𝑛! (𝑥! − 𝑥)̿ ! +𝑛( (𝑥( − 𝑥)̿ !


• Similar to the variance, we divide SSG by its df to obtain MSG, the
mean square for groups.

𝑆𝑆𝐺
𝑀𝑆𝐺 =
𝑘−1
• MSG is a kind of variance, which tells the variation among
sample means.

Intro One-way ANOVA technique Case study

13

BES
14

Measuring variation between sample means


o Ho: µ1 = µ2 =…= µk
o Ha: At least 2 population means differ

• First interpretation: Large value of MSG indicates large variation


between sample means, which provides evidence against Ho.

• Is MSG sufficient for us to make rejection decision?

Intro One-way ANOVA technique Case study

14

BES
15

Sources of variation

Total
SSG (and MSG) variation SSE (and MSE)

Between
Error
Groups
Intro One-way ANOVA technique Case study

15

5
8/16/23

BES
16

Sources of variation

Intro One-way ANOVA technique Case study

16

BES
17

One-way ANOVA
assumptions

• Samples are independent, simple random samples


CHECK
• All populations in question are normally distributed
• All population standard deviations are equal (s1 = s2 = …= sk = s)
ASSUMPTION
Intro One-way ANOVA technique Case study

17

BES
18

Let’s consider the t formula


To compare the means of 2 normal populations with unknown but
equal standard deviations, we have the formula:

(𝑥$ − 𝑥!)
𝑡=
1 1
𝑠* (𝑛 + 𝑛 )
$ !

𝑛$ − 1 𝑠$! + 𝑛! − 1 𝑠!!
where 𝑆*! =
𝑛$ + 𝑛! − 2

Intro One-way ANOVA technique Case study

18

6
8/16/23

BES
19

One-way ANOVA F Test


• Analogous to the t formula, in one-way ANOVA, we use:
𝑆𝑆𝐸 = (𝑛$ −1)𝑠$! + (𝑛! −1)𝑠!! + ⋯ + (𝑛' −1)𝑠'!

++, .+/
𝑀𝑆𝐸 = %-' ; 𝐹 = .+,
• F distribution
• F ranges from 0 to ¥
• A family of distributions
• Depends on 2 degrees of freedom
o 𝑑𝑓$ = numerator degrees of freedom
o 𝑑𝑓! = denominator degrees of freedom
Intro One-way ANOVA technique Case study

19

BES
20

Making rejection decision


.+/
• We use the ratio 𝐹 = .+, to make the decision.
• Differences among group means tend to make this ratio large.
• Therefore, we reject Ho if this ratio is large enough.
• If we can reject Ho à effect of the factor is significant
𝑝 − 𝑣𝑎𝑙𝑢𝑒 = 𝑃(𝐹 ≥ 𝐹𝑠𝑡𝑎𝑡𝑖𝑠𝑡𝑖𝑐 )
• We read p-value from software output, and compare it with our
significance level to make decision.

p-value < Alpha => reject Ho


Intro One-way ANOVA technique Case study

20

BES
21

F statistic

Intro One-way ANOVA technique Case study

21

7
8/16/23

BES
22

Exploring One-way ANOVA


via an applet

Exploring how F statistic and its p-value depend on both the variation
within the groups and the differences among the group means:
http://digitalfirst.bfwpub.com/stats_applet/stats_applet_1_anova.html

Intro One-way ANOVA technique Case study

22

BES
23

Checking One-way ANOVA assumptions


Samples are All populations All population
simple random are normally standard deviations
samples distributed are equal

S largest < 2 x S smallest

If largest sample SD <


Observe how twice smallest sample
the samples are Use Q-Q Plot,
Histogram, etc. SD à assume equal
selected
population SDs
Recommendation: use equal sample sizes
Intro One-way ANOVA technique Case study

23

BES
24

Limitation of ANOVA

An ANOVA F test only tells whether a difference exists


among population means, but does not tell where the
difference is.

Intro One-way ANOVA technique Case study

24

8
8/16/23

BES
25

Case study
A natural product can help bones. Kudzu is a plant that
was imported to the US from Japan and now covers over
seven million acres in the South. The plant contains
chemicals called isoflavones that have been shown to have
beneficial effects on bones. One study used three groups of
rats to compare a control group with rats that were fed either
a low dose or a high dose of isoflavones from kudzu. One of
the outcomes examined was the bone mineral density in
the femur (in grams per square centimeter). The data is
provided in the file named kudzu.csv.

Intro One-way ANOVA technique Case study

25

BES
26

Case study
bone Mineral bone Mineral bone Mineral
treatment treatment treatment
Density Density Density

1 Control 228 1 LowDose 211 1 HighDose 250


2 Control 207 2 LowDose 220 2 HighDose 237
3 Control 234 3 LowDose 211 3 HighDose 217
4 Control 220 4 LowDose 233 4 HighDose 206
5 Control 217 5 LowDose 219 5 HighDose 247
6 Control 228 6 LowDose 233 6 HighDose 228
7 Control 209 7 LowDose 226 7 HighDose 245
8 Control 221 8 LowDose 228 8 HighDose 232
9 Control 204 9 LowDose 216 9 HighDose 267
10 Control 220 10 LowDose 225 10 HighDose 261
11 Control 203 11 LowDose 200 11 HighDose 221
12 Control 219 12 LowDose 208 12 HighDose 219
13 Control 218 13 LowDose 198 13 HighDose 232
14 Control 245 14 LowDose 208 14 HighDose 209
15 Control 210 15 LowDose 203 15 HighDose 255
Intro One-way ANOVA technique Case study

26

BES
27

Case study

Questions

a. Explain why one-way ANOVA should be considered for


analysis of these data?

b. Produce some descriptive statistics for the data

c. Examine the assumptions necessary for one-way ANOVA.


d. Run the ANOVA and interpret the findings

Intro One-way ANOVA technique Case study

27

9
8/16/23

BES
28

R output
1-way frequency table of treatment variable:
Control LowDose HighDose
sample size = n = 15x3 = 45
15 15 15

The mean of boneMineralDensity for each level of treatment variable:


kudzu$treatment: Control
[1] 0.2188667 xbar1
---------------------------------------------------------------
kudzu$treatment: LowDose
[1] 0.2159333
xbar2
---------------------------------------------------------------
kudzu$treatment: HighDose xbar3
[1] 0.2350667

Intro One-way ANOVA technique Case study

28

BES R output
29

s largest < 2 x s smallest


s3 < 2 x s2
The standard deviation of boneMineralDensity for each level of treatment
variable: 0.01877... 2x0.01151...
kudzu$treatment: Control
[1] 0.01158735 s1
---------------------------------------------------------------
kudzu$treatment: LowDose
[1] 0.01151066 s2
---------------------------------------------------------------
-> the variances of 3 population are
kudzu$treatment: HighDose
[1] 0.01877105
s3
equal
Intro One-way ANOVA technique Case study

29

BES
30

R output
n1 = n2 = n3 = 15
Q-Q Plot of residuals
to examine normality
assumption

Intro One-way ANOVA technique Case study

30

10
8/16/23

BES
31

One-way ANOVA output


3 groups => k =3
One-way ANOVA output from R:
MSG F p-value
Df Sum Sq Mean Sq F value Pr(>F)
treatment 2 0.003186 0.0015928 7.718 0.0014 **
Residuals 42 0.008668 0.0002064 reject Ho when p-value < alpha
group ---
of error
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

F(alpha, k-1, n-k)


F = MSG / MSE(error)
Intro One-way ANOVA technique Case study

31

BES
32

The test procedure


Hypothesis M1 = M2 = M3
• H0 : All population means are equal (µ1 = µ1 = ... = µk )
• Ha : At least two population means are different.
Test statistic: F = MSG/MSE = 7.718
Assumptions:
1. Independent, simple random samples
2. All populations are normally distributed
3. All population variances are equal because s largest < 2x s smallest
Significance Level: α = 0.05

Intro One-way ANOVA technique Case study

32

BES
33

The test procedure


Decision Rule:
• Reject H0 if 𝑝 − 𝑣𝑎𝑙𝑢𝑒 ≤ 𝛼 p-value (0.0014) < 0.05
• Reject H0 if 𝐹 > 𝐹0,2+ ,2,
Conclusion: 7.718 > F(0.05,2,42) = 3.23

(Do not) reject H0


There is (not) enough evidence to conclude that at least two
population means are different.

Intro One-way ANOVA technique Case study

33

11
8/16/23

BES
34

Solution
Hypothesis
• H0: All population means are equal (µ1 = µ1 = ... = µk)
• Ha: At least two population means are different.
Test statistic: F =
Assumptions:
1. Independent, simple random samples
2. All populations are normally distributed
3. All population variances are equal
Significance Level: α
Decision Rule: Reject H0 if 𝑝 − 𝑣𝑎𝑙𝑢𝑒 ≤ 𝛼
Conclusion:
Intro One-way ANOVA technique Case study

34

BES
35

Conclusion

• A problem context
• One-way ANOVA technique
• Case study

Intro One-way ANOVA technique Case study

35

12

You might also like