0% found this document useful (0 votes)
68 views23 pages

Weekend Workshop I: Proc Mixed

This document provides an overview of mixed models and the PROC MIXED procedure in SAS. Key points include: 1) Mixed models can contain both fixed and random effects, allowing inference to extend beyond the levels included in the experiment. 2) PROC MIXED is used to fit mixed models and estimate variance components. Examples shown include modeling family as a random effect to account for twin relationships. 3) Random coefficient models allow slopes and intercepts to vary randomly across groups. This provides a more flexible way to model hierarchical data.

Uploaded by

ptscrib
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views23 pages

Weekend Workshop I: Proc Mixed

This document provides an overview of mixed models and the PROC MIXED procedure in SAS. Key points include: 1) Mixed models can contain both fixed and random effects, allowing inference to extend beyond the levels included in the experiment. 2) PROC MIXED is used to fit mixed models and estimate variance components. Examples shown include modeling family as a random effect to account for twin relationships. 3) Random coefficient models allow slopes and intercepts to vary randomly across groups. This provides a more flexible way to model hierarchical data.

Uploaded by

ptscrib
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Weekend Workshop I

PROC MIXED
Random or Fixed ?
RANDOM FIXED

Levels: Selected at random
from infinite population
Finite number of
possibilities
Another Experiment Different selections
from same population
Same Levels
Goal Estimate variance
components
Compare means
Inference All levels in population Only levels used in the
experiment.
Twins: One gets SAS training method 1, the other gets method 2
Response Y = programming times
PROC MIXED Model
38.25
33.00
28.75
30.00
46.50
55.25
(
(
(
(
(
(
(
(

1
2
1 0 1
1 1 0
1 0 1
1 1 0
1 1 0
1 0 1
M
M

(
(
(
(
(
(
=
(
(
(
(

(
(

1
2
3
1 0 0
1 0 0
0 1 0
0 1 0
0 0 1
0 0 1
F
F
F
(
(
(
(
(
(
+
(
(
(
(

(
(

1
2
3
4
5
6
e
e
e
e
e
e
(
(
(
(
+
(
(
(
(
(

Y = X | + Z + e



Variance of is G = ,Variance of e is R =



2
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
o
| |
|
|
|
|
|
|
|
|
\ .
2
1 0 0
0 1 0
0 0 1
F
o
| |
|
|
|
\ .
Model ; Random ; Repeated ;
PROC MIXED DATA=TWINS;
CLASS FAMILY METHOD;
MODEL TIME = METHOD; * fixed;
RANDOM FAMILY; *<- family ~ N(0, o
2
F
) ;

Covariance Parameter Estimates

Cov Parm Estimate
family 21.2184
Residual 40.8338

Type 3 Tests of Fixed Effects

Num Den
Effect DF DF F Value Pr > F
method 1 19 9.60 0.0059
Intraclass correlation (related to heritability)
o
2
F
/(o
2
F
+ o
2
)
Estimated as 21.2/62 or about 1/3.
Q: Why not usual (Pearson) correlation?
Demo
Get_Twins.sas
Twins_MIXED.sas
BLUP
Y
ij
= + F
i
+ e
ij

D
i
= Family mean = F
i
+ e
i
.
best estimate of F
i
= ?

Variance of (F
i
b D
i
) is (1-b)
2
o
2
F
+ b
2
o
2
/2
Use b = o
2
F
/(o
2
F
+ o
2
/2)
Estimate: b = 21.2/(21.2 + 40.8/2) = 0.510

Overall mean + 0.510(Family i mean Overall mean)
PROC MIXED DATA=TWINS;
CLASS FAMILY METHOD;
MODEL TIME = METHOD;
RANDOM FAMILY;
ESTIMATE "1 " intercept 1 | family 1;
ESTIMATE "2 " intercept 1 | family 0 1;
PROC GLM DATA=TWINS;
CLASS FAMILY METHOD;
MODEL TIME = FAMILY METHOD;
LSMEANS FAMILY;
MEANS and BLUPs
(MIXED) (GLM)
Demo
Twins_BLUP.sas
Twins_TEST.sas
REML Estimation
(1) Regress out fixed effects
(2) Maximze likelihood of residuals (mean known: 0)
(3) Variance estimates less biased (unbiased in
some simple cases)
ML Estimation
Search over all (fixed and random) parameters
Estimates of variances biased low!
Unbalanced Data
SUBJ
Ear plug
A B C D E F G
I 25 (L) 19 (L) 29 (R) 16 (R) 25 (L)
II 8 (R) 7 (L) 23 (L) 16 (R) 24 (R)
III 22 (R) 7 (R) 14 (L) 12 (L)
I vs. III free of subject effects for red data.
Misses info in other data.
proc glm; class plug worker;
model loss = worker plug; Random Worker;
Estimate "I vs III - GLM" Plug -1 0 1; run;
proc mixed; class plug worker;
model Loss=Plug; Random Worker;
Estimate "I vs III - Mixed" Plug -1 0 1; run;
GLM
Source DF Type III SS F Value Pr > F
worker 6 451.9062500 12.21 0.0074
plug 2 62.6562500 5.08 0.0625
Standard
Parameter Estimate Error t Value Pr > |t|
I vs III - GLM -4.8125 1.9635 -2.45 0.0579
Type 3 Tests of Fixed Effects
Num Den
Effect DF DF F Value Pr > F
plug 2 5 5.79 0.0499
Estimates
Standard
Label Estimate Error DF t Value Pr > |t|
I vs III - Mixed -5.2448 1.9347 5 -2.71 0.0422
Covariance Parameter
Estimates

Cov Parm Estimate

worker 37.578
Residual 6.1674
Demo
Earplugs.sas
Soil Variety
1 1
1 2
2 1
2 2
3 1
3 2
4 Aquariums,
2 aerated
2 not
six dishes / aquarium
one plant / dish
soil x variety combinations
ANOVA

Source
Air
Error A
V
S
VA
VS
AS
AVS
Error B
SPLIT PLOT
PROC MIXED;
CLASS VAR AQUARIUM SOIL AIR;
MODEL YIELD = AIR SOIL VAR SOIL*VAR
AIR*SOIL AIR*VAR AIR*SOIL*VAR /
DDFM=SATTERTHWAITE;
RANDOM AQUARIUM(AIR);

ESTIMATE "SOIL 1: AIR EFFECT"
AIR -1 1 AIR*SOIL -1 1 0 0 0 0;
RUN;
Compare Air to No Air within soil 1
Variance of this contrast is hard to figure out:
(1/3)[MS(A)+2 MS(B)]

Need Satterthwaite df
AUTOMATIC IN MIXED!!!
Covariance Parameter Estimates

Cov Parm Estimate
AQUARIUM(AIR) 2.1833
Residual 7.7333

Type 3 Tests of Fixed Effects
Num Den
Effect DF DF F Value Pr > F
AIR 1 2 16.20 0.0565
SOIL 2 10 7.87 0.0088
VAR 1 10 24.91 0.0005
VAR*SOIL 2 10 0.04 0.9631
SOIL*AIR 2 10 1.08 0.3752
VAR*AIR 1 10 4.22 0.0669
VAR*SOIL*AIR 2 10 0.23 0.7973

Standard
Label Estimate Error DF t Value Pr > |t|
SOIL 1: AIR EFFECT 5.2500 2.4597 5.47 2.13 0.0812
Demo
Aquarium.sas
Random Coefficient Models
the basic idea
mistakes
Program writing time
Average programmer
Dave
Line for individual j: (a
0
+ a
j
) + ( b
0
+ b
j
)t




|
|
.
|

\
|
|
|
.
|

\
|
|
|
.
|

\
|
|
|
.
|

\
|
2
2
,
0
0
~
B AB
AB A
j
j
N
b
a
o o
o o
a
0
+ b
0
t
Hierarchial Models
(1) Same as split plot - almost
(2) Whole and split level continuous predictor
variables (typically)

(1) Aquarium level (level i): pH
i
(2) Dish level: Soil nitrogen test (N
ij
)
Y
ij
= a
i
+ b
i
N
ij
+e
ij

(3) Idea: a
i
= o
0
+ o
1
pH
i
+ a
i
*
b
i
= |
0
+ |
1
pH
i
+ b
i
*



Y
ij
= a
i
+ b
i
N
ij
+e
ij
Y
ij
= o
0
+ o
1
pH
i
+ a
i
*
+ b
i
N
ij
+e
ij
Y
ij
= o
0
+ o
1
pH
i
+ a
i
*
+ (|
0
+ |
1
pH
i
+ b
i
*
) N
ij
+e
ij

Y
ij
= [o
0
+ o
1
pH
i
+ |
0
N
ij
+ |
1
pH
i
N
ij
] + [a
i
*
+b
i
*
N
ij
+e
ij
]
fixed random
PROC MIXED DATA = UNDERWATER;
MODEL GROWTH = N P N*P;
RANDOM INTERCEPT N / SUBJECT = TANK TYPE=UN;
p
Num Den
Effect DF DF F Value Pr > F
N 1 2 3.50 0.2018
pH 1 2.05 6.76 0.1186
N*pH 1 2 1.31 0.3702
aquarium
N pH growth

1 2.21 5.5 27.05
1 1.25 5.5 25.92
1 4.36 5.5 30.09
1 7.14 5.5 33.66
1 8.61 5.5 36.13
1 6.53 5.5 33.00
2 6.58 4.7 35.72
2 3.12 4.7 31.17
2 5.28 4.7 34.35
2 1.09 4.7 28.34
2 4.83 4.7 33.56
2 9.61 4.7 40.25
3 7.99 4.2 47.04
3 7.79 4.2 46.56
3 8.32 4.2 48.27
3 2.53 4.2 34.20
3 6.85 4.2 44.59
3 4.73 4.2 39.29
4 0.95 5.1 24.94
4 2.00 5.1 27.33
4 9.99 5.1 43.84
4 0.23 5.1 23.54
4 0.13 5.1 23.56
4 1.17 5.1 25.68
Num Den
Effect DF DF F Value Pr > F
N 1 3 50.19 0.0058
pH 1 2.03 14.68 0.0603
Cov Parm Estimate
UN(1,1) 1.8976
UN(2,1) -0.5563
UN(2,2) 0.2596
Residual 0.0286
pH
N
Demo
Hierarchial.sas
Next: Repeated Measures

Notes in pdf from NCSU experimental design class
(ST 711)
Demo
SURGERY.sas

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy