49
Estat´ ıstica Experimental: Session 4 1 Latin Square Designs (LS) based on Chris Brien’s notes (University of South Australia, Adelaide), http://chris.brien.name/ee2/ Clarice G. B. Dem´ etrio Departamento de Ciˆ encias Exatas ESALQ/USP Piracicaba, SP, Brasil email: [email protected] April 2010

Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Embed Size (px)

Citation preview

Page 1: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 1'

&

$

%

Latin Square Designs (LS)based on Chris Brien’s notes (University of South Australia, Adelaide),

http://chris.brien.name/ee2/

Clarice G. B. Demetrio

Departamento de Ciencias Exatas

ESALQ/USP

Piracicaba, SP, Brasil

email: [email protected]

April 2010

Page 2: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 2'

&

$

%

Course Outline

V.A Design of Latin squares

V.B Indicator-variable models and estimation for an LS

VI.C Hypothesis testing using the ANOVA method for a Latin Square

V.D Treatment differences

IV.E Summary

IV.F Exercise

Page 3: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 3'

&

$

%

V. Latin squares designs (LS)

V.A Design of Latin squares

• Sometimes we need more than one type of blocks. In general callone sort of blocks “rows” and the other sort “columns”.

• Definition V.1: A Latin square design is one in which

– each treatment occurs once and only once in each row andeach column

– so that the numbers of rows, columns and treatments are allequal.

• Clearly, the total number of observations is n = t2.

• Suppose in a field trial moisture is varying across the field and thestoniness down the field.

• A Latin square can eliminate both sources of variability.

Page 4: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 4'

&

$

%

Example V.1 Sugarcane experiment

• Suppose there are five different varieties of sugarcane to becompared and suppose that moisture is varying across the fieldand that the stoniness down the field.

• A Latin square design for this would be as follows:

5× 5 Latin SquareColumn Less

1 2 3 4 5 stony ofI A B C D E fieldII C D E A B ⇓

Row III E A B C D ⇓IV B C D E A ⇓V D E A B C Stonier

end offield

Less Moremoisture ⇒⇒⇒ moisture

VarietiesA, B, C, D, E

Page 5: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 5'

&

$

%

• Even if one has not identified trends in two directions, a Latinsquare may be employed to guard against the problem of puttingthe blocks in the wrong direction.

• Latin squares may also be used when there are two different kindsof blocking variables, for example, animals and times.

• General principle is that one is interested in maximizing row andcolumn differences so as to minimize the amount of uncontrolledvariation affecting treatment comparisons.

• The major disadvantage with the Latin square is that you arerestricted to having the number of replicates equal to the numberof treatments.

Page 6: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 6'

&

$

%

• Several fundamentally different Latin squares exist for a particulart

– for t = 4 there are three different squares.

– A collection of Latin squares for t = 3, 4, . . . , 9 is given inAppendix 8A of Box, Hunter and Hunter.

• To randomize these designs appropriately involves the following:

1. randomly select one of the designs for a value of t;

2. randomly permute the rows and then the columns;

3. randomly assign letters to treatments.

• Note: no nested.factors as Rows and Columns are to berandomized independently

• Hence they are not nested (they are crossed)

• Generally we will use R to obtain randomized layouts.

• General instructions given in Appendix B, Randomized layouts andsample size computations in R.

Page 7: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 7'

&

$

%

a) Obtaining a layout for an LS in R

# Obtaining randomized layout for a LS

library(dae)

t <- 5

n <- t * t

LSSugarCane.unit <- list(Rows = t, Columns = t)

Varieties <- factor(c("A", "B", "C", "D", "E",

"C", "D", "E", "A", "B", "E", "A", "B", "C", "D",

"B", "C", "D", "E", "A", "D", "E", "A", "B", "C"),

labels =c("A", "B", "C", "D", "E"))

LSSugarcane.lay <- fac.layout(unrandomized=LSSugarCane.unit,

randomized=Varieties,seed=941)

remove("Varieties")

LSSugarcane.lay

Units Permutation Rows Columns Varieties

1 1 20 1 1 A

2 2 18 1 2 D

3 3 17 1 3 C

4 4 19 1 4 E

5 5 16 1 5 B

