Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite...
-
Upload
dayton-gardiner -
Category
Documents
-
view
218 -
download
4
Transcript of Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite...
![Page 1: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/1.jpg)
Weekend Workshop IWeekend Workshop I
PROC MIXED
![Page 2: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/2.jpg)
Random or Fixed ?
RANDOMRANDOM FIXEDFIXED
Levels:Levels: Selected at random Selected at random from infinite populationfrom infinite population
Finite number of Finite number of possibilitiespossibilities
Another ExperimentAnother Experiment Different selections Different selections from same populationfrom same population
Same LevelsSame Levels
GoalGoal Estimate variance Estimate variance componentscomponents
Compare meansCompare means
InferenceInference All levels in populationAll levels in population Only levels used in the Only levels used in the experiment.experiment.
![Page 3: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/3.jpg)
Twins: One gets SAS training method 1, the other gets method 2
Response Y = programming times
![Page 4: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/4.jpg)
PROC MIXED ModelPROC 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
2
1 0 0
0 1 0
0 0 1F
Model ; Random ; Repeated ;
![Page 5: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/5.jpg)
PROC MIXED DATA=TWINS; CLASS FAMILY METHOD; MODEL TIME = METHOD; * fixed; RANDOM FAMILY; *<- family ~ N(0, 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) 2
F /(2F + 2)
Estimated as 21.2/62 or about 1/3. Q: Why not usual (Pearson) correlation?
![Page 6: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/6.jpg)
DemoDemoGet_Twins.sasGet_Twins.sas
Twins_MIXED.sasTwins_MIXED.sas
![Page 7: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/7.jpg)
BLUPBLUP
Yij = + Fi + eij
Di = Family mean – Fi + ei.best estimate of Fi = ?
Variance of (Fi – b Di) is (1-b)22F + b2 2/2
Use b = 2F /(2
F + 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;
![Page 8: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/8.jpg)
MEANS andMEANS and BLUPsBLUPs
(MIXED)(GLM)
![Page 9: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/9.jpg)
DemoDemo Twins_BLUP.sasTwins_BLUP.sasTwins_TEST.sasTwins_TEST.sas
![Page 10: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/10.jpg)
REML EstimationREML Estimation(1)(1)Regress out fixed effectsRegress out fixed effects(2)(2)Maximze likelihood of residuals (mean known: 0)Maximze likelihood of residuals (mean known: 0)(3)(3)Variance estimates less biased (unbiased in some Variance estimates less biased (unbiased in some simple cases) simple cases)
ML EstimationML Estimation Search over all (fixed Search over all (fixed andand random) parameters random) parameters
Estimates of variances biased low! Estimates of variances biased low!
![Page 11: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/11.jpg)
Unbalanced DataUnbalanced 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.
![Page 12: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/12.jpg)
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;
GLMSource DF Type III SS F Value Pr > F worker 6 451.9062500 12.21 0.0074 plug 2 62.6562500 5.08 0.0625 StandardParameter 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 StandardLabel 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
![Page 13: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/13.jpg)
DemoDemo Earplugs.sasEarplugs.sas
![Page 14: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/14.jpg)
Soil Variety 1 1 1 2 2 1 2 2 3 1 3 2
4 Aquariums, 2 aerated2 notsix dishes / aquarium
one plant / dish soil x variety combinations
ANOVA
SourceAir Air Error AError A V S VA VS AS AVSError B
SPLIT PLOT
![Page 15: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/15.jpg)
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 1Variance of this contrast is hard to figure out:
(1/3)[MS(A)+2 MS(B)]
Need Satterthwaite df AUTOMATIC IN MIXED!!!
![Page 16: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/16.jpg)
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
![Page 17: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/17.jpg)
DemoDemo Aquarium.sasAquarium.sas
![Page 18: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/18.jpg)
Random Coefficient ModelsRandom Coefficient Models the basic ideathe basic idea
mistakesmistakes
Program writing time
Average programmer
Dave
Line for individual j: (a0 + aj) + ( b0 + bj )t
2
2
,0
0~
BAB
ABA
j
j Nb
a
a0 + b0 t
![Page 19: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/19.jpg)
Hierarchial ModelsHierarchial Models(1)(1)Same as split plot - Same as split plot - almost almost (2)(2)Whole and split level Whole and split level continuouscontinuous predictor predictor variables (typically)variables (typically)
(1)(1)Aquarium level (level i): pHAquarium level (level i): pHii
(2)(2)Dish level: Soil nitrogen test (NDish level: Soil nitrogen test (Nijij))
YYijij = a = aii + b + bii N Nijij+e+eijij
(3) Idea: a(3) Idea: aii = = 00 + + 11 pH pHii + a + aii**
bbii = = 00 + + 11 pH pHii + b + bii* *
YYijij = a = aii + b + bii N Nijij+e+eijijYYijij = = 00 + + 11 pH pHii + a + aii* * + b+ bii N Nijij+e+eijijYYijij = = 00 + + 11 pH pHii + a + aii
* * + + ((00 + + 11 pH pHii + b + bii* * ) ) NNijij+e+eijij
YYijij = = [[00 + + 11 pH pHii + + 00 N Nij ij + + 11 pH pHii N Nijij] ] + + [a[aii** +b +bii
* * NNijij+e+eijij]]
fixed fixed randomrandom
PROC MIXED DATA = UNDERWATER; MODEL GROWTH = N P N*P; RANDOM INTERCEPT N / SUBJECT = TANK TYPE=UN;
![Page 20: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/20.jpg)
p
Num DenEffect DF DF F Value Pr > FN 1 2 3.50 0.2018pH 1 2.05 6.76 0.1186N*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 DenEffect DF DF F Value Pr > FN 1 3 50.19 0.0058pH 1 2.03 14.68 0.0603
Cov Parm EstimateUN(1,1) 1.8976UN(2,1) -0.5563UN(2,2) 0.2596Residual 0.0286
pHN
![Page 21: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/21.jpg)
DemoDemo Hierarchial.sasHierarchial.sas
![Page 22: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/22.jpg)
Next: Repeated Measures
Notes in pdf from NCSU experimental design class(ST 711)
![Page 23: Weekend Workshop I PROC MIXED. Random or Fixed ?RANDOMFIXEDLevels: Selected at random from infinite population Finite number of possibilities Another.](https://reader038.fdocuments.in/reader038/viewer/2022110205/56649cb65503460f9497b6a1/html5/thumbnails/23.jpg)
DemoDemo SURGERY.sasSURGERY.sas