68
BS704 Class 8 Analysis of Variance

BS704 Class 8 Analysis of Variance

  • Upload
    leyna

  • View
    17

  • Download
    0

Embed Size (px)

DESCRIPTION

BS704 Class 8 Analysis of Variance. HW Set #7. Chapter 7 Problems 5, 14, 19 and 28 R Problem Set 7 (on Blackboard) Due November 2 Please complete Quiz 9 Before Nov 2. An RCT to Assess the Efficacy of a New Drug for Asthma in Children. Background characteristics Age Sex - PowerPoint PPT Presentation

Citation preview

Page 1: BS704 Class 8 Analysis  of Variance

BS704 Class 8Analysis of Variance

Page 2: BS704 Class 8 Analysis  of Variance

HW Set #7Chapter 7Problems 5, 14, 19 and 28R Problem Set 7 (on Blackboard)Due November 2

Please complete Quiz 9 Before Nov 2

Page 3: BS704 Class 8 Analysis  of Variance

An RCT to Assess the Efficacy of a New Drug for Asthma in Children Background characteristics

Age Sex Years since diagnosis of asthma

Outcomes Self-reported improvement in symptoms FEV1

Page 4: BS704 Class 8 Analysis  of Variance

Did the randomization work?

Yes No

0%0%

1. Yes2. No

Characteristic Placebo New Drug pAge, years 10 (2.4) 9.9 (2.1) .76 % Male 54% 43% .04Yrs since Dx 3.4 (1.9) 3.1 (2.1) .34

Page 5: BS704 Class 8 Analysis  of Variance

What are hypotheses to compare ages?

H0:m1=

m2 vs H

1:m...

0% 0%0%0%

Characteristic Placebo New Drug pAge, years 10 (2.4) 9.9 (2.1) .76 % Male 54% 43% .04Yrs since Dx 3.4 (1.9) 3.1 (2.1) .34

1. H0:m1=m2 vs H1:m1≠m2

2. H0:p1=p2 vs H1:p1≠p2

3. H0:m=10 vs H1:m≠104. H0:md=0 vs H1:md≠0

Page 6: BS704 Class 8 Analysis  of Variance

What test would be used to compare % improvement between groups?

Test fo

r equali

ty of ..

.

Test fo

r equali

ty of p

...

Test fo

r mea

n diffe

rence

No clue

0% 0%0%0%

1. Test for equality of means2. Test for equality of

proportions3. Test for mean difference4. No clue

Page 7: BS704 Class 8 Analysis  of Variance

What test would be used to compare FEV1 between groups?

Test fo

r equali

ty of ..

.

Test fo

r equali

ty of p

...

Test fo

r mea

n diffe

rence

No clue

0% 0%0%0%

1. Test for equality of means2. Test for equality of

proportions3. Test for mean difference4. No clue

Page 8: BS704 Class 8 Analysis  of Variance

Objectives Understand the procedure for testing

the equality of k > 2 means Perform the test by hand and using R Appropriately interpret results

Page 9: BS704 Class 8 Analysis  of Variance

Hypothesis Testing Procedures1. Set up null and research

hypotheses, select a2. Select test statistic3. Set up decision rule4. Compute test statistic5. Draw conclusion & summarize

significance (p-value)

Page 10: BS704 Class 8 Analysis  of Variance

Hypothesis Testing for More than 2 Means - Analysis of Variance Continuous outcome k Independent Samples, k > 2

H0: m1=m2=m3 … =mk

H1: Means are not all equalTest Statistic

(Find critical value in Table 4)