6 6 15 2 1 C

7 7 13 2 2 A

8 8 12 2 3 E

9 9 14 2 4 B

10 10 11 2 5 D

11 11 25 3 1 B

12 12 23 3 2 E

13 13 22 3 3 D

14 14 24 3 4 A

15 15 21 3 5 C

16 16 5 4 1 E

Page 8: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 8'

&

$

%

17 17 3 4 2 C

18 18 2 4 3 B

19 19 4 4 4 D

20 20 1 4 5 A

21 21 10 5 1 D

22 22 8 5 2 B

23 23 7 5 3 A

24 24 9 5 4 C

25 25 6 5 5 E

Thus the randomized layout is:

5 × 5 Latin SquareColumn Less

1 2 3 4 5 stony ofI A D C E B fieldII C A E B D ⇓

Row III B E D A C ⇓IV E C B D A ⇓V D B A C E Stonier

end offield

Less Moremoisture ⇒⇒⇒ moisture

VarietiesA, B, C, D, E

Page 9: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 9'

&

$

%

V.B Indicator-variable models and estimation for an LS

• Have to decide whether each of the factors Rows, Columns andTreatments are to be regarded as fixed or random.

• As for the RCBD, it happens that the analysis of the Latin squareis essentially unaffected by which model is used.

• Generally, the Latin square involves t rows and columns so thatthere are n = t2 observations in all.

Page 10: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 10'

&

$

%

Maximal model

• The maximal model when all are fixed, is

ΨR+C+T = E(Y) = XRβ +XCγ +XT τ and var(Y) = VY = σ2In

where

Y is the t2-vector of random variables for the response variable observations,

β is the t-vector of parameters specifying a different mean response for each row,

XR is the t2 × t matrix indicating the row from which an observation came,

γ is the t-vector of parameters specifying a different mean response for eachcolumn,

XC is the t2 × t matrix indicating the column from which an observation came,

τ is the t-vector of parameters specifying a different mean response for eachtreatment,

XT is the t2 × t matrix indicating the observations that received each of thetreatments.

• Our model also involves assuming Y ∼ N(ΨR+C+T ,VY).

Page 11: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 11'

&

$

%

Example V.2 A 3× 3 Latin square

• For example, suppose that a 3× 3 Latin square with the followingarrangement of treatments was being considered:

3× 3 Latin SquareColumn

1 2 3I A B C

Row II C A BIII B C A

• Suppose the random vector Y is ordered in standard order forRows then Columns.

Page 12: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 12'

&

$

%

• Then, for this example,

Y =

Y11A

Y12B

Y13C

Y21C

Y22A

Y23B

Y31B

Y32C

Y33A

XR =

1 0 0

1 0 0

1 0 0

0 1 0

0 1 0

0 1 0

0 0 1

0 0 1

0 0 1

XC =

1 0 0

0 1 0

0 0 1

1 0 0

0 1 0

0 0 1

1 0 0

0 1 0

0 0 1

XT =

1 0 0

0 1 0

0 0 1

0 0 1

1 0 0

0 1 0

0 1 0

0 0 1

1 0 0

• Note that XR = It ⊗ 1t and XC = 1t ⊗ It, but that XT cannotbe written as a direct product.

Page 13: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 13'

&

$

%

• The model for the expectation is still of the form E(Y) = Xθ,with X = [XR XC XT ] andθ′ = [β′ γ′ τ ′] = [β1, β2, · · · , βt, γ1, γ2, · · · , γt, τ1, τ2, · · · , τt]′.

• From the theory of linear models (see chapter XI, Brien’s notes)the estimators for ΨT = E(Y) = XBβ + XCγ + XT τ is given by

ΨR+C+T = R + C + T− 2G

where

R = XR(X′RXR)−1X′

RY = MRYC = XC(X′

CXC)−1X′CY = MCY

T = XT (X′T XT )−1X′

T Y = MT YG = XG(X′

GXG)−1X′GY = MGY

are the t2-vectors of row, column, treatment and grand means,respectively.

• That is, MR, MC , MT and MG are the row, column, treatmentand grand mean operators, respectively.

• So once again the fitted values are functions of means.

Page 14: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 14'

&

$

%

