Exp Design

80
Experimental Design and the Analysis of Variance

description

OK

Transcript of Exp Design

Page 1: Exp Design

Experimental Design and the Analysis of Variance

Page 2: Exp Design

Comparing t > 2 Groups - Numeric Responses

• Extension of Methods used to Compare 2 Groups• Independent Samples and Paired Data Designs• Normal and non-normal data distributions

DataDesign

Normal Non-normal

IndependentSamples(CRD)

F-Test1-WayANOVA

Kruskal-Wallis Test

Paired Data(RBD)

F-Test2-WayANOVA

Friedman’sTest

Page 3: Exp Design

Completely Randomized Design (CRD)

• Controlled Experiments - Subjects assigned at random to one of the t treatments to be compared

• Observational Studies - Subjects are sampled from t existing groups

• Statistical model yij is measurement from the jth subject from group i:

ijiijiijy

where is the overall mean, i is the effect of treatment i , ij is a random error, and i is the population mean for group i

Page 4: Exp Design

1-Way ANOVA for Normal Data (CRD)

• For each group obtain the mean, standard deviation, and sample size:

1

)( 2.

.

i

jiij

ii

jij

i n

yy

sn

y

y

• Obtain the overall mean and sample size

N

y

N

ynynynnN i j ijtt

t

..11

..1

......

Page 5: Exp Design

Analysis of Variance - Sums of Squares

• Total Variation

1)(1 1

2..

NdfyyTSS Total

k

i

n

j iji

• Between Group (Sample) Variation

t

i

n

j

t

i Tiiii tdfyynyySST

1 1 1

2...

2... 1)()(

• Within Group (Sample) Variation

ETTotal

E

t

i ii

t

i

n

j iij

dfdfdfSSESSTTSS

tNdfsnyySSE i

1

2

1 1

2. )1()(

Page 6: Exp Design

Analysis of Variance Table and F-TestSource ofVariation Sum of Squares

Degrres ofFreedom Mean Square F

Treatments SST t-1 MST=SST/(t-1) F=MST/MSEError SSE N-t MSE=SSE/(N-t)Total TSS N-1

• Assumption: All distributions normal with common variance

•H0: No differences among Group Means (t =0)

• HA: Group means are not all equal (Not all i are 0)

)(:

)9(:..

:..

,1,

obs

tNtobs

obs

FFPvalP

TableFFRRMSE

MSTFST

Page 7: Exp Design

Expected Mean Squares

• Model: yij = +i + ij with ij ~ N(0,2), i = 0:

1)(

)( true),is ( otherwise

1)(

)( true,is 0:When

)1(11

)(

)(

1

)(

)(

10

21

2

2

1

2

2

1

2

2

2

MSEE

MSTEH

MSEE

MSTEH

t

nt

n

MSEE

MSTE

t

nMSTE

MSEE

a

t

t

iii

t

iii

t

iii

Page 8: Exp Design

Expected Mean Squares

• 3 Factors effect magnitude of F-statistic (for fixed t)– True group effects (1,…,t)

– Group sample sizes (n1,…,nt)

– Within group variance (2)

• Fobs = MST/MSE

• When H0 is true (1=…=t=0), E(MST)/E(MSE)=1 • Marginal Effects of each factor (all other factors fixed)

– As spread in (1,…,t) E(MST)/E(MSE)

– As (n1,…,nt) E(MST)/E(MSE) (when H0 false)

– As 2 E(MST)/E(MSE) (when H0 false)

Page 9: Exp Design

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0 20 40 60 80 100 120 140 160 180 200

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0 20 40 60 80 100 120 140 160 180 200

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0 20 40 60 80 100 120 140 160 180

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0 20 40 60 80 100 120 140 160 180 200

A)=100, 1=-20, 2=0, 3=20, = 20 B)=100, 1=-20, 2=0, 3=20, = 5

C)=100, 1=-5, 2=0, 3=5, = 20 D)=100, 1=-5, 2=0, 3=5, = 5

