Lecture 13: Experiments With Random Effects: Montgomery, Chapter 12 or 13
Lecture 13: Experiments With Random Effects: Montgomery, Chapter 12 or 13
Spring , 2008
Page 1
Statistics 514: Experiments with Random Effects
Example 1
A textile company weaves a fabric on a large number of looms. It would like the looms to
be homogeneous so that it obtains a fabric of uniform strength. A process engineer
suspects that, in addition to the usual variation in strength within samples of fabric from the
same loom, there may also be significant variations in strength between looms. To
investigate this, she selects four looms at random and makes four strength determinations
on the fabric manufactured on each loom. The layout and data are given in the following.
Observations
looms 1 2 3 4
1 98 97 99 96
2 91 90 93 92
3 96 95 97 95
4 95 96 99 98
Spring , 2008
Page 2
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 3
Statistics 514: Experiments with Random Effects
µ - grand mean
τi - ith treatment effect (random)
ǫij ∼ N(0, σ 2 )
P
• Instead of τi = 0, assume
τi ∼ N(0, στ2 )
{τi } and {ǫij } independent
• Var(yij ) = στ2 + σ 2
Spring , 2008
Page 4
Statistics 514: Experiments with Random Effects
Statistical Analysis
Source SS DF MS F0
MStr
Between SStr a−1 MStr F0 = MSE
Spring , 2008
Page 5
Statistics 514: Experiments with Random Effects
Estimation
Spring , 2008
Page 6
Statistics 514: Experiments with Random Effects
Confidence intervals
(N − a)MSE 2 (N − a)MSE
≤ σ ≤
χ2α/2,N −a χ21−α/2,N −a
σ 2 + nστ2 2 σ2
σ̂τ2 ≈ χa−1 − χ2N −a
n(a − 1) n(N − a)
No closed form expression for this distribution. Can use approximation
Spring , 2008
Page 7
Statistics 514: Experiments with Random Effects
Recall
M Str /(σ 2 + nστ2 )
∼ Fa−1,N −a
M SE /σ 2
• For στ2 /σ 2 :
στ2
L≤ 2 ≤U
σ
MStr MStr
L= MSE Fα/2,a−1,N −a
− 1 /n and U = MSE F − 1 /n
1−α/2,a−1,N −a
L στ2 U
≤ 2 ≤ , or
L+1 σ + στ2 U+1
Spring , 2008
Page 8
Statistics 514: Experiments with Random Effects
Total 111.94 15
Spring , 2008
Page 9
Statistics 514: Experiments with Random Effects
Loom Experiment
Confidence Intervals
• 95% CI for σ 2
SSE SSE
≤ σ2 ≤ = c(22.75/23.34, 22.75/4.40)
χ2.025,12 χ2.975,12
= (0.97, 5.17)
Spring , 2008
Page 10
Statistics 514: Experiments with Random Effects
Using SAS
options nocenter ps=35 ls=72;
data example;
input loom strength;
datalines;
1 98
1 97
1 99
1 96
.
4 98
;
proc glm;
class loom;
model strength=loom;
random loom;
output out=diag r=res p=pred;
proc plot;
Spring , 2008
Page 11
Statistics 514: Experiments with Random Effects
plot res*pred;
Spring , 2008
Page 12
Statistics 514: Experiments with Random Effects
SAS Output
Dependent Variable: strength
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 3 89.1875000 29.7291667 15.68 0.0002
Error 12 22.7500000 1.8958333
Corrected Total 15 111.9375000
Spring , 2008
Page 13
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 14
Statistics 514: Experiments with Random Effects
Iteration History
Iteration Evaluations -2 Res Log Like Criterion
0 1 75.48910190
1 1 63.19303249 0.00000000
Convergence criteria met.
Fit Statistics
-2 Res Log Likelihood 63.2
AIC (smaller is better) 67.2
AICC (smaller is better) 68.2
BIC (smaller is better) 66.0
Spring , 2008
Page 15
Statistics 514: Experiments with Random Effects
1 21 20 20 20 19 21
2 24 23 24 24 23 24
3 20 21 19 21 20 22
. . . . . . .
19 25 26 25 24 25 25
20 19 19 18 17 19 17
Spring , 2008
Page 16
Statistics 514: Experiments with Random Effects
i = 1, 2, . . . , a
yijk = µ + τi + βj + (τ β)ij + ǫijk j = 1, 2, . . . , b
k = 1, 2, . . . , n
Spring , 2008
Page 17
Statistics 514: Experiments with Random Effects
• Proc Mixed
Variance component estimates
Spring , 2008
Page 18
Statistics 514: Experiments with Random Effects
data randr;
input part operator resp @@;
cards;
1 1 21 1 1 20 1 2 20 1 2 20 1 3 19 1 3 21
2 1 24 2 1 23 2 2 24 2 2 24 2 3 23 2 3 24
3 1 20 3 1 21 3 2 19 3 2 21 3 3 20 3 3 22
4 1 27 4 1 27 4 2 28 4 2 26 4 3 27 4 3 28
..........................................
20 1 19 20 1 19 20 2 18 20 2 17 20 3 19 20 3 17
;
proc glm;
class operator part;
model resp=operator|part;
random operator part operator*part / test;
test H=operator E=operator*part;
test H=part E=operator*part;
Spring , 2008
Page 19
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 20
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 21
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 22
Statistics 514: Experiments with Random Effects
Sum of
Source DF Squares Mean Square
operator 2 2.616667 1.308333
part 19 1185.425000 62.390789
operator*part 38 27.050000 0.711842
Residual 60 59.500000 0.991667
Spring , 2008
Page 23
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 24
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 25
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 26
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 27
Statistics 514: Experiments with Random Effects
6 To find the expected mean square of any term (row), cover the entries in the
columns that contain non-bracketed subscript letters in this term in the model. For
those rows with at least the same subscripts, multiply the remaining numbers to
get coefficient for corresponding term in the model.
Spring , 2008
Page 28
Statistics 514: Experiments with Random Effects
F F R
a b n
term i j k EMS
2 bnΣτi2
τi 0 b n σ + a−1
2 anΣβj2
βj a 0 n σ + b−1
2 nΣΣ(τ β)2ij
(τ β)ij 0 0 n σ + (a−1)(b−1)
2
ǫ(ij)k 1 1 1 σ
Spring , 2008
Page 29
Statistics 514: Experiments with Random Effects
R R R
a b n
term i j k EMS
τi 1 b n σ 2 + nστ2β + bnστ2
βj a 1 n σ 2 + nστ2β + anσβ2
(τ β)ij 1 1 n σ 2 + nστ2β
ǫ(ij)k 1 1 1 σ2
Spring , 2008
Page 30
Statistics 514: Experiments with Random Effects
F R R
a b n
term i j k EMS
2 bnΣτi2
τi 0 b n σ + nστ2β + a−1
βj a 1 n σ2 + anσβ2
(τ β)ij 0 1 n σ 2 + nστ2β
ǫ(ij)k 1 1 1 σ2
Spring , 2008
Page 31
Statistics 514: Experiments with Random Effects
F R R R
a b c n
term i j k l EMS
2 bcnΣτi2
τi 0 b c n σ + cnστ2β + bnστ2γ + nστ2βγ + a−1
βj a 1 c n σ 2 + anσβγ
2
+ acnσβ2
γk a b 1 n σ 2 + anσβγ
2
+ abnσγ2
(τ β)ij 0 1 c n σ 2 + nστ2βγ + cnστ2β
(τ γ)ik 0 b 1 n σ 2 + nστ2βγ + bnστ2γ
(βγ)jk a 1 1 n σ 2 + anσβγ
2
(τ βγ)ijk 0 1 1 n σ 2 + nστ2βγ
ǫijkl 1 1 1 1 σ2
Spring , 2008
Page 32
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 33
Statistics 514: Experiments with Random Effects
• Testing hypotheses:
H0 : τ1 = τ2 = . . . = 0 → MSA /MSAB
H0 : σβ2 = 0 → MSB /MSE
H0 : στ2β = 0 → MSAB /MSE
• Diagnostics
– Histogram or QQplot
Normality or Unusual Observations
– Residual Plots
Constant variance or Unusual Observations
Spring , 2008
Page 34
Statistics 514: Experiments with Random Effects
2 2
Var(y i.. − y i′ .. ) = 2στ β /b + 2σ /bn
= 2(nστ2β + σ 2 )/bn
• Need to plug in variance estimates to compute Var(y i.. )
• What are the DF?
• For pairwise comparisons, use estimate 2MSAB /bn
• Use dfAB for t-statistic or Tukey’s method.
Spring , 2008
Page 35
Statistics 514: Experiments with Random Effects
data randr;
input part operator resp @@;
cards;
1 1 21 1 1 20 1 2 20 1 2 20 1 3 19 1 3 21
2 1 24 2 1 23 2 2 24 2 2 24 2 3 23 2 3 24
3 1 20 3 1 21 3 2 19 3 2 21 3 3 20 3 3 22
4 1 27 4 1 27 4 2 28 4 2 26 4 3 27 4 3 28
.........................................
20 1 19 20 1 19 20 2 18 20 2 17 20 3 19 20 3 17
;
proc glm;
class operator part;
model resp=operator|part;
run;
==================================================
Dependent Variable: resp
Sum of
Spring , 2008
Page 36
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 37
Statistics 514: Experiments with Random Effects
• H0 : τ1 = τ2 = τ3 = 0:
M SA 1.308
F0 = = = 1.84
M SAB 0.712
P-value based on F2,38 : 0.173.
• H0 : σβ2 = 0:
M SB 62.391
F0 = = = 62.89
M SE 0.992
P-value based on F19,60 : 0.000
• H0 : στ2β = 0:
M SAB 0.712
F0 = = = 0.72
M SE 0.992
P-value based on F38,60 : 0.86
Spring , 2008
Page 38
Statistics 514: Experiments with Random Effects
0.71 − 0.99
σ̂τ2β = = −.14(≈ 0)
2
σ̂ 2 = 0.99
Spring , 2008
Page 39
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 40
Statistics 514: Experiments with Random Effects
• Connection
(τ¯β).j = (
X
(τ β)ij )/a
i
Check the model above satisfies the conditions of restricted mixed model
Spring , 2008
Page 41
Statistics 514: Experiments with Random Effects
data randr;
input part operator resp @@;
cards;
1 1 21 1 1 20 1 2 20 1 2 20 1 3 19 1 3 21
2 1 24 2 1 23 2 2 24 2 2 24 2 3 23 2 3 24
3 1 20 3 1 21 3 2 19 3 2 21 3 3 20 3 3 22
4 1 27 4 1 27 4 2 28 4 2 26 4 3 27 4 3 28
.
.
;
proc glm;
class operator part;
model resp=operator|part;
random part operator*part / test;
means operator / tukey lines E=operator*part;
lsmeans operator / adjust=tukey E=operator*part tdiff stderr;
Spring , 2008
Page 42
Statistics 514: Experiments with Random Effects
Spring , 2008
Page 43
Statistics 514: Experiments with Random Effects
Approximate F Tests
Spring , 2008
Page 44
Statistics 514: Experiments with Random Effects
Source DF MS EMS F P
2 2
A 2 0.7866 12φA + 6σAB + 4σAC ? ?
2
+2σABC + σ2
2 2
B 1 0.0010 18σB + 6σBC + σ2 0.33 .622
2 2
AB 2 0.0056 6σAB + 2σABC + σ2 2.24 .222
2 2
C 2 0.0560 12σC + 6σBC + σ2 18.87 .051
2 2
AC 4 0.0107 4σAC + 2σABC + σ2 4.28 .094
2
BC 2 0.0030 6σBC + σ2 10.00 .001
2
ABC 4 0.0025 2σABC + σ2 8.33 .001
Error 18 0.0003 σ2
• Possible approaches:
– Could assume some variances are negligible, not recommended without
“conclusive” evidence
– Pool (insignificant) means squares with error, also risky, not recommended when df
for error is already big.
Spring , 2008
Page 45
Statistics 514: Experiments with Random Effects
τi2 = 0.
P
• H0 : effect = 0, e.g., H0 : τ1 = · · · = τa = 0 or equivalently H0 :
No exact test exists.
M S ′ = MSr ± . . . ± MSs
M S ′′ = MSu ± . . . ± MSv
′ ′′
such that 1) M S and M S do not share common mean squares; 2)
E(M S ′ ) − E(M S ′′ ) is a multiple of the effect.
M S′ MSr ±...±MSs
– approximate test statistic F : F = M S ′′
= MSu ±...±MSv
≈ Fp,q
(MSr ±...±MSs )2 (MSu ±...±MSv )2
where p = MS2 2 and q = MS2 2
r /fr +...+MSs /fs u /fu +...+MSv /fv
Spring , 2008
Page 46
Statistics 514: Experiments with Random Effects
H0 : τ1 = τ2 = τ3 = 0
M S ′ = MSA
MSA .7866
F = = = 57.0
MSAB + MSAC − MSABC .0107 + .0056 − .0025
.01382
p=2 q= = 4.15
.01072 /4 + .00562 /2 + .00252 /4
• Interpolation needed
Spring , 2008
Page 47
Statistics 514: Experiments with Random Effects
• SAS can be used to compute P-values and quantile values for F and χ2 values with
noninteger degrees of freedom.
data one;
p=1-probf(57,2.0,4.15);
f=finv(.95,2.0,4.15);
c1=cinv(.025,18.57);
c2=cinv(.975,18.57);
proc print data=one;
OBS P F C1 C2
1 .00096 6.7156 8.61485 32.2833
Spring , 2008
Page 48
Statistics 514: Experiments with Random Effects
M S ′′ = MSAB + MSAC
E(M S ′ − M S ′′ ) =?
MSA + MSABC .7866 + .0025
F = = = 48.41
MSAB + MSAC .0107 + .0056
.78912 .01632
p= = 2.01 q= = 6.00
.78662 /2 + .00252 /4 .01072 /4 + .00562 /2
Spring , 2008
Page 49
Statistics 514: Experiments with Random Effects
• Case 1: there exists a mean square M Sx with dfx such that E(M Sx ) = σx2 . Then
σ̂x2 = M Sx , and
dfx M Sx 2
2
∼ χ (dfx )
σx
df M S
Exact 100(1-α)% CI: χ2x x
≤ σx2 ≤ df x M Sx
χ2
α/2,df x 1−α/2,df x
2
M S ′ − M S ′′ dfx σ̂x
σ̂x2 = , and ≈ χ2
(dfx )
k σx2
where
Spring , 2008
Page 50
Statistics 514: Experiments with Random Effects
df x σ̂x2 2 df x σ̂x2
≤ σx ≤ 2
χ2α/2,df x χ1−α/2,df x
Spring , 2008
Page 51
Statistics 514: Experiments with Random Effects
(62.39 − 0.71)2
df = 2 2
= 18.57
62.39 /19 + 0.71 /38
Spring , 2008
Page 52
Statistics 514: Experiments with Random Effects
M SB −M SAB
σ̂β2 = an
= (1.31 − 0.71)/40 = 0.015
(1.31 − 0.71)2
df = = .413
1.312 /2 + 0.712 /38
−8
CI: (.413(.015)/3.079, .413(.015)/2.29 × 10 ) = (.002, 270781)
Spring , 2008
Page 53
Statistics 514: Experiments with Random Effects
Y = Xβ + Zδ + ǫ
• Cov(Y ) = ZGZ ′ + R
• If R = σ 2 I and Z = 0, back to standard linear model
• SAS Proc Mixed allows one to specify G and R
• G through RANDOM, R through REPEATED
• Unrestricted linear mixed model is default
Spring , 2008
Page 54