• Note that, if the data in the vector Y has been arranged instandard order for Rows then Columns the mean operators can bewritten as

MG = n−1Jt ⊗ Jt = t−2Jn

MR = t−1It ⊗ Jt

MC = t−1Jt ⊗ It

where ⊗ is called the direct product operator and

if Ar and Br are square matrices of order r and c, respectively,

Ar ⊗Bc =

a11B . . . a1rB. . . . . . . . .

ar1B . . . arrB

• In this case it is not possible to write MT as a direct product of Iand J matrices as the treatments will not be in a systematic orderexpressible in this form.

Page 15: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 15'

&

$

%

X′RXR = X′

CXC = X′T XT =

t 0 . . . 00 t . . . 0. . . . . . . . . . . .

0 0 . . . t

,

MR =

1t Jt 0t×t . . . 0t×t

0t×t1t Jt . . . 0t×t

. . . . . . . . . . . .

0t×t 0t×t . . . 1t Jt

, MC =

1t It

1t It . . . 1

t It

1t It

1t It . . . 1

t It

. . . . . . . . . . . .1t It

1t It . . . 1

t It

Page 16: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 16'

&

$

%

Example V.3 A 3× 3 Latin square (continued)

• For this example,

R =

R1

R1

R1

R2

R2

R2

R3

R3

R3

, C =

C1

C2

C3C1

C2

C3

C1

C2

C3

, T =

TA

TB

TC

TC

TA

TB

TB

TC

TA

, G =

G

G

G

G

G

G

G

G

G

where Rj. =∑t

k=1 Yjk

t, C.k =

∑tj=1 Yjk

t, Tl =

∑tl=1 Yjk(l)

tand

G =

∑tj=1

∑tk=1 Yjk

t2.

Page 17: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 17'

&

$

%

b) Alternative expectation models

• There are 8 possible different models for the expectation that weconsider:

ΨG = E(Y) = XGµ (no treatment, row or column differences)

ΨR = E(Y) = XRβ (row differences only)

ΨC = E(Y) = XCγ (column differences only)

ΨR+C = E(Y) = XRβ + XCγ (additive row and column differences)

ΨT = E(Y) = XT τ (treatment differences only)

ΨR+T = E(Y) = XRβ + XT τ (additive row and treatmentdifferences)

ΨC+T = E(Y) = XCγ + XT τ (additive column and treatmentdifferences)

ΨR+C+T = E(Y) = XRβ + XCγ + XT τ (additive row, column andtreatment differences)

Page 18: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 18'

&

$

%

• The estimators of the fitted values under the different models are:

ΨG = GΨR = RΨC = CΨR+C = R + C− G

ΨT = TΨR+T = R + T− G

ΨC+T = C + T− G

ΨR+C+T = R + T + C− 2G

• That is, they are all functions of the four mean vectors for thisdesign.

Page 19: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 19'

&

$

%

• We note the following marginality relations between the models:

ΨG ≤ ΨR,ΨC ,ΨR+C ,ΨT ,ΨR+T ,ΨC+T ,ΨR+C+T

ΨR ≤ ΨR+C ,ΨR+T ,ΨR+C+T

ΨC ≤ ΨR+C ,ΨC+T ,ΨR+C+T

ΨT ≤ ΨR+T ,ΨC+T ,ΨR+C+T

ΨR+C ,ΨR+T ,ΨC+T ≤ ΨR+C+T

Page 20: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 20'

&

$

%

V.C Hypothesis testing using the ANOVA method for an LS

• An analysis of variance will be used to choose between the eightalternative expectation models for an LS.

a) Analysis of an example

Example V.1 Sugarcane data: The following data are from an 5× 5LS experiment with 5 varieties (A: Co 290, B: Co 421, C: Co 419, D:POJ 2878, E: CO 36-13) of sugarcane. The response variable wasyield (kg/plot) of sugarcane.

5× 5 Latin SquareColumn Row

1 2 3 4 5 Totals432D 518A 458B 583C 331E 2322724C 478E 524A 550B 400D 2676489E 384B 556C 297D 420A 2146494B 500D 313E 486A 501C 2294515A 660C 438D 394E 318B 2325

Column Totals 2654 2540 2289 2310 1970 11763

