240 likes | 307 Views
Looking at V 0 , V , etc. for a simple model. Correlation/Covariance Model. E( e ij )=0 Let var(e ij ) = 2 , all i’ s and j ’s. Let cov(e ij , e ij’ ) = r 2 , all j j ’ Let cov( e ij , e i’j’ )=0 , all i i’. What is Correlation and Covariance?.
E N D
Correlation/Covariance Model • E(eij )=0 • Let var(eij) =2, all i’s and j’s. • Let cov(eij, eij’) =r 2, all j j’ • Let cov(eij, ei’j’)=0, all i i’.
What is Correlation and Covariance? • cov(eij, eij’) E{[eij -E(eij )][eij’-E(eij’)} = E{eij eij’ }-E(eij )E(eij’) = E{eij eij’ }
What is the covariance of the Yij’s given our model? • cov(Yij,Yij’)= E{[Yij -E(Yij )][Yij’-E(Yij’)} • cov(Yij, Yij’) = E{[eij -E(eij )][eij’-E(eij’)} =cov(eij,eij’) = r2
The Rest • What is V0? • What is V? • How can we estimate 2 and r?
Homework for Next Time • Let var(eij) =2, all i’s and j’s. • Let cov(eij, eij’) =r22, if abs(j- j’) < 3, 0 otherwise. • Let cov(eij, ei’j’)=0, all i i’. • ni=n=5 • m=4 1) Provide cor(Yij,Yij’) for a) abs(j-j’)<3, i= i’, b) abs(j-j’) 3, i= i’ and c) i i’. 2) Provide V0 and V. 3) What process might result in this sort of correlation (assume that the order of the j’s has some meaning)? Extra How would you estimate 2andr?
The Mixed Model A general approach to repeated measures data.
What’s being “Mixed”? • For our purposes, a mixed model has two types of effects, fixed and random. • A fixed effect means that all levels of the variable are contained in the data and the effect is universal to all in the population. • A random effect means that the levels (effects) of the variable comprise random samples of the levels (effects) in the population. • Consider a treatment. Fixed, Random, Both?
Why Use Mixed Model? • The model implies correlation between measurements on the same subject. • It allows different subjects to have different responses to a treatment, risk variable, etc. • Estimation can return both fixed effects and estimate of subject-level effects. • Permits one to specify a rich set of correlation models and allows for heteroskedascity.
The Simplest Example. • The Model: • E(i)=0, E(eij)=0, E[i eij]=0. • Var(i)= 2. • Var(eij)= 2e . • What are the fixed and random effects in this model?
A more complicated example. • The Model: • E(0i)=0, E(1i)=0, E(eij)=0. • Var(0i)= 20, Var(1i)= 21, Var(eij)= 2 • cov(0i, 1i)= 212, cov(0i, eij)=0, cov(1i, eij)=0. • What are the fixed and random effects in this model?
Strength Data id tx y time 1. 1 1 85 1 2. 1 1 85 2 3. 1 1 86 3 4. 1 1 85 4 5. 1 1 87 5 6. 1 1 86 6 7. 1 1 . 7 8. 2 1 80 1 9. 2 1 79 2 10. 2 1 . 3 11. 2 1 78 4 12. 2 1 78 5 13. 2 1 79 6 14. 2 1 . 7
Using Splus on Strength Data • First, the Model (xij, time of ijth measurement). • E(0i)=0, E(eij)=0. • Var(0i)= 20, Var(eij)= 2 • cov(0i, eij)=0. • What are the fixed and random effects in this model?
Using Splus on Strength Data > lme.strength.1<-lme(fixed=y~time,random=~1 | id,data=strength.wb,na.action=na.omit) > summary(lme.strength.1) Linear mixed-effects model fit by REML Data: strength.wb AIC BIC logLik 1378.659 1394.291 -685.3295 Random effects: Formula: ~ 1 | id (Intercept) Residual StdDev: 3.164483 1.134307 (0) Fixed effects: y ~ time Value Std.Error DF t-value p-value (Intercept) 80.36677 0.4388089 312 183.1475 <.0001 0 time 0.15310 0.0301512 312 5.0779 <.0001 1
Fixed and Random Effects > lme.strength.1$coefficients $fixed: (Intercept) time 80.36677 0.1531045 $random: $random$id: 0i (Intercept) 1 4.66415489 2 -2.06488079 3 -4.04774444 4 3.10664991 5 -1.10181736 6 -4.04774444 7 -1.38238184 8 -5.73113134 9 -2.05089747 10 -2.21406991 11 -0.26012390 12 -3.90746220 13 1.98439197 14 0.58156955 15 -0.09282822
A more complicated example, again. • The Model: • E(0i)=0, E(1i)=0, E(eij)=0. • Var(0i)= 20, Var(1i)= 21, Var(eij)= 2 • cov(0i, 1i)= 212, cov(0i, eij)=0, cov(1i, eij)=0.
Using Splus on Strength Data > lme.strength.2<-lme(fixed=y~time,random=~1+time | id,data=strength.wb,na.action=na.omit) > summary(lme.strength.2) Linear mixed-effects model fit by REML Data: strength.wb AIC BIC logLik 1273.267 1296.715 -630.6335 Random effects: Formula: ~ 1 + time | id Structure: General positive-definite StdDev Corr (Intercept) 2.9708423 (Inter 0 time 0.3807420 -0.078 1 12 Residual 0.8153052 Fixed effects: y ~ time Value Std.Error DF t-value p-value (Intercept) 80.33188 0.4046043 312 198.5443 <.0001 0 time 0.16714 0.0550963 312 3.0336 0.0026 1
Fixed and Random Effects > lme.strength.2$coefficients $fixed: (Intercept) time 80.33188 0.1671382 $random: $random$id: (Intercept) time 0i 1i 1 4.21746046 0.136576669 2 -0.87435798 -0.345212643 3 -2.70851624 -0.350781931 4 3.45028650 -0.086161111 5 0.05054146 -0.298100961 6 -2.59000494 -0.380680970 7 -1.52713706 0.028618762 8 -3.76028487 -0.513295373 9 -3.13546212 0.289483121 10 -1.35098740 -0.247660561 11 -0.07538639 -0.052399525 12 -3.51957957 -0.110504764 13 1.99853583 -0.005142824 14 4.65764917 -1.032558693
Re-do in SAS LIBNAME rep2001 'd:\rep2001\sas\data'; FOOTNOTE"&PROGRAM ON: &SYSDAY &SYSDATE"; ********************************************************; * DATA SET PREPARATION; ********************************************************; DATA TEMP0; SET rep2001.strength; RUN; ********************************************************; * PROC MIXED, Model 1 - random intercept; ********************************************************; procmixeddata=temp0; class id; model y = time / s; random int / sub=id; run; ********************************************************; * PROC MIXED, Model 2 - random intercept and slope; ********************************************************; procmixeddata=temp0; class id; model y = time / s; random int time / sub=id; run;
Results of Random Intercept Model Covariance Parameter Estimates Cov Parm Subject Estimate Intercept ID 10.0139 Residual 1.2867 &PROGRAM ON: Monday 05NOV01 The SAS System 2 The Mixed Procedure Fit Statistics -2 Res Log Likelihood 1370.7 AIC (smaller is better) 1374.7 AICC (smaller is better) 1374.7 BIC (smaller is better) 1378.7
Results of Random Intercept Model Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 80.3668 0.4388 56 183.15 <.0001 TIME 0.1531 0.03015 312 5.08 <.0001 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F TIME 1 312 25.78 <.0001
Results of Random Int. & Slope Model Covariance Parameter Estimates Cov Parm Subject Estimate Intercept ID 8.7146 TIME ID 0.1430 Residual 0.6663 &PROGRAM ON: Monday 05NOV01 The SAS System 4 The Mixed Procedure Fit Statistics -2 Res Log Likelihood 1261.5 AIC (smaller is better) 1267.5 AICC (smaller is better) 1267.6 BIC (smaller is better) 1273.7
Results of Random Int. & Slope Model Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 80.3315 0.4022 56 199.73 <.0001 TIME 0.1673 0.05479 56 3.05 0.0035 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F TIME 1 56 9.32 0.0035