k)/(N)XΣΣ(X1)/(k)XX(Σn

F 2j

2jj

=

Page 11: BS704 Class 8 Analysis  of Variance

Test Statistic - F Statistic Comparison of two estimates of variability in

data Between treatment variation, is based on the

assumption that H0 is true (i.e., population means are equal)

Within treatment, Residual or Error variation, is independent of H0 (i.e., we do not assume that the population means are equal and we treat each sample separately)

Page 12: BS704 Class 8 Analysis  of Variance

F Statistic

k)/(N)XΣΣ(X1)/(k)XX(Σn

F 2j

2jj

=

Difference BETWEEN each group mean and overall mean

Difference between each observation and its group mean (WITHIN group variation - ERROR)

Page 13: BS704 Class 8 Analysis  of Variance

F Statistic

F = MSB/MSE

MS = Mean Square

What values of F that indicate H0 is likely true?

Page 14: BS704 Class 8 Analysis  of Variance

Decision Rule

Reject H0 if F > Critical Value of F with df1=k-1 and df2=N-k from Table 4

k= # comparison groupsN=Total sample size

Page 15: BS704 Class 8 Analysis  of Variance
Page 16: BS704 Class 8 Analysis  of Variance

ANOVA TableSource of Sums of MeanVariation Squares df Squares F

BetweenTreatments k-1 SSB/k-1

MSB/MSE

Error N-k SSE/N-k

Total N-1

)X - X( n Σ = SSB j2

j

)X - X( Σ Σ = SSE j2

)X -X( Σ Σ = SST 2

Page 17: BS704 Class 8 Analysis  of Variance

ExampleIs there a significant difference in mean weight loss among 4 different diet programs? (Data are pounds lost over 8 weeks)

Low-Cal Low-Fat Low-Carb Control8 2 3 29 4 5 26 3 4 -17 5 2 03 1 3 3

Page 18: BS704 Class 8 Analysis  of Variance

ExampleSummary Statistics on Weight Loss by

Treatment

Low-Cal Low-Fat Low-CarbControl

n 5 5 5 5Mean 6.6 3.0 3.4 1.2

Overall Mean = 3.6

Page 19: BS704 Class 8 Analysis  of Variance

Is there a statistically significant difference in weight loss programs?

Yes No ??

0% 0%0%

1. Yes2. No3. ??

Page 20: BS704 Class 8 Analysis  of Variance

Example1. H0: m1=m2=m3=m4

H1: Means are not all equal a=0.05

2. Test statistic

k)/(N)XΣΣ(X1)/(k)XX(Σn

F 2j

2jj

=

Page 21: BS704 Class 8 Analysis  of Variance

Example3. Decision rule

df1=k-1=4-1=3df2=N-k=20-4=16

Reject H0 if F > 3.24

Page 22: BS704 Class 8 Analysis  of Variance

Example

)X - X( n Σ = SSB j2

j

=5(6.6-3.6)2+5(3.0-3.6)2+5(3.4-3.6)2+5(1.2-3.6)2

= 75.8

Page 23: BS704 Class 8 Analysis  of Variance

Example)X - X( Σ Σ = SSE j

2

Low-Cal (X-6.6) (X-6.6)2

8 1.4 2.09 2.4 5.86 -0.6 0.47 0.4 0.23 -3.6 13.0

Total 0 21.4

Page 24: BS704 Class 8 Analysis  of Variance

Example)X - X( Σ Σ = SSE j

2

Low-Fat (X-3.0) (X-3.0)2

2 -1.0 1.04 1.0 1.03 0 05 2.0 4.01 -2.0 4.0

Total 0 10.0

Page 25: BS704 Class 8 Analysis  of Variance

Example)X - X( Σ Σ = SSE j

2

Low-Carb (X-3.4) (X-3.4)2

3 -0.4 0.25 1.6 2.64 0.6 0.42 -1.4 2.03 -0.4 0.2

Total 0 5.4

Page 26: BS704 Class 8 Analysis  of Variance

Example)X - X( Σ Σ = SSE j

2

Control (X-1.2) (X-1.2)2

2 0.8 0.62 0.8 0.6-1 -2.2 4.80 -1.2 1.43 1.8 3.2

Total 0 10.6

Page 27: BS704 Class 8 Analysis  of Variance

Example

)X - X( Σ Σ = SSE j2

=21.4 + 10.0 + 5.4 + 10.6 = 47.4

Page 28: BS704 Class 8 Analysis  of Variance

ExampleSource of Sums of MeanVariation Squares df Squares F

Between 75.8 3 25.3 8.43Treatments

Error 47.4 16 3.0

Total 123.2 19

Page 29: BS704 Class 8 Analysis  of Variance

Example4. Compute test statistic

F=8.43

5. Conclusion. Reject H0 because 8.43 > 3.24. We have statistically significant evidence at a=0.05 to show that there is a difference in mean weight loss among 4 different diet programs.

Page 30: BS704 Class 8 Analysis  of Variance

ANOVA Using R.csv data file

Page 31: BS704 Class 8 Analysis  of Variance

ExampleAn investigator wishes to compare the average time to relief of headache pain under three distinct medications, A, B and C.

Fifteen patients who suffer from chronic headaches are randomly selected for the investigation.

The outcome is time to pain relief, in minutes.

Page 32: BS704 Class 8 Analysis  of Variance

One Way ANOVARCT to Compare 3 Medications for

Chronic Pain N=15Randomize

A BC

Outcome: Time to Pain Relief, minutes

Page 33: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)Data