TA = 2463, TB = 2204, TC = 3024, TD = 2067, TE = 2005

Page 21: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 21'

&

$

%

1 2 3 4 5

300

400

500

600

700

Rows

Yield

s

1 2 3 4 5

300

400

500

600

700

Columns

Yield

s

A B C D E

300

400

500

600

700

Treatments

Yield

s

Figure 1: Sugarcane LS data. Boxplots

• It would appear that there are yield mean differences between therows, columns and varieties.

Page 22: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 22'

&

$

%

Example V.1 Sugarcane LS experiment (continued):

Mean Variance StandardErrorA 492.6 1861.8 43.14858B 440.8 8339.2 91.31922C 604.8 7721.7 87.87320D 413.4 5544.8 74.46341E 401.0 6591.5 81.18805

• The differences between the treatment variances are not too large.

s2max

s2min

=8339.21861.8

= 4.5

Page 23: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 23'

&

$

%

• The hypothesis test for this example is:

Step 1: Set up hypotheses

a) H0 : τ1 = τ2 = . . . = τ5 (or XT τ not required in the model)

H1 : not all population Treatment means are equal

b) H0 : β1 = β2 = . . . = β5 (or XRβ not required in the model)

H1 : not all population Row means are equal

b) H0 : γ1 = γ2 = . . . = γ5 (or XCγ not required in the model)

H1 : not all population Column means are equal

Set α = 0.05.

Page 24: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 24'

&

$

%

Step 2: ANOVA table using R

Source df SSq MSq F Prob

Rows 4 30481 7620 2.68 0.0831 .

Columns 4 55641 13910 4.89 0.0142 *

Rows:Columns 16 171603

Varieties 4 137488 34372 12.09 0.0003 ***

Residual 12 34115 2843

Total 24 257725

Step 3: Decide between hypotheses

• It would appear that there are significant differences between thevarieties and columns but not between the rows.

Page 25: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 25'

&

$

%

b) Sums of squares for the analysis of variance

• The estimators of the sum of squares for the LS ANOVA are thesums of squares of the following vectors:Total or Units Deviation:DG = Y − G = (MU −MG)Y = QUY with QU = MU −MG

Rows Effect:Re = R− G = (MR −MG)Y = QRY with QR = MR −MG

Columns Effect:Ce = C− G = (MC −MG)Y = QCY with QC = MC −MG

Rows:Columns Deviation:DR+C = Y − R− C + G = (MU −MR −MC + MG)Y =QRCY with QRC = MU −MR −MC + MG

Treatments Effect:Te = T− G = (MT −MG)Y = QT Y with QT = MT −MG

Residual Deviation:DR+C+T = Y−R−C−T+2G = Y−Re−Ce−Te−G = (MU −MR−MC−MT +2MG)Y = QRCRes

Y with QRCRes= MU−MR−MC+2MG

where

• D’s are n-vectors of deviations from Y and

• Re, Ce and Te are n-vectors of Rows, Columns and Treatment effects.

Page 26: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 26'

&

$

%

Theorem V.1: For a latin squares design, the sums of squares in theanalysis of variance for Units, Rows, Columns, Rows:Columns,Treatments and Residual are given by the quadratic forms

Y′QUY = D′GDG, Y′QRY = R′eRe, Y′QCY = C′eCe,

Y′QRCY = D′RCDRC , Y′QT Y = T′eTe and Y′QRCRes

Y = D′R+C+T DR+C+T ,

respectively, where

QU = MU −MG, QR = MR −MG, QC = MC −MG,

QRC = MRC −MR −MC + MG, QT = MT −MG,

QRCRes = MU −MR −MC −MT + 2MG,

Y = InY = MUY = (It ⊗ It)Y,

G = 1t2 JnY = MGY = (t−2Jt ⊗ Jt)Y,

R = MRY = (t−1It ⊗ Jt)Y,

C = MCY = (t−1Jt ⊗ It)Y,

T = MT Y.

All the M’s and Q’s are symmetric (M = M′, Q = Q′) andidempotent (MM = M, QQ = Q).

Page 27: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 27'

&

$

%

• So the analysis of variance table is constructed as follows:

Source df SSq MSq F Prob

