Latin Square Design Design of Experiments - Montgomery Section 4-2
Latin Square Design Can be used when goal is to block on two nuisance factors Constructed so blocking factors orthogonal to treatment Must have same the number of blocks and treatments y ijk = µ + α i + τ j + β k + ǫ ijk α i - ith Block 1 effect (row) τ j - jth treatment effect β k - kth Block 2 effect (column) ǫ ijk N(0, σ 2 ) i = 1, 2,..., p j = 1, 2,..., p k = 1, 2,..., p Completely additive model (no interaction) Latin Square 2
Latin Square Design Design commonly represented in p p grid There are now two randomization restrictions One trt per row (row = blocking factor 1) One trt per column (column = blocking factor 2) Can randomly shuffle rows, columns, and treatments of standard square to get other variations of layout Standard square has treatment levels written alphabetically in the first row and first column. Other cells are filled using the same alphabetic order Latin Square 3
Layout Examples C B A B A C A C B D B C A B A C C D A B A C B B A D C C B A A C B D Latin Square 4
Proc PLAN title Latin Square Design ; proc plan seed=12; factors rows=4 ordered cols=4 ordered / NOPRINT; treatments tmts=4 cyclic; output out=g rows cvals=( Day 1 Day 2 Day 3 Day 4 ) random cols cvals=( Lab 1 Lab 2 Lab 3 Lab 4 ) random tmts nvals=( 0 100 250 450 ) random; proc tabulate; class rows cols; var tmts; table rows, cols*(tmts*f=6.) / rts=8; run; Latin Square 5
Proc PLAN Output cols Lab 1 Lab 2 Lab 3 Lab 4 tmts tmts tmts tmts Sum Sum Sum Sum rows Day 1 450 100 0 250 Day 2 100 0 250 450 Day 3 0 250 450 100 Day 4 250 450 100 0 Latin Square 6
Partitioning the SS Rewrite observation as: y ijk = y... + (y i.. y... ) + (y.j. y... ) + (y..k y... ) + (y ijk y i.. y.j. y..k + 2y.. ) = ˆµ + ˆα i + ˆτ j + ˆβk + ˆǫ ijk p Partition SS T into (y i.. y... ) 2 + p (y.j. y... ) 2 + p (y..k y... ) 2 + ˆǫ 2 ijk SS Row + SS Treatment + SS Col + SS E Under H 0, all SS/σ 2 independent chi-squared RVs Usual F-test analysis Caution testing column and row effects Latin Square 7
Analysis of Variance Table Source of Sum of Degrees of Mean F 0 Variation Squares Freedom Square Rows SS Row p 1 MS Row Treatment SS Treatment p 1 MS Treatment F 0 Column SS Column p 1 MS Column Error SS E (p 2)(p 1) MS E Total SS T p 2 1 If F 0 > F α,p 1,(p 2)(p 1) then reject H 0 Latin Square 8
Comparisons of Treatments Multiple Comparisons/Contrasts Similar procedures as before with CRD Replace n with p in all standard error formulas Degrees of freedom error is (p 2)(p 1) y.j. = µ + ᾱ. + τ j + β. + ǫ.j. Var(y.j. ) = 0 + 0 + 0 + 0 + σ 2 /p y.j. y.j. = τ j τ j + ǫ.j. ǫ.j. Var(y.j. y.j.) = 0 + 0 + σ 2 /p + σ 2 /p Latin Square 9
Missing Values When missing (and not due to treatment) Design unbalanced Orthogonality lost Order of fit important Procedures 1 Regression approach Use Type III sum of squares 2 Estimate missing value Choose value to minimize SS E Take derivative and set equal to zero y ijk = p(y i.. +y.j. +y..k ) 2y... (p 2)(p 1) Latin Square 10
Using SAS Consider experiment to investigate the effect of 4 diets on milk production. There are 4 cows. Each lactation period the cows receive a different diet. Assume there is a washout period so previous diet does not affect future results. Will therefore block on lactation period and cow. data new; input cow period trt resp @@; cards; 1 1 1 38 1 2 2 32 1 3 3 35 1 4 4 33 2 1 2 39 2 2 3 37 2 3 4 36 2 4 1 30 3 1 3 45 3 2 4 38 3 3 1 37 3 4 2 35 4 1 4 41 4 2 1 30 4 3 2 32 4 4 3 33 ; proc glm; class cow trt period; model resp=trt period cow; means trt/ lines tukey; lsmeans trt / adjust=tukey lines; output out=new1 r=res p=pred; symbol1 v=circle; proc gplot; plot res*pred; plot res*cow; plot res*trt; plot res*period; proc univariate noprint; histogram res / normal (L=1 mu=0 sigma=est) kernel (L=2); run; Latin Square 11
ANOVA Table Dependent Variable: resp Sum of Source DF Squares Mean Square F Value Pr > F Model 9 242.5625000 26.9513889 33.17 0.0002 Error 6 4.8750000 0.8125000 Corrected Total 15 247.4375000 Source DF Type I SS Mean Square F Value Pr > F trt 3 40.6875000 13.5625000 16.69 0.0026 period 3 147.1875000 49.0625000 60.38 <.0001 cow 3 54.6875000 18.2291667 22.44 0.0012 Source DF Type III SS Mean Square F Value Pr > F trt 3 40.6875000 13.5625000 16.69 0.0026 period 3 147.1875000 49.0625000 60.38 <.0001 cow 3 54.6875000 18.2291667 22.44 0.0012 Latin Square 12
Multiple Comparisons Tukey s Studentized Range (HSD) Test for resp Alpha 0.05 Error Degrees of Freedom 6 Error Mean Square 0.8125 Critical Value of Studentized Range 4.89559 Minimum Significant Difference 2.2064 Mean N trt A 37.5000 4 3 A 37.0000 4 4 B 34.5000 4 2 B 33.7500 4 1 Latin Square 13
Latin Square 14
Latin Square 15
Latin Square 16
Using Proc Mixed Often at least one block is considered random Example: 4 cows randomly chosen from large herd Want the inference to extend to the herd Sometimes time is one of the blocking factors Example: Each cow measured over 4 lactation periods This is an example of a crossover design Could observations closer together be more correlated? Proc Mixed can incorporate both concepts into model Latin Square 17
Random Effects Similar approach and results as with the RCBD Must be careful if using Proc GLM Standard error for a mean: Proc GLM incorrect Standard error for a contrast: Proc GLM correct GLM very limited in terms of handling repeated measures Latin Square 18
Comparison of Approaches proc glm; class cow trt period; model resp=cow trt period; random cow; lsmeans trt / stderr tdiff lines; proc mixed; class cow trt period; model resp=trt period / ddfm=kr; ***recommended df adjustment option random cow; lsmeans trt/ diff; run; ****F test for treatment is the same for both models ***** Latin Square 19
GLM Selected Output Standard LSMEAN trt resp LSMEAN Error Pr > t Number 1 33.7500000 0.4506939 <.0001 1 2 34.5000000 0.4506939 <.0001 2 3 37.5000000 0.4506939 <.0001 3 4 37.0000000 0.4506939 <.0001 4 resp LSMEAN LSMEAN trt Number A 37.50 3 3 A A 37.00 4 4 B 34.50 2 2 B B 33.75 1 1 Latin Square 20
MIXED Selected Output Least Squares Means Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.7500 1.1365 3.82 29.70 <.0001 trt 2 34.5000 1.1365 3.82 30.36 <.0001 trt 3 37.5000 1.1365 3.82 33.00 <.0001 trt 4 37.0000 1.1365 3.82 32.56 <.0001 Differences of Least Squares Means Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.7500 0.6374 6-1.18 0.2839 trt 1 3-3.7500 0.6374 6-5.88 0.0011 trt 1 4-3.2500 0.6374 6-5.10 0.0022 trt 2 3-3.0000 0.6374 6-4.71 0.0033 trt 2 4-2.5000 0.6374 6-3.92 0.0078 trt 3 4 0.5000 0.6374 6 0.78 0.4626 Latin Square 21
Correlated Errors Random effects induce correlations among observations Errors from same EU may also be correlated Errors closer in time may be more similar Can incorporate various correlation structures Given p obs per EU, consider a p p covariance matrix Main diagonal contains the variances Off-diagonal elements represent covariances Latin Square 22
Covariance Matrices Uncorrelated errors (for p = 4 obs/cow) σ 2 0 0 0 1 0 0 0 0 σ 2 0 0 0 0 σ 2 0 = σ 2 0 1 0 0 0 0 1 0 0 0 0 σ 2 0 0 0 1 1st order autoregressive (for p = 4 obs/cow) σ 2 1 ρ ρ 2 ρ 3 ρ 1 ρ ρ 2 ρ 2 ρ 1 ρ ρ 3 ρ 2 ρ 1 Latin Square 23
Covariance Matrices Compound symmetry (for p = 4 obs/cow) σ 2 + σ 1 σ 1 σ 1 σ 1 σ 1 σ 2 + σ 1 σ 1 σ 1 σ 1 σ 1 σ 2 + σ 1 σ 1 σ 1 σ 1 σ 1 σ 2 + σ 1 Toeplitz (for p = 4 obs/cow) σ 2 σ 1 σ 2 σ 3 σ 1 σ 2 σ 1 σ 2 σ 2 σ 1 σ 2 σ 1 σ 3 σ 2 σ 1 σ 2 Latin Square 24
Covariance Matrices Banded Toeplitz d = 2(for p = 4 obs/cow) σ 2 σ 1 0 0 σ 1 σ 2 σ 1 0 0 σ 1 σ 2 σ 1 0 0 σ 1 σ 2 Unstructured (for p = 4 obs/cow) σ1 2 σ 12 σ 13 σ 14 σ 12 σ2 2 σ 23 σ 24 σ 13 σ 23 σ3 2 σ 34 σ 14 σ 24 σ 34 σ4 2 Latin Square 25
Mixed Model Can be expressed Y = Xβ + Zδ + e X and Z describe the treatment and design structure β is a vector of the fixed effect parameters δ is a vector of the random effect parameters Typically assume δ and e are multivariate Normal (MVN) Mean 0 Covariance matrices G and R uncorrelated Latin Square 26
Conditional/Marginal Models Conditional model of Y δ is MVN E(Y δ) = Xβ + Zδ Cov(Y δ) = R Marginal model of Y is MVN E(Y ) = Xβ Cov(Y ) = ZGZ + R Can specify either model in MIXED. Random statement needed for conditional model. When dists Normal, both models give identical estimates, unless covariances negative Latin Square 27
SAS Code /* Fit a simple correlation structure for residuals */ /* Assuming cow is fixed - matches glm output on Slide 20 */ proc mixed covtest cl; class cow trt period; model resp=trt period cow / ddfm=kr outp=diag; repeated period / subject=cow type=simple r=1; lsmeans trt / diff; run; /* Assuming cow is random - matches mixed output on Slide 21 */ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; random intercept / subject=cow v=1; repeated period / subject=cow type=simple r=1; lsmeans trt / diff; run; Latin Square 28
Simple - Fixed effects Estimated R Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 0.8125 2 0.8125 3 0.8125 4 0.8125 Covariance Parameter Estimates Cov Standard Z Parm Subject Estimate Error Value Pr > Z Alpha Lower Upper period cow 0.8125 0.4691 1.73 0.0416 0.05 0.3374 3.9399 Fit Statistics -2 Res Log Likelihood 26.9 AIC (Smaller is Better) 28.9 BIC (Smaller is Better) 28.3 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 6 16.69 0.0026 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.7500 0.4507 6 74.88 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.7500 0.6374 6-1.18 0.2839 Latin Square 29
Simple - Random effects Estimated V Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 5.1667 4.3542 4.3542 4.3542 2 4.3542 5.1667 4.3542 4.3542 3 4.3542 4.3542 5.1667 4.3542 4 4.3542 4.3542 4.3542 5.1667 Covariance Parameter Estimates Standard Z Cov Parm Subject Estimate Error Value Pr > Z Alpha Lower Upper Intercept cow 4.3542 3.7229 1.17 0.1211 0.05 1.3461 73.9887 period cow 0.8125 0.4691 1.73 0.0416 0.05 0.3374 3.9399 Fit Statistics -2 Res Log Likelihood 41.3 AIC (Smaller is Better) 45.3 BIC (Smaller is Better) 44.1 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 6 16.69 0.0026 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.7500 1.1365 3.82 29.70 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.7500 0.6374 6-1.18 0.2839 Latin Square 30
SAS Code /* Fit Compound Symmetry - matches mixed output on Slide 21 */ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; repeated period / subject=cow type=cs r=1; lsmeans trt / diff; run; /* Fit an Unstructured correlation structure */ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; repeated period / type=un subject=cow; lsmeans trt / diff; run; Latin Square 31
Compound Symmetry Estimated R Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 5.1667 4.3542 4.3542 4.3542 2 4.3542 5.1667 4.3542 4.3542 3 4.3542 4.3542 5.1667 4.3542 4 4.3542 4.3542 4.3542 5.1667 Covariance Parameter Estimates Standard Z Cov Parm Subject Estimate Error Value Pr > Z Alpha Lower Upper CS cow 4.3542 3.7229 1.17 0.2422 0.05-2.9425 11.6508 Residual 0.8125 0.4691 1.73 0.0416 0.05 0.3374 3.9399 Fit Statistics -2 Res Log Likelihood 41.3 AIC (Smaller is Better) 45.3 BIC (Smaller is Better) 44.1 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 6 16.69 0.0026 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.7500 1.1365 3.82 29.70 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.7500 0.6374 6-1.18 0.2839 Latin Square 32
Unstructured WARNING: Stopped because of too many likelihood evaluations. Covariance Parameter Values At Last Iteration Cov Parm Subject Estimate UN(1,1) cow 2.4607 UN(2,1) cow 1.9933 UN(2,2) cow 5.7153 UN(3,1) cow 4.3270 UN(3,2) cow 5.1926 UN(3,3) cow 9.6422 UN(4,1) cow 3.7877 UN(4,2) cow 3.8424 UN(4,3) cow 7.4442 UN(4,4) cow 6.1382 **** SOME COVARIANCE STRUCTURES ARE TOO COMPLEX FOR THE DATA **** Latin Square 33
SAS Code /* Fit an AR(1) correlation structure for residuals*/ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; repeated period / type=ar(1) subject=cow r=1; lsmeans trt / diff; run; /* Fit an AR(1) correlation structure for residuals*/ /* Add cow random effect */ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; random intercept / subject=cow v=1; repeated period / type=ar(1) subject=cow r=1; lsmeans trt / diff; run; Latin Square 34
AR(1) Estimated R Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 4.6509 3.8900 3.2536 2.7213 2 3.8900 4.6509 3.8900 3.2536 3 3.2536 3.8900 4.6509 3.8900 4 2.7213 3.2536 3.8900 4.6509 Covariance Parameter Estimates Standard Z Cov Parm Subject Estimate Error Value Pr Z Alpha Lower Upper AR(1) cow 0.8364 0.1277 6.55 <.0001 0.05 0.5861 1.0867 Residual 4.6509 3.0108 1.54 0.0612 0.05 1.7820 29.7337 Fit Statistics -2 Res Log Likelihood 42.0 AIC (Smaller is Better) 46.0 BIC (Smaller is Better) 44.8 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 5.7 10.76 0.0091 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.6574 1.0414 4.53 32.32 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.7732 0.7289 5.7-1.06 0.3317 trt 1 3-4.0457 0.8397 5.84-4.82 0.0032 Latin Square 35
AR(1) with random cow effect Estimated V Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 5.0751 4.3489 4.1903 4.1556 2 4.3489 5.0751 4.3489 4.1903 3 4.1903 4.3489 5.0751 4.3489 4 4.1556 4.1903 4.3489 5.0751 Covariance Parameter Estimates Standard Z Cov Parm Subject Estimate Error Value Pr Z Alpha Lower Upper Intercept cow 4.1459 3.7154 1.12 0.1322 0.05 1.2331 88.2186 AR(1) cow 0.2184 0.5794 0.38 0.7062 0.05-0.9171 1.3540 Residual 0.9292 0.7343 1.27 0.1029 0.05 0.3061 11.3252 Fit Statistics -2 Res Log Likelihood 41.2 AIC (Smaller is Better) 47.2 BIC (Smaller is Better) 45.3 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 5.04 8.65 0.0197 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.7306 1.1424 3.81 29.53 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.7200 0.7831 5.82-0.92 0.3943 trt 1 3-3.8257 0.8834 5.51-4.33 0.0060 Latin Square 36
SAS Code /* Fit an TOEP(2) correlation structure for residuals*/ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; repeated period / type=toep(2) subject=cow r=1; lsmeans trt / diff; run; /* Fit an Heterogeneous CS correlation structure for residuals*/ proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; repeated period / type=csh subject=cow r=1; lsmeans trt / diff; run; Latin Square 37
Banded TOEP(2) Estimated R Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 4.8110 2.7620 2 2.7620 4.8110 2.7620 3 2.7620 4.8110 2.7620 4 2.7620 4.8110 Covariance Parameter Estimates Standard Z Cov Parm Subject Estimate Error Value Pr Z Alpha Lower Upper TOEP(2) cow 2.7620 1.5679 1.76 0.0781 0.05-0.3110 5.8350 Residual 4.8110 2.4887 1.93 0.0266 0.05 2.1482 18.7489 Fit Statistics -2 Res Log Likelihood 45.0 AIC (Smaller is Better) 49.0 BIC (Smaller is Better) 47.8 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 3.33 2.02 0.2751 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.5524 1.1236 8.86 29.86 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-1.5006 1.2047 7.06-1.25 0.2526 trt 1 3-4.2288 1.6494 8.18-2.56 0.0329 Latin Square 38
CSH Estimated R Matrix for cow 1 Row Col1 Col2 Col3 Col4 1 1.4288 2.1325 3.4799 2.8649 2 2.1325 3.6114 5.5323 4.5546 3 3.4799 5.5323 9.6162 7.4321 4 2.8649 4.5546 7.4321 6.5176 Covariance Parameter Estimates Cov Standard Z Parm Subject Estimate Error Value Pr Z Alpha Lower Upper Var(1) cow 1.4288 1.2819 1.11 0.1325 0.05 0.4246 30.5790 Var(2) cow 3.6114 3.0137 1.20 0.1154 0.05 1.1388 55.0752 Var(3) cow 9.6162 7.9587 1.21 0.1135 0.05 3.0525 141.54 Var(4) cow 6.5176 5.3805 1.21 0.1129 0.05 2.0731 94.8982 CSH cow 0.9388 0.05846 16.06 <.0001 0.05 0.8242 1.0534 Fit Statistics -2 Res Log Likelihood 34.8 AIC (Smaller is Better) 44.8 BIC (Smaller is Better) 41.7 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F trt 3 5.3 40.08 0.0005 Effect trt Estimate Std Error DF t Value Pr > t trt 1 33.3399 1.1103 3.21 30.03 <.0001 Effect trt _trt Estimate Std Error DF t Value Pr > t trt 1 2-0.9207 0.4999 5.28-1.84 0.1218 trt 1 3-4.8929 0.5084 5.34-9.62 0.0001 Latin Square 39
Summary When comparing models with a model selection criterion, REML fitting can only be used when fixed effects structure does not change. If different models with different fixed effects were compared, would have to use ML estimation, even though variance/covariance parameters are biased This is because REML uses a transformed set of data that takes into account loss of DF due to estimating fixed effects From the results here, heterogenous compound symmetry is the best choice provided residuals look ok Latin Square 40