Drug A Drug B Drug C30 25 1535 20 2040 30 2525 20 2035 30 20

Mean 33.0 25.0 20.0

Page 34: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)1. Hypotheses

H0: m1 = m2 = m3

H1: means not all equal a=0.05

2. Test Statistic F

Page 35: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)3. Decision Rule

K-1=3-1=2, N-k=15-3=12Reject H0 if F > 3.89

4. Compute Sums of Squares

Page 36: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)

)X - X( n Σ = SSB j2

j

26.0 = 3

20.0) + 25.0 + (33.0=X..

= 5((33-26.0)2 + (25-26.0)2 + (20-26.0)2) = 430

)X - X( Σ Σ = SSE j2

Page 37: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)Drug A

X (X-33) (X-33)2

30 -3 935 -2 440 7 4925 -8 6435 -2 4

0 130

Page 38: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)Drug B

X (X-25) (X-25)2

25 0 120 -5 2530 5 2520 -5 2530 5 25

0 100

Page 39: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)Drug C

X (X-20) (X-20)2

15 -5 2520 0 025 5 2520 0 020 0 0

0 50

Page 40: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)

= 130+100+50 = 280

Source SS df MS FBetween 430.0 2 215 9.21Error 280.0 12 23.3Total 710.0 14

)X - X( Σ Σ = SSE j2

Page 41: BS704 Class 8 Analysis  of Variance

One Way ANOVA (cont’d)

Reject H0 since 9.21 > 3.89 – Means are not all equal.

Page 42: BS704 Class 8 Analysis  of Variance

Paper – Testosterone Replacement Study design?

RCT Number of comparison groups?

-placebo, no exercise-testosterone, no exercise-placebo and exercise -testosterone and exercise

Primary outcomes? Change in muscle strength, body weight, muscle

volume, lean body mass (continuous)

Page 43: BS704 Class 8 Analysis  of Variance

Paper – Testosterone Replacement Objective is to compare mean change in

muscle strength, body weight, muscle volume, lean body mass (One at a time) across four treatment groups

Figure 1 – generalizability?

Page 44: BS704 Class 8 Analysis  of Variance
Page 45: BS704 Class 8 Analysis  of Variance

Paper – Testosterone Replacement Table 1 – what tests were used?

Table 2 – what tests were used?

Page 46: BS704 Class 8 Analysis  of Variance
Page 47: BS704 Class 8 Analysis  of Variance
Page 48: BS704 Class 8 Analysis  of Variance

Practice Problem – Complete the ANOVA TableH0: m1=m2=m3=m4=m5

H1: means not all equal a=0.05

Source SS df MS FBetweenWithin 50 2.5Total 225

Page 49: BS704 Class 8 Analysis  of Variance

Practice Problem – Complete the ANOVA TableH0: m1=m2=m3=m4=m5H1: means not all equal a=0.05

Source SS df MS FBetween 100 4 25

10Within 125 50 2.5Total 225Reject H0 if F > F0.05(4,50)=2.56

Page 50: BS704 Class 8 Analysis  of Variance

ANOVA When the sample sizes are equal, the

design is said to be balanced Balanced designs give greatest power

and are more robust to violations of the normality assumption

Page 51: BS704 Class 8 Analysis  of Variance

Extensions Multiple Comparison Procedures –

Used to test for specific differences in means after rejecting equality of all means

Higher-Order ANOVA - Tests for differences in means as a function of several factors

Page 52: BS704 Class 8 Analysis  of Variance

Extensions Repeated Measures ANOVA - Tests for

differences in means when there are multiple measurements in the same participants (e.g., measures taken serially in time)

Page 53: BS704 Class 8 Analysis  of Variance

Multiple Comparisons Procedures (MCPs)If we reject H0 in an ANOVA – we

conclude that the k means are not all equal. Which means are different?

Pairwise comparisons H0: mi=mj

General contrasts H0: (mi+mj)/2=mk

Page 54: BS704 Class 8 Analysis  of Variance

MCPs (continued) With k treatments there are k(k-1)/2

possible pairwise comparisons The overall Type I error rate can be as

large as a{k(k-1)/2}!

There are a number of different MCPs – they differ in terms of treatment of Type I error rate

Page 55: BS704 Class 8 Analysis  of Variance

MCPs (continued)Error rate per comparison (ER_PC) = P(Type I error) on any one test or

comparison (usually ER_PC is 0.05).

Error rate per experiment (ER_PE) =the number of Type I errors we

expect to make in any experiment under H0 (in 100 tests, we expect to make 5 Type I errors = #tests(a)).

Page 56: BS704 Class 8 Analysis  of Variance

MCPs (continued)Familywise error rate (FW_ER)=P(at least 1 Type I error) in experiment.

FW_ER =1 - (1-ai)c,

where ai is the ER_PC c=# contrasts in experiment.

Page 57: BS704 Class 8 Analysis  of Variance

MCPs (continued)Example. Suppose we test the equality of 5

treatment means using ANOVA and the null hypotheses is rejected at a = 0.05.

Suppose that it is of interest to perform all pairwise comparisons.

There are k(k-1)/2 = 5(5-1)/2 = 10 distinct pairwise comparisons.

Page 58: BS704 Class 8 Analysis  of Variance

MCPs (continued)Suppose we wish to conduct each comparison at a

5% level of significance.

NOTE: Only tests that are of substantive interest should be run and not all possible tests.

ER_PC = 0.05. ER_PE = 10(0.05) = 0.5.FW_ER = 1 - (1 - 0.05)10 = 0.401.

Page 59: BS704 Class 8 Analysis  of Variance

Scheffe MCP Conservative procedure that controls

familywise error rate regardless of the number of contrasts

Handles both pairwise and general contrasts Other MCPs include the Tukey procedure,

Duncan procedure (multiple range test), Fisher's Least Significant Difference, the Newman-Keuls test, and Dunnett's test (used to compare a control to several active treatments).

Page 60: BS704 Class 8 Analysis  of Variance

Scheffe MCPFor pairwise tests

H0: mi = mj H1: mi ≠ mj

Reject H0 if F > (k-1) Fa (k-1, N-k)

n1 +

n1 MSE

)X - X( = F

ji

2.j.i

Page 61: BS704 Class 8 Analysis  of Variance

One Way ANOVA-ScheffeIn Example we determined 3 drugs were significantly different with respect to mean time to pain relief

Drug A Drug B Drug CMean 33.0 25.0 20.0

Which drugs are different?

Page 62: BS704 Class 8 Analysis  of Variance

Scheffe Test – Drug A Vs. BH0: mA = mB H1: mA ≠ mB

Reject H0 if F > (k-1) Fa (k-1, N-k) (k-1) F 0.05 (2,12) = 2(3.89) = 7.78

n1 +

n1 MSE

)X - X( = F

BA

2BA

Page 63: BS704 Class 8 Analysis  of Variance

Scheffe Test – Drug A Vs. B

87.6

51

513.23

)0.250.33(

n1 +

n1 MSE

)X - X( = F2

BA

2BA =

=

Do not reject H0 since 6.87<7.78. No significant difference in mean times to pain relief for Drugs A and B.

Page 64: BS704 Class 8 Analysis  of Variance

Scheffe Test – Drug A Vs. CH0: mA = mC H1: mA ≠ mC

Reject H0 if F > (k-1) Fa (k-1, N-k) (k-1) F 0.05 (2,12) = 2(3.89) = 7.78

n1 +

n1 MSE

)X - X( = F

CA

2CA

Page 65: BS704 Class 8 Analysis  of Variance

Scheffe Test – Drug A Vs. C

13.18

51

513.23

)0.200.33(

n1 +

n1 MSE

)X - X( = F2

CA

2CA =

=

Reject H0 since 18.13>7.78. Significant difference in mean times to pain relief for Drugs A and C.

Page 66: BS704 Class 8 Analysis  of Variance

Scheffe Test – Drug B Vs. CH0: mB = mC H1: mB ≠ mC

Reject H0 if F > (k-1) Fa (k-1, N-k) (k-1) F 0.05 (2,12) = 2(3.89) = 7.78

n1 +

n1 MSE

)X - X( = F

CB

2CB

Page 67: BS704 Class 8 Analysis  of Variance

Scheffe Test – Drug B Vs. C

68.2

51

513.23

)0.200.25(

n1 +

n1 MSE

)X - X( = F2

CB

2CB =

=

Do not reject H0 since 2.68<7.78. No significant difference in mean times to pain relief for Drugs B and C.

Overall conclusion??

Page 68: BS704 Class 8 Analysis  of Variance

Tukey Test in RANOVA Pairwise Tests using Tukey MCP

Only significant result is A vs C