Rows t− 1 Y′QRY s2R

s2R

s2RCRes

pR

Columns t− 1 Y′QCY s2C

s2C

s2RCRes

pC

Rows:Columns (t− 1)2 Y′QRCY

Treatments t− 1 Y′QT Y s2T

s2T

s2RCRes

pT

Residual (t− 1)(t− 2) Y′QRCResY s2RCRes

Total t2 − 1 Y′QUY

where s2R =

Y′QRYt− 1

, s2C =

Y′QCYt− 1

, s2T =

Y′QT Yt− 1

and

s2RCRes

=Y′QRCRes

Y(t− 1)(t− 2)

.

Page 28: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 28'

&

$

%

Y′QUY =∑n

i=1 Y 2i − correction, where correction =

(∑n

i=1 Yi)2

n

Y′QRY =1t

t∑

j=1

R2j − correction, where Rj is total for row j

Y′QCY =1t

t∑

k=1

C2k − correction, where Ck is total for column k

Y′QT Y =1t

t∑

l=1

T 2(l) − correction, where T(l) is total for treatment l

Y′QRCResY = Y′QUY −Y′QRY −Y′QCY −Y′QT Y

Page 29: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 29'

&

$

%

c) Expected mean squares

• The expected means squares when both Rows and Columnseffects are fixed are given in the following table:

Source df MSq E(MSq) F

Rows t− 1Y′QRY

t− 1σ2 + qR(Ψ)

s2R

s2RCRes

Columns t− 1Y′QCY

t− 1σ2 + qC(Ψ)

s2C

s2RCRes

Rows:Columns (t− 1)2

Treatments t− 1Y′QT Y

t− 1σ2 + qT (Ψ)

s2T

s2RCRes

Residual (t− 1)(t− 2)Y′QRCRes

Y

(t− 1)(t− 2)σ2

Total t2 − 1

where qR(Ψ) =Ψ′QRΨ

t− 1=

∑ t(βj − β.)2

t− 1,

qC(Ψ) =Ψ′QCΨ

t− 1=

∑ t(γk − γ.)2

t− 1, qT (Ψ) =

Ψ′QT Ψ

t− 1=

∑ t(τl − τ .)2

t− 1.

Page 30: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 30'

&

$

%

• The expected means squares when both Rows and Columnseffects are random are given in the following table:

Source df MSq E(MSq) F

Rows t− 1Y′QRY

t− 1σ2 + tσ2

R

s2R

s2RCRes

Rows t− 1Y′QCY

t− 1σ2 + tσ2

C

s2C

s2RCRes

Rows:Columns (t− 1)2

Treatments t− 1Y′QT Y

t− 1σ2 + qT (Ψ)

s2T

s2RCRes

Residual (t− 1)(t− 2)Y′QRCRes

Y(t− 1)(t− 2)

σ2

Total t2 − 1

Page 31: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 31'

&

$

%

Also is possible to show that (Chapter XII of Chris Brien’s notes)

-Y′QRCRes

Y

σ2∼ χ2

(t−1)(t−2)

-Y′QT Y

σ2∼ χ2

t−1, under H0

-Y′QRCRes

Y

σ2and

Y′QT Y

σ2are independent

- F =Treatments MSq

Residual MSq∼ Ft−1,(t−1)(t−2)

-Y′QRY

σ2∼ χ2

t−1, under H0

-Y′QRCRes

Y

σ2and

Y′QRY

σ2are independent

- F =Rows MSq

Residual MSq∼ Ft−1,(t−1)(t−2)

-Y′QRCRes

Y

σ2and

Y′QCY

σ2are independent

- F =Columns MSq

Residual MSq∼ Ft−1,(t−1)(t−2)

Page 32: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 32'

&

$

%

d) Summary of the hypothesis test

Step 1: Set up hypotheses

a) H0 : τ1 = τ2 = . . . = τt (or XT τ not required in the model)

H1 : not all population Treatment means are equal

b) H0 : β1 = β2 = . . . = βt (or XRβ not required in the model)

H1 : not all population Row means are equal

b) H0 : γ1 = γ2 = . . . = γt (or XCγ not required in the model)

H1 : not all population Column means are equal