n A B C D4 9 129 1.5 98 17 257 2 1712 25 385 2.5 2520 41 641 3.5 41

)(

)(

MSEE

MSTE

Page 10: Exp Design

Example - Seasonal Diet Patterns in Ravens

• “Treatments” - t = 4 seasons of year (3 “replicates” each)– Winter: November, December, January

– Spring: February, March, April

– Summer: May, June, July

– Fall: August, September, October

• Response (Y) - Vegetation (percent of total pellet weight)• Transformation (For approximate normality):

100arcsin'

YY

Source: K.A. Engel and L.S. Young (1989). “Spatial and Temporal Patterns in the Diet of Common Ravens in Southwestern Idaho,” The Condor, 91:372-378

Page 11: Exp Design

Seasonal Diet Patterns in Ravens - Data/MeansY Winter(i=1) Fall(i=2) Summer(i=3) Fall (i=4)

j=1 94.3 80.7 80.5 67.8j=2 90.3 90.5 74.3 91.8j=3 83.0 91.8 32.4 89.3

Y' Winter(i=1) Fall(i=2) Summer(i=3) Fall (i=4)j=1 1.329721 1.115957 1.113428 0.967390j=2 1.254080 1.257474 1.039152 1.280374j=3 1.145808 1.280374 0.605545 1.237554

135572.112

237554.1...329721.1

16773.13

237554.1280374.1967390.0

919375.03

605545.0039152.1113428.1

217935.13

280374.1257474.1115957.1

24203.13

145808.1254080.1329721.1

..

.4

.3

.2

.1

y

y

y

y

y

Page 12: Exp Design

Seasonal Diet Patterns in Ravens - Data/MeansPlot of Transformed Data by Season

0.500000

0.600000

0.700000

0.800000

0.900000

1.000000

1.100000

1.200000

1.300000

1.400000

1.500000

0 1 2 3 4 5

Season

Tra

nsf

orm

ed

% V

eg

eta

tio

n

Page 13: Exp Design

Seasonal Diet Patterns in Ravens - ANOVA

241038.0)161773.1237554.1(...)243203.1329721.1(

8)4-12(df :Variation GroupWithin

197387.0)135572.1161773.1(...)135572.124203.1(3

3)1-4(df :Variation GroupBetween

438425.0)135572.127554.1(...)135572.1329721.1(

11)1-12(df :Variation Total

22

E

22

T

22

Total

SSE

SST

TSS

ANOVASource of Variation SS df MS F P-value F critBetween Groups 0.197387 3 0.065796 2.183752 0.167768 4.06618Within Groups 0.241038 8 0.03013

Total 0.438425 11

Do not conclude that seasons differ with respect to vegetation intake

Page 14: Exp Design

Seasonal Diet Patterns in Ravens - Spreadsheet

Month Season Y' Season MeanOverall Mean TSS SST SSENOV 1 1.329721 1.243203 1.135572 0.037694 0.011584 0.007485DEC 1 1.254080 1.243203 1.135572 0.014044 0.011584 0.000118JAN 1 1.145808 1.243203 1.135572 0.000105 0.011584 0.009486FEB 2 1.115957 1.217935 1.135572 0.000385 0.006784 0.010400MAR 2 1.257474 1.217935 1.135572 0.014860 0.006784 0.001563APR 2 1.280374 1.217935 1.135572 0.020968 0.006784 0.003899MAY 3 1.113428 0.919375 1.135572 0.000490 0.046741 0.037657JUN 3 1.039152 0.919375 1.135572 0.009297 0.046741 0.014346JUL 3 0.605545 0.919375 1.135572 0.280928 0.046741 0.098489AUG 4 0.967390 1.161773 1.135572 0.028285 0.000687 0.037785SEP 4 1.280374 1.161773 1.135572 0.020968 0.000687 0.014066OCT 4 1.237554 1.161773 1.135572 0.010400 0.000687 0.005743

Sum 0.438425 0.197387 0.241038

Total SS Between Season SS Within Season SS

(Y’-Overall Mean)2 (Group Mean-Overall Mean)2 (Y’-Group Mean)2

Page 15: Exp Design

CRD with Non-Normal Data Kruskal-Wallis Test

• Extension of Wilcoxon Rank-Sum Test to k > 2 Groups• Procedure:

– Rank the observations across groups from smallest (1) to largest ( N = n1+...+nk ), adjusting for ties

– Compute the rank sums for each group: T1,...,Tk . Note that T1+...+Tk = N(N+1)/2

Page 16: Exp Design

Kruskal-Wallis Test

• H0: The k population distributions are identical (1=...=k)

• HA: Not all k distributions are identical (Not all i are equal)

)(:

:..

)1(3)1(

12:..

2

21,

1

2

HPvalP

HRR

Nn

T

NNHST

k

k

ii

i

An adjustment to H is suggested when there are many ties in the data. Formula is given on page 344 of O&L.

Page 17: Exp Design

Example - Seasonal Diet Patterns in RavensMonth Season Y' RankNOV 1 1.329721 12DEC 1 1.254080 8JAN 1 1.145808 6FEB 2 1.115957 5MAR 2 1.257474 9APR 2 1.280374 10.5MAY 3 1.113428 4JUN 3 1.039152 3JUL 3 0.605545 1AUG 4 0.967390 2SEP 4 1.280374 10.5OCT 4 1.237554 7

• T1 = 12+8+6 = 26

• T2 = 5+9+10.5 = 24.5

• T3 = 4+3+1 = 8

• T4 = 2+10.5+7 = 19.5

1632.)12.5(:value

815.7:)05.0.(.

12.53912.44)112(33

)5.19(

3

)8(

3

)5.24(

3

)26(

)112(12

12:..

sDifference Seasonal : difference seasonal No :

2

214,05.

2222

0

HPP

HRR

HST

HH a

Page 18: Exp Design

Post-hoc Comparisons of Treatments

• If differences in group means are determined from the F-test, researchers want to compare pairs of groups. Three popular methods include:– Fisher’s LSD - Upon rejecting the null hypothesis of no

differences in group means, LSD method is equivalent to doing pairwise comparisons among all pairs of groups as in Chapter 6.

– Tukey’s Method - Specifically compares all t(t-1)/2 pairs of groups. Utilizes a special table (Table 11, p. 701).

– Bonferroni’s Method - Adjusts individual comparison error rates so that all conclusions will be correct at desired confidence/significance level. Any number of comparisons can be made. Very general approach can be applied to any inferential problem

Page 19: Exp Design

Fisher’s Least Significant Difference Procedure

• Protected Version is to only apply method after significant result in overall F-test

• For each pair of groups, compute the least significant difference (LSD) that the sample means need to differ by to conclude the population means are not equal

ijji

ijjiji

jiij

LSDyy

LSDyy

tNnn

MSEtLSD

..

..

2/

:Interval Confidence sFisher'

if Conclude

dfwith 11

Page 20: Exp Design

Tukey’s W Procedure

• More conservative than Fisher’s LSD (minimum significant difference and confidence interval width are higher).

• Derived so that the probability that at least one false difference is detected is (experimentwise error rate)

t

ijji

ijjiji

ij

nn

tn

Wyy

Wyy

N-tqn

MSEtqW

11 use unequal, are sizes sample When the

:Interval Confidence sTukey'

if Conclude

with 701 p. 11, Tablein given ),(

1

..

..

Page 21: Exp Design

Bonferroni’s Method (Most General)• Wish to make C comparisons of pairs of groups with simultaneous confidence intervals or 2-sided tests

•When all pair of treatments are to be compared, C = t(t-1)/2

• Want the overall confidence level for all intervals to be “correct” to be 95% or the overall type I error rate for all tests to be 0.05

• For confidence intervals, construct (1-(0.05/C))100% CIs for the difference in each pair of group means (wider than 95% CIs)

• Conduct each test at =0.05/C significance level (rejection region cut-offs more extreme than when =0.05)

• Critical t-values are given in table on class website, we will use notation: t/2,C, where C=#Comparisons, = df

Page 22: Exp Design

Bonferroni’s Method (Most General)

ijji

ijjiji

jivCij

Byy

Byy

N-tvt

nnMSEtB

..

..

,,2/

:Interval Confidence s'Bonferroni

if Conclude

) with websiteclasson given (

11

Page 23: Exp Design

Example - Seasonal Diet Patterns in Ravens

Note: No differences were found, these calculations are only for demonstration purposes

4930.03

1

3

1)03013.0(479.3

4540.03

1)03013.0(53.4

3268.03

1

3

1)03013.0(306.2

479.353.4306.2303013.0 8,6,025.8,4,05.8,025.

ij

ij

ij

dfCdfti

B

W

LSD

tqtnMSEEE

Comparison(i vs j) Group i Mean Group j MeanDifference1 vs 2 1.243203 1.217935 0.0252671 vs 3 1.243203 0.919375 0.3238281 vs 4 1.243203 1.161773 0.0814302 vs 3 1.217935 0.919375 0.2985602 vs 4 1.217935 1.161773 0.0561623 vs 4 0.919375 1.161773 -0.242398

Page 24: Exp Design

Randomized Block Design (RBD)• t > 2 Treatments (groups) to be compared• b Blocks of homogeneous units are sampled. Blocks can

be individual subjects. Blocks are made up of t subunits• Subunits within a block receive one treatment. When

subjects are blocks, receive treatments in random order.• Outcome when Treatment i is assigned to Block j is

labeled Yij

• Effect of Trt i is labeled i

• Effect of Block j is labeled j

• Random error term is labeled ij

• Efficiency gain from removing block-to-block variability from experimental error

Page 25: Exp Design

Randomized Complete Block Designs• Model:

2

1

)(0)(0

ijij

t

ii

ijjiijjiij

VE

Y

• Test for differences among treatment effects:

• H0: 1t 0 (1t )

• HA: Not all i = 0 (Not all i are equal)

Typically not interested in measuring block effects (although sometimes wish to estimate their variance in the population of blocks). Using Block designs increases efficiency in making inferences on treatment effects

Page 26: Exp Design

RBD - ANOVA F-Test (Normal Data)• Data Structure: (t Treatments, b Subjects)

• Mean for Treatment i:

• Mean for Subject (Block) j:

• Overall Mean:

• Overall sample size: N = bt

• ANOVA:Treatment, Block, and Error Sums of Squares

.iy

jy.

..y

)1)(1(

1

1

1

2

....

1

2

...

1

2

...

1 1

2

..

tbdfSSBSSTTSSyyyySSE

bdfyytSSB

tdfyybSST

btdfyyTSS

Ejiij

B

b

j j

T

t

i i

t

i

b

j Totalij

Page 27: Exp Design

RBD - ANOVA F-Test (Normal Data)

• ANOVA Table:Source SS df MS F

Treatments SST t-1 MST = SST/(t-1) F = MST/MSEBlocks SSB b-1 MSB = SSB/(b-1)Error SSE (b-1)(t-1) MSE = SSE/[(b-1)(t-1)]Total TSS bt-1

•H0: 1t 0 (1t )

• HA: Not all i = 0 (Not all i are equal)

)(:

:..

:..

)1)(1(,1,

obs

tbtobs

obs

FFPvalP

FFRRMSE

MSTFST

Page 28: Exp Design

Pairwise Comparison of Treatment Means• Tukey’s Method- q in Studentized Range Table with = (b-1)(t-1)

ijji

ijjiji

ij

Wyy

Wyy

b

MSEvtqW

..

..

:Interval Confidence sTukey'

if Conclude

),(

• Bonferroni’s Method - t-values from table on class website with = (b-1)(t-1) and C=t(t-1)/2

ijji

ijjiji

vCij

Byy

Byy

b

MSEtB

..

..

,,2/

:Interval Confidence s'Bonferroni

if Conclude

2

Page 29: Exp Design

Expected Mean Squares / Relative Efficiency • Expected Mean Squares: As with CRD, the Expected Mean

Squares for Treatment and Error are functions of the sample sizes (b, the number of blocks), the true treatment effects (1,…,t) and the variance of the random error terms (2)

• By assigning all treatments to units within blocks, error variance is (much) smaller for RBD than CRD (which combines block variation&random error into error term)

• Relative Efficiency of RBD to CRD (how many times as many replicates would be needed for CRD to have as precise of estimates of treatment means as RBD does):

MSEbt

MSEtbMSBb

MSE

MSECRRCBRE

RCB

CR

)1(

)1()1(),(

Page 30: Exp Design

Example - Caffeine and Endurance

• Treatments: t=4 Doses of Caffeine: 0, 5, 9, 13 mg• Blocks: b=9 Well-conditioned cyclists

• Response: yij=Minutes to exhaustion for cyclist j @ dose i

• Data:

Dose \ Subject 1 2 3 4 5 6 7 8 90 36.05 52.47 56.55 45.20 35.25 66.38 40.57 57.15 28.345 42.47 85.15 63.20 52.10 66.20 73.25 44.50 57.17 35.059 51.50 65.00 73.10 64.40 57.45 76.49 40.55 66.47 33.1713 37.55 59.30 79.12 58.33 70.54 69.47 46.48 66.35 36.20

Page 31: Exp Design

Plot of Y versus Subject by Dose

0.00

10.00

20.00

30.00

40.00

50.00

60.00

70.00

80.00

90.00

0 1 2 3 4 5 6 7 8 9 10

Cyclist

Tim

e t

o E

xhau

stio

n

0 mg

5 mg

9mg

13 mg

Page 32: Exp Design

Example - Caffeine and EnduranceSubject\Dose 0mg 5mg 9mg 13mg Subj MeanSubj Dev Sqr Dev

1 36.05 42.47 51.50 37.55 41.89 -13.34 178.072 52.47 85.15 65.00 59.30 65.48 10.24 104.933 56.55 63.20 73.10 79.12 67.99 12.76 162.714 45.20 52.10 64.40 58.33 55.01 -0.23 0.055 35.25 66.20 57.45 70.54 57.36 2.12 4.516 66.38 73.25 76.49 69.47 71.40 16.16 261.177 40.57 44.50 40.55 46.48 43.03 -12.21 149.128 57.15 57.17 66.47 66.35 61.79 6.55 42.889 28.34 35.05 33.17 36.20 33.19 -22.05 486.06

Dose Mean 46.44 57.68 58.68 58.15 55.24 1389.50Dose Dev -8.80 2.44 3.44 2.91Squared Dev 77.38 5.95 11.86 8.48 103.68

TSS 7752.773

24)19)(14(653.1261555812.933773.7752

)24.5515.5819.3320.36()24.5544.4689.4105.36(

81900.5558)50.1389(4)24.5519.33()24.5589.41(4

31412.933)68.103(9)24.5515.58()24.5544.46(9

351)9(4773.7752)24.5520.36()24.5505.36(

22

22

22

22

E

B

T

Total

dfSSBSSTTSS

SSE

dfSSB

dfSST

dfTSS

Page 33: Exp Design

Example - Caffeine and Endurance

Source df SS MS FDose 3 933.12 311.04 5.92Cyclist 8 5558.00 694.75Error 24 1261.65 52.57Total 35 7752.77

equal allnot are means that trueConclude

EXCEL) (From 0036.)92.5( :value

01.3:0.05).(.

92.557.52

04.311:..

Doses AmongExist sDifference :

)0(Effect Dose Caffeine No :

24,3,05.

410

FPP

FFRRMSE

MSTFST

H

H

obs

obs

A

Page 34: Exp Design

Example - Caffeine and Endurance

83.99

257.52875.2875.2 :B s'Bonferroni

43.99

157.5290.390.3: sTukey'

24,6,2/05.

24,4,05.

Bt

WqW

Doses High Mean Low Mean Difference Conclude5mg vs 0mg 57.6767 46.4400 11.2367 9mg vs 0mg 58.6811 46.4400 12.2411 13mg vs 0mg 58.1489 46.4400 11.7089 9mg vs 5mg 58.6811 57.6767 1.0044 NSD13mg vs 5mg 58.1489 57.6767 0.4722 NSD13mg vs 9mg 58.1489 58.6811 -0.5322 NSD

Page 35: Exp Design

Example - Caffeine and Endurance

79.395.1839

39.6977

)57.52)(1)4(9(

)57.52)(3(9)75.694(8

)1(

)1()1(),(

57.5275.69494

:Design Randomized Completely Block to Randomized of Efficiency Relative

MSEbt

MSEtbMSBbCRRCBRE

MSEMSBbt

Would have needed 3.79 times as many cyclists per dose to have the same precision on the estimates of mean endurance time.

• 9(3.79) 35 cyclists per dose

• 4(35) = 140 total cyclists

Page 36: Exp Design

RBD -- Non-Normal DataFriedman’s Test

• When data are non-normal, test is based on ranks• Procedure to obtain test statistic:

– Rank the k treatments within each block (1=smallest, k=largest) adjusting for ties

– Compute rank sums for treatments (Ti) across blocks

– H0: The k populations are identical (1=...=k)

– HA: Differences exist among the k group means

)(:

:..

)1(3)1(

12:..

2

21,

1

2

r

kr

k

i ir

FPvalP

FRR

kbTkbk

FST

Page 37: Exp Design

Example - Caffeine and Endurance

Subject\Dose 0mg 5mg 9mg 13mg Ranks 0mg 5mg 9mg 13mg1 36.05 42.47 51.5 37.55 1 3 4 22 52.47 85.15 65 59.3 1 4 3 23 56.55 63.2 73.1 79.12 1 2 3 44 45.2 52.1 64.4 58.33 1 2 4 35 35.25 66.2 57.45 70.54 1 3 2 46 66.38 73.25 76.49 69.47 1 3 4 27 40.57 44.5 40.55 46.48 2 3 1 48 57.15 57.17 66.47 66.35 1 2 4 39 28.34 35.05 33.17 36.2 1 3 2 4

Total 10 25 27 28

equal allnot are (Medians) Means Conclude

EXCEL) (From 0026.)2.14( :value-

815.7:)05.0.(.

2.14135180

26856)14)(9(3)28()10(

)14)(4(9

12:..

Exist sDifference Dose :

sDifference Dose No :

2

214,05.

22

0

PP

FRR

FST

H

H

r

r

a

Page 38: Exp Design

Latin Square Design• Design used to compare t treatments when there are

two sources of extraneous variation (types of blocks), each observed at t levels

• Best suited for analyses when t 10• Classic Example: Car Tire Comparison

– Treatments: 4 Brands of tires (A,B,C,D)

– Extraneous Source 1: Car (1,2,3,4)

– Extraneous Source 2: Position (Driver Front, Passenger Front, Driver Rear, Passenger Rear)

Car\Position DF PF DR PR1 A B C D2 B C D A3 C D A B4 D A B C

Page 39: Exp Design

Latin Square Design - Model

• Model (t treatments, rows, columns, N=t2) :

TermError Random

Column todueEffect

row todueEffect

Treatment ofEffect

Mean Overall

.....

^

.....

^

.....

^

k

...

^

ijk

jjj

iii

kk

ijkkikijk

yyj

yyi

yyk

y

y

Page 40: Exp Design

Latin Square Design - ANOVA & F-Test

)2)(1()1(3)1( Squares of SumError

1 Squares of SumColumn

1 Squares of Sum Row

1 Squares of SumTreatment

1 :Squares of Sum Total

2

2

1.....

2

1.....

2

1.....

22

1 1...

ttttdfSSCSSRSSTTSSSSE

tdfyytSSC

tdfyytSSR

tdfyytSST

tdfyyTSS

E

C

t

jj

R

t

ii

T

t

kk

t

i

t

jijk

• H0: 1 = … = t = 0 Ha: Not all k = 0

• TS: Fobs = MST/MSE = (SST/(t-1))/(SSE/((t-1)(t-2)))

• RR: Fobs F, t-1, (t-1)(t-2)

Page 41: Exp Design

Pairwise Comparison of Treatment Means• Tukey’s Method- q in Studentized Range Table with = (t-1)(t-2)

ijji

ijjiji

ij

Wyy

Wyy

t

MSEvtqW

..

..

:Interval Confidence sTukey'

if Conclude

),(

• Bonferroni’s Method - t-values from table on class website with = (t-1)(t-2) and C=t(t-1)/2

ijji

ijjiji

vCij

Byy

Byy

t

MSEtB

..

..

,,2/

:Interval Confidence s'Bonferroni

if Conclude

2

Page 42: Exp Design

Expected Mean Squares / Relative Efficiency • Expected Mean Squares: As with CRD, the Expected Mean

Squares for Treatment and Error are functions of the sample sizes (t, the number of blocks), the true treatment effects (1,…,t) and the variance of the random error terms (2)

• By assigning all treatments to units within blocks, error variance is (much) smaller for LS than CRD (which combines block variation&random error into error term)

• Relative Efficiency of LS to CRD (how many times as many replicates would be needed for CRD to have as precise of estimates of treatment means as LS does):

MSEt

MSEtMSCMSR

MSE

MSECRLSRE

LS

CR

)1(

)1(),(

Page 43: Exp Design

2-Way ANOVA• 2 nominal or ordinal factors are believed to

be related to a quantitative response

• Additive Effects: The effects of the levels of each factor do not depend on the levels of the other factor.

• Interaction: The effects of levels of each factor depend on the levels of the other factor

• Notation: ij is the mean response when factor A is at level i and Factor B at j

Page 44: Exp Design

2-Way ANOVA - Model

TermsError Random

combined are B of level andA of level n effect when Interactio

Bfactor of level ofEffect

Afactor of level ofEffect

Mean Overall

levelat B , levelat A Factors receivingunit on t Measuremen

,...,1,...,1,...,1

ijk

ij

j

i

thth

th

th

thijk

ijkijjiijk

ji

j

i

jiky

rkbjaiy

•Model depends on whether all levels of interest for a factor are included in experiment:

• Fixed Effects: All levels of factors A and B included

• Random Effects: Subset of levels included for factors A and B

• Mixed Effects: One factor has all levels, other factor a subset

Page 45: Exp Design

Fixed Effects Model

• Factor A: Effects are fixed constants and sum to 0• Factor B: Effects are fixed constants and sum to 0• Interaction: Effects are fixed constants and sum to 0

over all levels of factor B, for each level of factor A, and vice versa

• Error Terms: Random Variables that are assumed to be independent and normally distributed with mean 0, variance

2

2

1111

,0~000,0 Nij ijk

b

jij

a

iij

b

jj

a

ii

Page 46: Exp Design

Example - Thalidomide for AIDS • Response: 28-day weight gain in AIDS patients

• Factor A: Drug: Thalidomide/Placebo

• Factor B: TB Status of Patient: TB+/TB-

• Subjects: 32 patients (16 TB+ and 16 TB-). Random assignment of 8 from each group to each drug). Data:– Thalidomide/TB+: 9,6,4.5,2,2.5,3,1,1.5– Thalidomide/TB-: 2.5,3.5,4,1,0.5,4,1.5,2– Placebo/TB+: 0,1,-1,-2,-3,-3,0.5,-2.5– Placebo/TB-: -0.5,0,2.5,0.5,-1.5,0,1,3.5

Page 47: Exp Design

ANOVA Approach

• Total Variation (TSS) is partitioned into 4 components:– Factor A: Variation in means among levels of A– Factor B: Variation in means among levels of B– Interaction: Variation in means among

combinations of levels of A and B that are not due to A or B alone

– Error: Variation among subjects within the same combinations of levels of A and B (Within SS)

Page 48: Exp Design

Analysis of Variance

)1( :Squares of SumError

)1)(1( :Squares of Sumn Interactio

1 :Squares of Sum BFactor

1 :Squares of SumA Factor

1 :Variation Total

1 1 1

2

.

1 1

2

........

1

2

.....

1

2

.....

1 1 1

2

...

rabdfyySSE

badfyyyyrSSAB

bdfyyarSSB

adfyybrSSA

abrdfyyTSS

E

a

i

b

j

r

kijijk

AB

a

i

b

jjiij

B

b

jj

A

a

ii

Total

a

i

b

j

r

kijk

• TSS = SSA + SSB + SSAB + SSE

• dfTotal = dfA + dfB + dfAB + dfE

Page 49: Exp Design

ANOVA Approach - Fixed EffectsSource df SS MS F Factor A a-1 SSA MSA=SSA/(a-1) FA=MSA/MSE Factor B b-1 SSB MSB=SSB/(b-1) FB=MSB/MSE Interaction (a-1)(b-1) SSAB MSAB=SSAB/[(a-1)(b-1)] FAB=MSAB/MSE Error ab(r-1) SSE MSE=SSE/[ab(r-1)] Total abr-1 TSS

• Procedure:

• First test for interaction effects

• If interaction test not significant, test for Factor A and B effects

)1(),1()1(),1(,)1(),1)(1(,

1010110

: : :

: : :

0 allNot : 0 allNot : 0 allNot :

0...:0...:0...:

BFactor for Test A Factor for Test :nInteractiofor Test

rabbBrabaArabbaAB

BAAB

jaiaija

baab

FFRRFFRRFFRRMSE

MSBFTS

MSE

MSAFTS

MSE

MSABFTS

HHH

HHH

Page 50: Exp Design

Example - Thalidomide for AIDS

Negative Positive

tb

Placebo Thalidomide

drug

-2.5

0.0

2.5

5.0

7.5

wtg

ain

Repor t

W TGAIN

3 .68 8 8 2 .69 8 4

2 .37 5 8 1 .35 6 2

-1 .2 50 8 1 .60 3 6

.6 88 8 1 .62 4 3

1 .37 5 3 2 2 .60 2 7

GR OU PTB+ /Tha lid o m i de

TB- /Th a lid om id e

TB+ /P la ce bo

TB- /P laceb o

Tota l

Mea n N S td . D evia tio n

Individual Patients Group Means

Placebo Thalidomide

drug

-1.000

0.000

1.000

2.000

3.000

mea

nw

g

Page 51: Exp Design

Example - Thalidomide for AIDSTes ts of Be tw ee n-S ubje cts Effec ts

D ep e nd en t Va ria b le: W TGAIN

1 09 .6 88a 3 3 6.5 6 3 1 0.2 0 6 .0 00

6 0.5 0 0 1 6 0.5 0 0 1 6.8 8 7 .0 00

8 7.7 8 1 1 8 7.7 8 1 2 4.5 0 2 .0 00

.7 81 1 .7 81 .2 18 .6 44

2 1.1 2 5 1 2 1.1 2 5 5 .89 7 .0 22

1 00 .3 13 2 8 3 .58 3

2 70 .5 00 3 2

2 10 .0 00 3 1

S ou rceC orre cte d Mod el

In te rcep t

D R UG

TB

D R UG * TB

E rro r

Tota l

C or re cte d Tota l

Typ e III Su mo f S qu a re s d f Mea n S qu are F S ig .

R S qu a red = .5 2 2 (Ad ju s ted R S q ua re d = .47 1 )a .

• There is a significant Drug*TB interaction (FDT=5.897, P=.022)

• The Drug effect depends on TB status (and vice versa)

Page 52: Exp Design

Comparing Main Effects (No Interaction)• Tukey’s Method- q in Studentized Range Table with = ab(r-1)

Bjiji

Ajiji

Bjiji

Ajiji

BA

ijij

ijij

ijij

WyyWyy

WyyWyy

ar

MSEvbqW

br

MSEvaqW

........

........

:)(:)( :CI sTukey'

if if :Conclude

),(),(

• Bonferroni’s Method - t-values in Bonferroni table with =ab (r-1)

Bjiji

Ajiji

Bjiji

Ajiji

vbbB

vaaA

ijij

ijij

ijij

Byy-Byy-αα

ByyByy

ar

MSEtB

br

MSEtB

........

........

,2/)1(,2/,2/)1(,2/

:)( :)(:CI s'Bonferroni

if if :Conclude

22

Page 53: Exp Design

Comparing Main Effects (Interaction)• Tukey’s Method- q in Studentized Range Table with = ab(r-1)

Ain BFactor for Similar :)( :CI sTukey'

if :Conclude B,Factor of level kWithin

),(

..

..

Ajkikji

Ajkikji

th

A

ij

ij

ij

Wyy

Wyy

r

MSEvaqW

• Bonferroni’s Method - t-values in Bonferroni table with =ab (r-1)

Ajkikji

Ajkikji

vaaA

ij

ij

ij

Byy-αα

Byy

r

MSEtB

..

..th

,2/)1(,2/

:)(:CI s'Bonferroni

if :Conclude B, of level kWithin

2

Page 54: Exp Design

Miscellaneous Topics

• 2-Factor ANOVA can be conducted in a Randomized Block Design, where each block is made up of ab experimental units. Analysis is direct extension of RBD with 1-factor ANOVA

• Factorial Experiments can be conducted with any number of factors. Higher order interactions can be formed (for instance, the AB interaction effects may differ for various levels of factor C).

• When experiments are not balanced, calculations are immensely messier and you must use statistical software packages for calculations

Page 55: Exp Design

Mixed Effects Models• Assume:

– Factor A Fixed (All levels of interest in study)…

– Factor B Random (Sample of levels used in study)j ~ N(0,b

2) (Independent)

• AB Interaction terms Random)ij ~ N(0ab

2(Independent)

• Analysis of Variance is computed exactly as in Fixed Effects case (Sums of Squares, df’s, MS’s)

• Error terms for tests change (See next slide).

Page 56: Exp Design

ANOVA Approach – Mixed EffectsSource df SS MS F Factor A a-1 SSA MSA=SSA/(a-1) FA=MSA/MSAB Factor B b-1 SSB MSB=SSB/(b-1) FB=MSB/MSAB Interaction (a-1)(b-1) SSAB MSAB=SSAB/[(a-1)(b-1)] FAB=MSAB/MSE Error ab(r-1) SSE MSE=SSE/[ab(n-1)] Total abr-1 TSS

• Procedure:

• First test for interaction effects

• If interaction test not significant, test for Factor A and B effects

)1)(1(),1(,)1)(1(),1(,)1(),1)(1(,

22

2010

20

: : :

: : :

0 : 0 allNot : 0 :

0: 0...: 0:

BFactor for Test A Factor for Test :nInteractiofor Test

babBbaaArabbaAB

BAAB

baiaaba

baab

FFRRFFRRFFRRMSAB

MSBFTS

MSAB

MSAFTS

MSE

MSABFTS

HHH

HHH

Page 57: Exp Design

Comparing Main Effects for A (No Interaction)• Tukey’s Method- q in Studentized Range Table with = (a-1)(b-1)

Ajiji

Ajiji

A

ij

ij

ij

Wyy

Wyy

br

MSABvaqW

....

....

:)( :CI sTukey'

if :Conclude

),(

• Bonferroni’s Method - t-values in Bonferroni table with = (a-1)(b-1)

Ajiji

Ajiji

vaaA

ij

ij

ij

Byy-αα

Byy

br

MSABtB

....

....

,2/)1(,2/

:)(:CI s'Bonferroni

if :Conclude

2

Page 58: Exp Design

Random Effects Models• Assume:

– Factor A Random (Sample of levels used in study)i ~ N(0,a

2) (Independent)

– Factor B Random (Sample of levels used in study)j ~ N(0,b

2) (Independent)

• AB Interaction terms Random)ij ~ N(0ab

2(Independent)

• Analysis of Variance is computed exactly as in Fixed Effects case (Sums of Squares, df’s, MS’s)

• Error terms for tests change (See next slide).

Page 59: Exp Design

ANOVA Approach – Mixed EffectsSource df SS MS F Factor A a-1 SSA MSA=SSA/(a-1) FA=MSA/MSAB Factor B b-1 SSB MSB=SSB/(b-1) FB=MSB/MSAB Interaction (a-1)(b-1) SSAB MSAB=SSAB/[(a-1)(b-1)] FAB=MSAB/MSE Error ab(n-1) SSE MSE=SSE/[ab(n-1)] Total abn-1 TSS

• Procedure:

• First test for interaction effects

• If interaction test not significant, test for Factor A and B effects

)1)(1(),1()1)(1(),1(,)1(),1)(1(,

222

20

20

20

: : :

: : :

0 : 0 : 0 :

0: 0: 0:

BFactor for Test A Factor for Test :nInteractiofor Test

babBbaaArabbaAB

BAAB

baaaaba

baab

FFRRFFRRFFRRMSAB

MSBFTS

MSAB

MSAFTS

MSE

MSABFTS

HHH

HHH

Page 60: Exp Design

Nested Designs

• Designs where levels of one factor are nested (as opposed to crossed) wrt other factor

• Examples Include:– Classrooms nested within schools– Litters nested within Feed Varieties– Hair swatches nested within shampoo types– Swamps of varying sizes (e.g. large, medium, small)– Restaurants nested within national chains

Page 61: Exp Design

Nested Design - Model

j(i)at is B i,at isA when rep kfor error term Random

Random)or (Fixed A of level i within B of level j ofEffect

Random)or (Fixed A of leveli ofEffect

Mean Overall

A within level jat B level, iat A Factor of rep kfor Response

:where

,...,1,...,1,...1

th

thth)(

th

ththth

)(

ijk

ij

i

ijk

iijkijiijk

Y

rkbjaiY

Page 62: Exp Design

Nested Design - ANOVA

a

iiE

a

i

b

j

r

k

ijijk

a

iiAB

a

i

b

j

iij

A

a

i

ii

a

iiTotal

a

i

b

j

r

kijk

brdfYYSSE

abdfYYrASSB

adfYYbrSSA

brdfYYTSS

i

i

i

11 1 1

2.

1)(

1 1

2...

1

2.....

11 1 1

2...

)1(

:Error

)(

A Within Nested BFactor

1

:AFactor

1

:Variation Total

Page 63: Exp Design

Factors A and B Fixed

ii

i

i

brabAB

ABAB

ijAij

braA

AA

iAa

ijk

b

jij

a

ii

FF

FFPMSE

AMSBF

HjiH

FF

FFPMSE

MSAF

HH

Nai

)1(,,)(

)()(

)()(0

)1(,1,

10

2

1)(

1

:RegionRejection

:value-P)(

:StatisticTest

0 allNot :,0:

Effects BFactor Among sDifferencefor Tests

:RegionRejection

:value-P :StatisticTest

0 allNot :0...:

EffectsA Factor Among sDifferencefor Tests

,0~,...,100

Page 64: Exp Design

Comparing Main Effects for A• Tukey’s Method- q in Studentized Range Table with = (r-1)bi

Ajiji

Ajiji

ji

A

ij

ij

ij

Wyy

Wyy

rbrb

MSEvaqW

....

....

:)( :CI sTukey'

if :Conclude

11

2),(

• Bonferroni’s Method - t-values in Bonferroni table with = (r-1)bi

Ajiji

Ajiji

jivaa

A

ij

ij

ij

Byy-αα

Byy

rbrbMSEtB

....

....

,2/)1(,2/

:)(:CI s'Bonferroni

if :Conclude

11

Page 65: Exp Design

Comparing Effects for Factor B Within A• Tukey’s Method- q in Studentized Range Table with = (r-1)bi

Bkjkikjki

Bkjkikjki

kB

kij

kij

kij

Wyy

Wyy

r

MSEvbqW

)(

)(

)(

..)()(

..)()(

:)( :CI sTukey'

if :Conclude

),(

• Bonferroni’s Method - t-values in Bonferroni table with = (r-1)bi

Bkjkikjki

Bkjkikjki

vbbB

kij

kij

kkkij

Byy-

Byy

rMSEtB

)(

)(

)(

..)()(

..)()(

,2/)1(,2/

:)(:CI s'Bonferroni

if :Conclude

2

Page 66: Exp Design

Factor A Fixed and B Random

ii

i

brabAB

ABAB

bAb

abaA

AA

iAa

ijkbij

a

ii

FF

FFPMSE

AMSBF

HjiH

FF

FFPAMSB

MSAF

HH

NN

)1(,,)(

)()(

220

,1,

10

22)(

1

:RegionRejection

:value-P)(

:StatisticTest

0:,0:

Effects BFactor Among sDifferencefor Tests

:RegionRejection

:value-P)(

:StatisticTest

0 allNot :0...:

EffectsA Factor Among sDifferencefor Tests

,0~,0~0

Page 67: Exp Design

Comparing Main Effects for A (B Random)• Tukey’s Method- q in Studentized Range Table with = bi-a

Ajiji

Ajiji

ji

A

ij

ij

ij

Wyy

Wyy

rbrb

AMSBvaqW

....

....

:)( :CI sTukey'

if :Conclude

11

2

)(),(

• Bonferroni’s Method - t-values in Bonferroni table with = bi-a

Ajiji

Ajiji

jivaa

A

ij

ij

ij

Byy-αα

Byy

rbrbAMSBtB

....

....

,2/)1(,2/

:)(:CI s'Bonferroni

if :Conclude

11)(

Page 68: Exp Design

Factors A and B Random

ii

i

brabAB

ABAB

bAb

abaA

AA

aAa

ijkbijai

FF

FFPMSE

AMSBF

HjiH

FF

FFPAMSB

MSAF

HH

NNN

)1(,,)(

)()(

220

,1,

220

22)(

2

:RegionRejection

:value-P)(

:StatisticTest

0:,0:

Effects BFactor Among sDifferencefor Tests

:RegionRejection

:value-P)(

:StatisticTest

0:0:

EffectsA Factor Among sDifferencefor Tests

,0~,0~,0~

Page 69: Exp Design

Elements of Split-Plot Designs

• Split-Plot Experiment: Factorial design with at least 2 factors, where experimental units wrt factors differ in “size” or “observational points”.

• Whole plot: Largest experimental unit• Whole Plot Factor: Factor that has levels assigned to

whole plots. Can be extended to 2 or more factors• Subplot: Experimental units that the whole plot is split

into (where observations are made)• Subplot Factor: Factor that has levels assigned to

subplots• Blocks: Aggregates of whole plots that receive all levels

of whole plot factor

Page 70: Exp Design

Split Plot Design

Block 1 Block 2 Block 3 Block 4A=1, B=1 A=1, B=1 A=1, B=1 A=1, B=1A=1, B=2 A=1, B=2 A=1, B=2 A=1, B=2A=1, B=3 A=1, B=3 A=1, B=3 A=1, B=3A=1, B=4 A=1, B=4 A=1, B=4 A=1, B=4A=2, B=1 A=2, B=1 A=2, B=1 A=2, B=1A=2, B=2 A=2, B=2 A=2, B=2 A=2, B=2A=2, B=3 A=2, B=3 A=2, B=3 A=2, B=3A=2, B=4 A=2, B=4 A=2, B=4 A=2, B=4A=3, B=1 A=3, B=1 A=3, B=1 A=3, B=1A=3, B=2 A=3, B=2 A=3, B=2 A=3, B=2A=3, B=3 A=3, B=3 A=3, B=3 A=3, B=3A=3, B=4 A=3, B=4 A=3, B=4 A=3, B=4

Note: Within each block we would assign at random the 3 levels of A to the whole plots and the 4 levels of B to the subplots within whole plots

Page 71: Exp Design

Examples

• Agriculture: Varieties of a crop or gas may need to be grown in large areas, while varieties of fertilizer or varying growth periods may be observed in subsets of the area.

• Engineering: May need long heating periods for a process and may be able to compare several formulations of a by-product within each level of the heating factor.

• Behavioral Sciences: Many studies involve repeated measurements on the same subjects and are analyzed as a split-plot (See Repeated Measures lecture)

Page 72: Exp Design

Design Structure

• Blocks: b groups of experimental units to be exposed to all combinations of whole plot and subplot factors

• Whole plots: a experimental units to which the whole plot factor levels will be assigned to at random within blocks

• Subplots: c subunits within whole plots to which the subplot factor levels will be assigned to at random.

• Fully balanced experiment will have n=abc observations

Page 73: Exp Design

Data Elements (Fixed Factors, Random Blocks)

• Yijk: Observation from wpt i, block j, and spt k

• : Overall mean level

• i : Effect of ith level of whole plot factor (Fixed)

• bj: Effect of jth block (Random)

• (ab )ij : Random error corresponding to whole plot elements in block j where wpt i is applied

• k: Effect of kth level of subplot factor (Fixed)

• )ik: Interaction btwn wpt i and spt k

• (bc )jk: Interaction btwn block j and spt k (often set to 0)

• ijk: Random Error= (bc )jk+ (abc)ijk

• Note that if block/spt interaction is assumed to be 0, represents the block/spt within wpt interaction

Page 74: Exp Design

Model and Common Assumptions

• Yijk = + i + b j + (ab )ij + k + ( )ik + ijk

0),)((),())(,(

).0(~

0)()(

0

),0(~)(

),0(~

0

2

11

1

2

2

1

ijkijijkjijj

ijk

c

kik

a

iik

c

kk

abij

bj

a

ii

abCOVbCOVabbCOV

NID

NIDab

NIDb

Page 75: Exp Design

Tests for Fixed Effects

)~|(

:StatisticTest

,0)(: :nInteractio SPWP

)~|(

:StatisticTest

0: :EffectsTrt Subplot

)~|(

:StatisticTest

0: :EffectsTrt Plot Whole

)1)(1().1)(1(

0

)1)(1(.1

10

)1)(1.(1

*

10

cbacaSPWPSPWP

ERROR

SPWPSPWP

ik

cbacSPSP

ERROR

SPSP

c

baaWPWP

WPBLOCK

WPWP

a

FFFFPP

MS

MSF

kiH

FFFFPP

MS

MSF

H

FFFFPP

MS

MSF

H

Page 76: Exp Design

Comparing Factor Levels

)1)(1()1)(1()1(

)1(

below)given (df )1(2

:on)(Interactiplot sub same within EffectsPlot Whole

2:)()(for CI %95

:on)(Interactiplot wholesame Within EffectsPlot Sub

2:)(for CI %95

:LevelsFactor Plot Sub

2:for CI %95

:LevelsFactor Plot Whole

22

2^

'..

'..''

'....'

'....'

baMS

cbaMSc

MSMSc

bc

MScMStYY

b

MStYY

ab

MStYY

bc

MStYY

WPBLOCKERROR

WPBLOCKERROR

ERRORWPBLOCKkiki

ERRORkikiikikkk

ERRORkkkk

WPBLOCKiiii

Page 77: Exp Design

Repeated Measures Designs

• a Treatments/Conditions to compare

• N subjects to be included in study (each subject will receive only one treatment)– n subjects receive trt i: an = N

• t time periods of data will be obtained

• Effects of trt, time and trtxtime interaction of primary interest.– Between Subject Factor: Treatment– Within Subject Factors: Time, TrtxTime

Page 78: Exp Design

Model

2

11

1

2)()(

1

)(

,0~ error term random

0)()( timeand t between trn interactio)(

0 period time ofeffect

,0~in trt subject ofeffect

0 trt ofeffect

mean overall

)(

NID

ki

k

NIDbijb

i

bY

ijkijk

t

kik

a

iikik

t

kk

thk

bijth

ij

a

iii

ijkikkijiijk

Note the random error term is actually the interaction between subjects (within treatments) and time

Page 79: Exp Design

Tests for Fixed Effects

)~|(

:StatisticTest

,0)(: :nInteractio TimeTreatment/

)~|(

:StatisticTest

0: :Effects Time

)~|(

:StatisticTest

0: :EffectsTreatment

)1)(1(),1)(1(

0

)1)(1(,1

10

)1(,1

)(

10

tnataTIMETRTTIMETRT

ERROR

TIMETRTTIMETRT

ik

tnatTIMETIME

ERROR

TIMETIME

t

naaTRTSTRTS

TRTSSUBJECTS

TRTSTRTS

a

FFFFPP

MS

MSF

kiH

FFFFPP

MS

MSF

H

FFFFPP

MS

MSF

H

Page 80: Exp Design

Comparing Factor Levels

)1()1)(1()1(

)1(

:df eapproximatwith

)1(2

:Levels Time Within LevelsTreatment Comparing

2:for CI %95

:Levels Time Comparing

2:for CI %95

:LevelsTreatment Comparing

2)(

2

2)(

^

)('..

'....'k

)('....'

na

MS

tnaMSt

MSMSt

nt

MStMStYY

an

MStYY

nt

MStYY

TRTSUBJECTERROR

TRTSUBJECTERROR

ERRORTRTSSUBJECTSkiki

ERRORkkk

TRTSSUBJECTSiiii