1 / 23

Weekend Workshop I

Weekend Workshop I. PROC MIXED. Random or Fixed ?. Twins: One gets SAS training method 1 , the other gets method 2 Response Y = programming times. PROC MIXED Model. Model ; Random ; Repeated ;.

nascha
Download Presentation

Weekend Workshop I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Weekend Workshop I PROC MIXED

  2. Random or Fixed ?

  3. Twins: One gets SAS training method 1, the other gets method 2 Response Y = programming times

  4. PROC MIXED Model Model ; Random ; Repeated ; Y = X b + Zg + e Variance of g is G = ,Variance of e is R =

  5. PROCMIXED DATA=TWINS; CLASS FAMILY METHOD; MODEL TIME = METHOD; * fixed; RANDOM FAMILY; *<- family ~ N(0, s2F) ; 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) s2F /(s2F + s2) Estimated as 21.2/62 or about 1/3. Q: Why not usual (Pearson) correlation?

  6. Demo Get_Twins.sas Twins_MIXED.sas

  7. BLUP Yij = m + Fi + eij Di = Family mean – m = Fi + ei. best estimate of Fi = ? Variance of (Fi – b Di) is (1-b)2s2F + b2s2/2 Use b = s2F /(s2F + s2/2) Estimate: b = 21.2/(21.2 + 40.8/2) = 0.510 Overall mean + 0.510(Family i mean – Overall mean) PROCMIXED DATA=TWINS; CLASS FAMILY METHOD; MODEL TIME = METHOD; RANDOM FAMILY; ESTIMATE "1 " intercept 1 | family 1; ESTIMATE "2 " intercept 1 | family 01; PROCGLM DATA=TWINS; CLASS FAMILY METHOD; MODEL TIME = FAMILY METHOD; LSMEANS FAMILY;

  8. MEANS andBLUPs (GLM) (MIXED)

  9. Demo Twins_BLUP.sas Twins_TEST.sas

  10. ML Estimation Search over all (fixed and random) parameters Estimates of variances biased low!  • REML Estimation • Regress out fixed effects • Maximze likelihood of residuals (mean known: 0) • Variance estimates less biased (unbiased in some simple cases) 

  11. Unbalanced Data I vs. III free of subject effects for red data. Misses info in other data.

  12. procglm; class plug worker; model loss = worker plug; Random Worker; Estimate "I vs III - GLM" Plug -101; run; procmixed; class plug worker; model Loss=Plug; Random Worker; Estimate "I vs III - Mixed" Plug -101; run; Covariance Parameter Estimates Cov Parm Estimate worker 37.578 Residual 6.1674 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

  13. Demo Earplugs.sas

  14. SPLIT PLOT 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 Soil Variety 1 1 1 2 2 1 2 2 3 1 3 2

  15. 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!!! PROCMIXED; 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 -11 AIR*SOIL -110000; RUN;

  16. 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

  17. Demo Aquarium.sas

  18. Random Coefficient Models the basic idea mistakes Dave Averageprogrammer a0 + b0 t Program writing time Line for individual j: (a0 + aj) + ( b0 + bj )t

  19. Hierarchial Models • Same as split plot - almost • Whole and split level continuous predictor variables (typically) • Aquarium level (level i): pHi • Dish level: Soil nitrogen test (Nij) • Yij = ai + biNij+eij • (3) Idea: ai = a0 + a1pHi + ai* • bi = b0 + b1pHi + bi* Yij = [a0 + a1pHi + b0Nij+ b1pHiNij] + [ai* +bi* Nij+eij] fixed random PROC MIXED DATA = UNDERWATER; MODEL GROWTH = N P N*P; RANDOM INTERCEPT N / SUBJECT = TANK TYPE=UN; Yij = ai + biNij+eij Yij = a0 + a1pHi + ai* + biNij+eij Yij = a0 + a1pHi + ai* + (b0 + b1pHi + bi* ) Nij+eij

  20. p 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 2 3.50 0.2018 pH 1 2.05 6.76 0.1186 N*pH 1 2 1.31 0.3702 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 N pH

  21. Demo Hierarchial.sas

  22. Next: Repeated Measures Notes in pdf from NCSU experimental design class (ST 711)

  23. Demo SURGERY.sas

More Related