Set α = 0.05 (or 0.01).

Page 33: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 33'

&

$

%

Step 2: Calculate test statistic

Source df SSq MSq E(MSq) F Prob

Rows t− 1 Y′QRY s2R σ2 + qR(Ψ)

s2R

s2RCRes

pR

Columns t− 1 Y′QCY s2C σ2 + qC(Ψ) v

s2C

s2RCRes

pC

Rows:Columns (t− 1)2 Y′QRCY

Treatments t− 1 Y′QT Y s2T σ2 + qT (Ψ)

s2T

s2RCRes

pT

Residual (t− 1)(t− 2) Y′QRCResY s2

RCResσ2

Total t2 − 1 Y′QUY

where s2R =

Y′QRY

t− 1, s2

C =Y′QCY

t− 1, s2

T =Y′QT Y

t− 1and

s2RCRes

=Y′QRCRes

Y

(t− 1)(t− 2).

Step 3: Decide between hypotheses

• If P(F ≥ F0) = p ≤ α then the evidence suggests that the null hypothesis H0

should be rejected.

Page 34: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 34'

&

$

%

e) Comparison with traditional two-way ANOVA

• The above analysis of variance table and the traditionalLatin-square ANOVA table are essentially the same at any ratethe values of the F -statistics are exactly the same.

Source df Source in LS ANOVA

Rows t− 1 Between Rows

Columns t− 1 Between Columns

Rows:Columns (t− 1)2

Treatments t− 1 Between Treatments

Residual (t− 1)(t− 2) Error

Total t2 − 1

• The two tables have in common four sources that are labelleddifferently; they differ in that our table includes the lineRows:Columns.

Page 35: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 35'

&

$

%

• Rows:Columns reflects the variation of column differences fromrow to row or the differences in row-column combinations afteroverall row and overall column differences have been removed - itis uncontrolled variation in the units.

• The Rows:Columns sum of squares is partitioned into Treatmentsand Residual sums of squares.

• The advantage of the table we have presented is that it exhibitsthe confounding in the experiment.

• The indenting of Treatments under Rows:Columns signifies thattreatment differences are confounded or mixed-up withrow-column differences, adjusted for overall row and overallcolumn differences, as a result of the randomization of treatmentsto row-column combinations. This is not obvious from thetraditional table.

Page 36: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 36'

&

$

%

IV.D Diagnostic checking

• We have assumed a model on which the analysis outlined above isbased, that Y ∼ N(Ψ, σ2I) where, for the maximal model,ΨR+C+T = E(Y) = XRβ + XCγ + XT τ .

• For this model to be appropriate requires a set of behaviours as:

a) the response is operating additively, that is, that a treatmenthas about the same additive effect on each unit;

b) that the variability of the units within the row (column) are thesame for each row (column);

c) each observation displays the covariance implied by the model(independence for Rows and Column fixed and equal correlationwithin rows (columns) for Rows (Columns) random); and

d) that the response of the units is normally distributed.

Page 37: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 37'

&

$

%

• constant variance

– plot ei against fitted values ψi and look at pattern of spread –often easier to see any pattern by using absolute values |ei|

– tabulate sample variance of ei for any obvious subsets, e.g. byany classifying factors.

• Normality

– Plot the ordered residuals e(i) against the quantiles of a

