




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





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(tmtsf=6.) / rts=8; run;
| | 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| |______|______|______|______|______|
Partitioning the SS
yijk = y (^) ... + (y (^) i.. − y (^) ...) + (y (^) .j. − y (^) ...) + (y (^) ..k − y (^) ...) + (yijk − y (^) i.. − y (^) .j. − y (^) ..k + 2y (^) ..) = ˆμ + ˆαi + ˆτj + βˆ (^) k + ˆ≤ijk
p
∑ (y (^) i.. − y (^) ...) 2 + p
∑ (y (^) .j. − y (^) ...) 2 + p
∑ (y (^) ..k − y (^) ...) 2 +
∑ ∑ ˆ≤^2 ijk
SS (^) Row + SS (^) Treatment + SS (^) Col + SS (^) E
Analysis of Variance Table
∑ ∑ ∑
1 p
∑
1 p
∑
1 p
∑
Missing Values
Use Type III sum of squares
Choose value to minimize SSE
Take derivative and set equal to zero
y (^) ijk =
Using SAS
options nocenter ls=75;goptions colors=(none);
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; means period cow; output out=new1 r=res p=pred;
symbol1 v=circle; proc gplot; plot res*pred;
proc univariate noprint; histogram res / normal (L=1 mu=0 sigma=est) kernel (L=2); run;
The GLM Procedure 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
Least Squares Means for Effect trt i/j 1 2 3 4 1 -1.1767 -5.88348 -5. 0.2839 0.0011 0. 2 1.176697 -4.70679 -3. 0.2839 0.0033 0. 3 5.883484 4.706787 0. 0.0011 0.0033 0. 4 5.09902 3.922323 -0. 0.0022 0.0078 0.
The Mixed Procedure Least Squares Means Effect trt Estimate Std Error DF t Value Pr > |t| trt 1 33.7500 1.1365 6 29.70 <. trt 2 34.5000 1.1365 6 30.36 <. trt 3 37.5000 1.1365 6 33.00 <. trt 4 37.0000 1.1365 6 32.56 <.
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. trt 1 3 -3.7500 0.6374 6 -5.88 0. trt 1 4 -3.2500 0.6374 6 -5.10 0. trt 2 3 -3.0000 0.6374 6 -4.71 0. trt 2 4 -2.5000 0.6374 6 -3.92 0. trt 3 4 0.5000 0.6374 6 0.78 0.
12-
Correlated Observations
σ^2 0 0 0 σ^2 0 0 0 σ^2 0 0 0 σ^2
(^) = σ^2
[ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
]
σ^2
1 ρ ρ^2 ρ^3 ρ 1 ρ ρ^2 ρ^2 ρ 1 ρ ρ^3 ρ^2 ρ 1
SAS Code
/* Fit a simple correlation structure / / Similar to standard mixed analysis */
proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; random cow; repeated period / subject=cow type=simple; lsmeans trt / diff; run;
/* Fit an AR(1) correlation structure */
proc mixed covtest cl; class cow trt period; model resp=trt period / ddfm=kr outp=diag; random cow; repeated period / type=ar(1) subject=cow; lsmeans trt / diff; run;
Dimensions Covariance Parameters 2 Columns in X 9 Columns in Z 4
Fit Statistics -2 Res Log Likelihood 41. AIC (smaller is better) 45. AICC (smaller is better) 47. BIC (smaller is better) 44.
Covariance Parameter Estimates Parm Subject Estimate Std Error Z Value Pr Z Alpha Lower Upper cow 4.3542 3.7229 1.17 0.1211 0.05 1.346 73. period cow 0.8125 0.4691 1.73 0.0416 0.05 0.337 3.
Type 3 Tests of Fixed Effects Effect Num DF Den DF F Value Pr > F trt 3 6 16.69 0. period 3 6 60.38 <.
Least Squares Means Effect trt Estimate Std Error DF t Value Pr > |t| trt 1 33.7500 1.1365 3.82 29.70 <. trt 2 34.5000 1.1365 3.82 30.36 <. trt 3 37.5000 1.1365 3.82 33.00 <. trt 4 37.0000 1.1365 3.82 32.56 <.
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. trt 1 3 -3.7500 0.6374 6 -5.88 0. trt 1 4 -3.2500 0.6374 6 -5.10 0. trt 2 3 -3.0000 0.6374 6 -4.71 0. trt 2 4 -2.5000 0.6374 6 -3.92 0. trt 3 4 0.5000 0.6374 6 0.78 0.
Dimensions Covariance Parameters 3 Columns in X 9 Columns in Z 4
Fit Statistics -2 Res Log Likelihood 41. AIC (smaller is better) 47. AICC (smaller is better) 52. BIC (smaller is better) 45.
Covariance Parameter Estimates Cov Parm Subject Estimate Std Error Z Value Pr Z Alpha Lower Upper cow 4.1459 3.7154 1.12 0.1322 0.05 1.2331 88. AR(1) cow 0.2184 0.5794 0.38 0.7062 0.05 -0.9171 1. Residual 0.9292 0.7343 1.27 0.1029 0.05 0.3061 11.
Type 3 Tests of Fixed Effects Effect Num DF Den DF F Value Pr > F trt 3 5.04 8.65 0. period 3 4.06 41.27 0.
Least Squares Means Effect trt Estimate Std Error DF t Value Pr > |t| trt 1 33.7306 1.1424 3.81 29.53 <. trt 2 34.4506 1.1424 3.81 30.16 <. trt 3 37.5563 1.1424 3.81 32.87 <. trt 4 37.0125 1.1424 3.81 32.40 <.
Effect trt _trt Estimate Std Error DF t Value Pr > |t| trt 1 2 -0.7200 0.7831 5.82 -0.92 0. trt 1 3 -3.8257 0.8834 5.51 -4.33 0. trt 1 4 -3.2819 0.7831 5.82 -4.19 0. trt 2 3 -3.1057 0.7831 5.82 -3.97 0. trt 2 4 -2.5619 0.8834 5.51 -2.90 0. trt 3 4 0.5438 0.7831 5.82 0.69 0.
12-
Replicated Latin Square
Replicate Square
yijkl = μ + α (^) i + τj + β (^) k + δl + ≤ijkl
{ (^) i = 1, 2 ,... , p j = 1, 2 ,... , p k = 1, 2 ,... , p l = 1, 2 ,... , n
Source of Sum of Degrees of Mean F Variation Squares Freedom Square Rows SS (^) Row p − 1 Columns SSColumn p − 1 Replicate SSReplicate n − 1 Treatment SSTreatment p − 1 MSTreatment F 0 Error SSE (p − 1)(n(p + 1) − 3) MSE Total SS (^) T np^2 − 1
Replicated Rows (or columns)
∑
∑
yijkl = μ + α (^) i(l) + τj + β (^) k + δl + ≤ijkl
{ i = 1, 2 ,... , p j = 1, 2 ,... , p k = 1, 2 ,... , p l = 1, 2 ,... , n
Source of Sum of Degrees of Mean F Variation Squares Freedom Square Rows SS (^) Row n(p − 1) Columns SSColumn p − 1 Replicate SSReplicate n − 1 Treatment SSTreatment p − 1 MSTreatment F 0 Error SSE (p − 1)(np − 2) MSE Total SS (^) T np^2 − 1
Residual Effects
But what if there is a residual effect. In other words, the treatment effect is different for the different periods. The model can then be written
Trt 1 first : diff (^1) k = (τ 1 − τ 2 ′ ) + (P 1 − P 2 ) + e 1 k Trt 2 first : diff (^2) k = (τ 2 − τ 1 ′ ) + (P 1 − P 2 ) + e 2 k
Thus diff 1 −diff 2 estimates (τ 1 −τ 2 )+(τ 1 ′−τ ′ 2 ). Cannot yield inference about both differences (i.e., confounded).
Can test for residual effect by looking at sums instead of differences. Subject variability incorporated into error (δijk = ≤ijk + S (^) k)
Trt 1 first : sum 1 k = 2μ + (τ 1 + τ 2 ′ ) + (P 1 + P 2 ) + δ 1 k Trt 2 first : sum (^2) k = 2μ + (τ 2 + τ 1 ′ ) + (P 1 + P 2 ) + δ 2 k
Thus sum 1 − sum 2 estimates (τ 1 − τ 2 )-(τ 1 ′ − τ 2 ′ ). Can check to see if different from zero. Problem if that occurs. Low power test because it incorporates subject to subject variability.
yijk = μ + Pi + τj + S (^) k + r (^) ij′ + ≤ijk
{ i = 1, 2 ,... , p j = 1, 2 ,... , p k = 1, 2 ,... , np
where rij′ only occurs when i 6 = 1 and j′^ references the trt used in the previous period.
SAS Code
options nocenter ls=75;goptions colors=(none);
data new; input cow period trt resp @@; if period=1 then resid=0; else resid=a; resid1=0; resid2=0; resid3=0; if resid=1 then resid1=1; if resid=4 then resid1=-1; if resid=2 then resid2=1; if resid=4 then resid2=-1; if resid=3 then resid3=1; if resid=4 then resid3=-1; a=trt; retain a; 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 print;
proc glm; class cow period trt; model resp=cow period trt resid1 resid2 resid3 /solution; lsmeans trt / stderr pdiff cl; run;
Obs cow period trt resp resid resid1 resid2 resid 1 1 1 1 38 0 0 0 0 2 1 2 2 32 1 1 0 0 3 1 3 3 35 2 0 1 0 4 1 4 4 33 3 0 0 1 5 2 1 2 39 0 0 0 0 6 2 2 3 37 2 0 1 0 7 2 3 4 36 3 0 0 1 8 2 4 1 30 4 -1 -1 -
......... 16 4 4 3 33 2 0 1 0
Sum of Source DF Squares Mean Square F Value Pr > F Model 12 244.6875000 20.3906250 22.24 0. Error 3 2.7500000 0. Corrected Total 15 247.
Source DF Type I SS Mean Square F Value Pr > F cow 3 54.6875000 18.2291667 19.89 0. period 3 147.1875000 49.0625000 53.52 0. trt 3 40.6875000 13.5625000 14.80 0. resid1 1 0.5625000 0.5625000 0.61 0. resid2 1 0.5208333 0.5208333 0.57 0. resid3 1 1.0416667 1.0416667 1.14 0.
Source DF Type III SS Mean Square F Value Pr > F cow 3 46.0833333 15.3611111 16.76 0. period 3 147.1875000 49.0625000 53.52 0. trt 3 7.8409091 2.6136364 2.85 0. resid1 1 0.3750000 0.3750000 0.41 0. resid2 1 1.0416667 1.0416667 1.14 0. resid3 1 1.0416667 1.0416667 1.14 0.
Tests of importance Source DF Type III SS Mean Square F Value Pr > F trt 3 7.8409091 2.6136364 2.85 0. resid 3 2.1250000 7.0833333 0.77 0.
Standard Parameter Estimate Error t Value Pr > |t| Intercept 33.00000000 B 0.95742711 34.47 <. cow 1 0.62500000 B 0.82915620 0.75 0. cow 2 2.00000000 B 0.82915620 2.41 0. cow 3 5.37500000 B 0.82915620 6.48 0. cow 4 0.00000000 B... period 1 8.00000000 B 0.67700320 11.82 0. period 2 1.50000000 B 0.67700320 2.22 0. period 3 2.25000000 B 0.67700320 3.32 0. period 4 0.00000000 B... trt 1 -3.62500000 B 1.58771324 -2.28 0. trt 2 -4.00000000 B 1.58771324 -2.52 0. trt 3 -1.37500000 B 1.58771324 -0.87 0. trt 4 0.00000000 B... resid1 0.75000000 1.17260394 0.64 0. resid2 1.25000000 1.17260394 1.07 0. resid3 -1.25000000 1.17260394 -1.07 0.
Residual Effect of A increases response 0.75 units Residual Effect of B increases response 1.25 units Residual Effect of C decreases response 1.25 units Residual Effect of D decreases response 0.75 units
LSMEAN trt 1 = 35.6875 + (-3.625 - .25(-3.625-4.000-1.375)) = 34. = grand mean + trt effect
LSMEAN trt 2 = 35.6875 + (-4.000 - .25(-3.625-4.000-1.375)) = 33. = grand mean + trt effect
Least Squares Means Standard LSMEAN trt resp LSMEAN Error Pr > |t| Number
1 34.3125000 1.0013012 <.0001 1 2 33.9375000 1.0013012 <.0001 2 3 36.5625000 1.0013012 <.0001 3 4 37.9375000 1.0013012 <.0001 4
Least Squares Means for effect trt Pr > |t| for H0: LSMean(i)=LSMean(j)
Dependent Variable: resp i/j 1 2 3 4 1 0.8285 0.2514 0. 2 0.8285 0.1968 0. 3 0.2514 0.1968 0. 4 0.1066 0.0862 0.
Least Squares Means for Effect trt Difference Between 95% Confidence Limits for i j Means LSMean(i)-LSMean(j)
1 2 0.375000 -4.677812 5. 1 3 -2.250000 -7.302812 2. 1 4 -3.625000 -8.677812 1. 2 3 -2.625000 -7.677812 2. 2 4 -4.000000 -9.052812 1. 3 4 -1.375000 -6.427812 3.
Designs Balanced For Residual
Effects