standard normal distribution, Φ−1(i/(n + 1). A straight line=⇒ normality.

– Normal-plot with simulated envelope.

• NonadditivityUse Tukey’s one-degree-of-freedom-for-nonadditivity.

Page 38: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 38'

&

$

%

Example V.1 Sugarcane data (continued):

Source df SSq MSq F ProbRows 4 30481 7620 2.68 0.0831 .Columns 4 55641 13910 4.89 0.0142 *Rows:Columns 16 171603Varieties 4 137488 34372 12.09 0.0003 ***Residual 12 34115 2843

Nonadditivity 1 218 218 0.07 0.7953Deviation 11 33897 3081.54

Total 24 257724

• The hypotheses for the one-degree-of-freedom is:

H0: Rows, Columns and Varieties are additive

H1: Rows, Columns and Varieties are nonadditive

• The null hypothesis cannot be rejected and there is no evidence oftransformable nonadditivity.

Page 39: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 39'

&

$

%

400 500 600 700

−60

−40

−20

020

4060

fit

res

−2 −1 0 1 2

−60

−40

−20

020

4060

Normal Q−Q Plot

Theoretical Quantiles

Sam

ple

Qua

ntile

s

−2 −1 0 1 2

−2−1

01

2

t Quantiles

Stud

entiz

ed R

esid

uals

(LSS

ugar

cane

.lm)

Figure 2: Sugarcane LS. Residual plots

Page 40: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 40'

&

$

%

IV.E Treatment differences

• For the purposes of the scientist the effect of rows and columnsare not of primary interest.

• Rather, attention is likely to be focused on variety differenceswhich can be investigated using the variety means.

Example V.1 Sugarcane data (continued)

• The variety means (kg/plot) are:

Varieties

A B C D E

492.6 440.8 604.8 413.4 401.0

• As the variety levels are qualitative a multiple comparisonprocedure will be used to examine the differences between thevarieties if they were significant.

Page 41: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 41'

&

$

%

Tukey’s HSD procedure

Hypotheses: H0 : µk = µk′ versus H1 : µk 6= µk′

w(5%) = qt,ν,α

√1rResidual MSq = 4.51

√2843

5= 107.5

Varieties

E D B A

Means 401.0 413.4 440.8 492.6

D 413.4 12.4

B 440.8 39.8 27.4

A 492.6 91.6 79.2 51.8

C 604.8 203.8* 191.4* 164.0* 112.2*

Page 42: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 42'

&

$

%

−300 −200 −100 0 100 200

E−D

E−C

D−C

E−B

D−B

C−B

E−A

D−A

C−A

B−A

95% family−wise confidence level

Differences in mean levels of Treats

Page 43: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 43'

&

$

%

Conclusion:

• Evidence at the 5% level of significance that

µC 6= µA, µB , µD, µE

• There is one variety (Co 419) more productive that differs fromthe others.

E D B A C

401.0 413.4 440.8 492.6 604.8

a

b b b b

or

Page 44: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 44'

&

$

%

R program for LS Sugarcane data

library(dae)library(car)

LSSugarcane.dat <- data.frame(Rows=factor(rep(c(1,2,3,4,5), times=c(5,5,5,5,5))),Columns = factor(rep(c(1,2,3,4,5), times=5)))LSSugarcane.dat$Treats <- factor(c("D","A","B","C","E","C","E","A","B","D","E","B","C","D","A","B","D","E","A","C","A","C","D","E","B"))LSSugarcane.dat$Yields <- c(432,518,458,583,331,724,478,524,550,400,489,384,556,297,420,494,500,313,486,501,515,660,438,394,318)LSSugarcane.datattach(LSSugarcane.dat)

# boxplotspar(mfrow=c(1,3))boxplot(split(Yields, Rows), style.bxp = "old", xlab = "Rows", ylab= "Yields", medchar = T, medpch = 8)boxplot(split(Yields, Columns), style.bxp = "old", xlab = "Columns", ylab ="Yields", medchar = T, medpch = 8)boxplot(split(Yields, Treats), style.bxp = "old", xlab = "Treatments",ylab = "Yields", medchar = T, medpch = 8)par(mfrow=c(1,1))

# Variety means, variances and standard errosv <- tapply(Yields, Treats,var)data.frame(Mean= tapply(Yields, Treats,mean),Variance=v,StandardError= sqrt(v))rm(v)

# ANOVA using aov without error termLSSugarcane.NoError.aov <- aov(Yields ~ Rows + Columns + Treats, LSSugarcane.dat)summary(LSSugarcane.NoError.aov)

# ANOVA using aov with error term

Page 45: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 45'

&

$

%

LSSugarcane.aov <- aov(Yields ~ Rows + Columns + Treats + Error(Rows * Columns), LSSugarcane.dat)summary(LSSugarcane.aov)

#Compute Drivers and Cars Fs and p-valuesRows.F <- 7620/2843Rows.p <- 1 - pf(Rows.F, 4, 12)Columns.F <- 13910/2843Columns.p <- 1 - pf(Columns.F, 4, 12)data.frame(Rows.F, Rows.p, Columns.F, Columns.p)

# ANOVA using lmLSSugarcane.lm <- lm(Yields ~ Rows + Columns + Treats, LSSugarcane.dat)anova(LSSugarcane.lm)

# Diagnostic checkingfit<-fitted(LSSugarcane.lm)res<-residuals(LSSugarcane.lm)data.frame(Rows, Columns, Treats, Yields, res, fit)par(mfrow=c(1,2))plot(fit, res, pch = 16)qqnorm(res, pch = 16)qqline(res)par(mfrow=c(1,1))# normal-plot with simulation envelopelibrary(car)qq.plot(LSSugarcane.lm,simulate=TRUE,reps=999) #click on the point, use ESC in R to esc

# Test of nonadditivity - Tukey# directly from the package diagnostic.checking.rtukey.1df(LSSugarcane.aov, LSSugarcane.dat, error.term = "Rows:Columns")# or using lmLSSugarcane.lm <- lm(Yields ~ Rows + Columns + Treats)anova(LSSugarcane.lm , test="F")LP2 <- (predict(LSSugarcane.lm ))^2LSSugarcane.lm2 <-update(LSSugarcane.lm, .~. +LP2)anova(LSSugarcane.lm ,LSSugarcane.lm2, test="F")

# Multiple comparisons - Tukey’s HSD procedure

Page 46: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 46'

&

$

%

model.tables(LSSugarcane.aov, type="means")

q <- qtukey(0.95, 5, 12)

q

w <- qtukey(0.95, 5, 12)*summary(LSSugarcane.lm)$sigma/sqrt(5)

w

summary(LSSugarcane.aov <- aov(Yields ~ Rows + Columns + Treats))

TukeyHSD(LSSugarcane.aov , "Treats", ordered = TRUE)

plot(TukeyHSD(LSSugarcane.aov , "Treats"))

# Tukeys test using laercio library

require(laercio) # same as library(laercio)

LTukey(LSSugarcane.aov,"Treats",conf.level=0.95)

TUKEY TEST TO COMPARE MEANS

Confidence level: 0.95

Dependent variable: Yields

Variation Coefficient: 11.33189 %

Independent variable: Treats

Factors Means

C 604.8 a

A 492.6 b

B 440.8 b

D 413.4 b

E 401 b

detach(LSSugarcane.dat)

search()

Page 47: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 47'

&

$

%

IV.H Summary

In this chapter we have:

• described how to design an experiment using a Latin squaredesign;

• formulated a linear model using indicator variables to describe theresults from a Latin square design;

• given the estimators of the parameters in the linear model, thefitted values and the residuals as functions of M or mean operatormatrices;

• outlined an ANOVA hypothesis test for choosing betweenexpectation models;

– the partition of the total sums of squares was given with thesums of squares expressed as the sums of squares of theelements of vectors and as quadratic forms where the matricesof the quadratic forms, Q matrices, are symmetricidempotents;

Page 48: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 48'

&

$

%

– discussed the differences between the analyses where Rows andColumns are fixed and where they are random;

– the expected mean squares under the alternative expectationmodels are used to justify the choice of F test statistic;

• shown how to obtain a layout and the analysis of variance in R;

• discussed procedures for checking the adequacy of the proposedmodels;

• subsequent to the hypothesis test, examined treatment differencesin detail;

Page 49: Latin Square Designs (LS) - esalq.usp.br · Estat¶‡stica Experimental: Session 4 3 ’ & $ % V. Latin squares designs (LS) V.A Design of Latin squares † Sometimes we need more

Estatıstica Experimental: Session 4 49'

&

$

%

Exercise – Pig experiment The following data are from a 4× 4 LSexperiment at Animal Science Department, ESALQ/USP with 4treatments (A – Castration at 56 old, B – without castration, C –Castration at 7 days old, D – Castration at 21 days old).

The response variable was weight gain (kg), after 252 days.

The rows were litters and the columns were initial weight intervals(inside the litters)

Columns

Litters 1 2 3 4

1 93.0A 108.6B 108.9C 102.0D

2 115.4B 96.5D 77.9A 100.2C

3 102.1C 94.9A 116.9D 96.0B

4 117.6D 114.1C 118.7B 97.6A