Overview of this module Course 02429 Analysis of correlated data: Mixed Linear Models Main example: Lactase in piglets 1 Module 5: Hierarchical random effects The hierarchial structure One layer model 2 Per Bruun Brockhoff Type I and Type III tests - again 3 Two layer model 4 DTU Compute Building 324 - room 220 Three or more layers Technical University of Denmark 5 2800 Lyngby – Denmark Comparing different variance structures 6 e-mail: perbb@dtu.dk Alternative confidence limits - balanced situations 7 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 1 / 24 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 2 / 24 Main example: Lactase in piglets Main example: Lactase in piglets 1 Aim of this module Obs litter pig reg status loglact Obs litter pig reg status loglact 1 1 1 1 1 1.89537 31 3 11 1 2 1.58104 2 1 1 2 1 1.97046 32 3 11 2 2 1.52606 3 1 1 3 1 1.78255 33 3 11 3 2 1.65058 4 1 2 1 1 2.24496 34 4 12 1 1 1.97162 5 1 2 2 1 1.43413 35 4 12 2 1 2.11342 6 1 2 3 1 2.16905 36 4 12 3 1 2.51278 7 1 3 1 2 1.74222 37 4 13 1 1 2.06739 8 1 3 2 2 1.84277 38 4 13 2 1 2.25631 9 1 3 3 2 0.17479 39 4 13 3 1 1.79251 Present example where hierarchial error structure is natural 10 1 4 1 2 2.12704 40 5 14 1 1 1.93274 11 1 4 2 2 1.90954 41 5 14 2 1 1.82394 12 1 4 3 2 1.49492 42 5 14 3 1 1.23629 Introduce one, two, three, . . . layer models 13 2 5 1 2 1.62897 43 5 15 1 2 2.07386 14 2 5 2 2 2.26642 44 5 15 2 2 1.96713 15 2 5 3 2 1.96763 45 5 15 3 2 0.47971 16 2 6 1 2 2.01948 46 5 16 1 2 2.01307 Investigate the covariance structure 17 2 6 2 2 2.56443 47 5 16 2 2 1.85483 18 2 6 3 2 1.16387 48 5 16 3 2 2.18274 19 2 7 1 2 2.20681 49 5 17 1 2 2.86629 See how to specify such structures in R 20 2 7 2 2 2.55652 50 5 17 2 2 2.71414 21 2 7 3 2 1.69358 51 5 17 3 2 1.60533 22 2 8 1 2 1.09186 52 5 18 1 2 1.97865 23 2 8 2 2 1.93091 53 5 18 2 2 1.93342 24 2 8 3 2 . 54 5 18 3 2 0.74943 25 3 9 1 1 2.36462 55 5 19 1 2 2.89886 26 3 9 2 1 2.72261 56 5 19 2 2 2.88606 27 3 9 3 1 2.80336 57 5 19 3 2 2.20697 28 3 10 1 1 2.42834 58 5 20 1 2 1.87733 29 3 10 2 1 2.64971 59 5 20 2 2 1.70260 30 3 10 3 1 2.54788 60 5 20 3 2 1.11077 1 Data kindly supplied by: Charlotte Reinhard Bjørnvad, Division of Animal Nutrition (RVAU) Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 3 / 24 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 5 / 24
Main example: Lactase in piglets The hierarchial structure One layer model The hierarchial structure of the lactase data set One layer model Litter=1 Litter=2 The simplest hierarchial model: Pig=1 Pig=2 Pig=3 Pig=4 Pig=5 Pig=6 Pig=7 Pig=8 ε i ∼ i.i.d. N (0 , σ 2 ) y i = µ + ε i , 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 . The mean value parameter(s) are estimated by: The first layer (counting from the bottom) is the individual ˆ β = ( X ′ X ) − 1 X ′ y measurements i = 1 . . . N . The second layer is the pigs Pigs could be different, and the model should allow for this The single variance parameter is estimated by: If pigs are different, then two measurements on the same pig would be N more similar than two from different pigs 1 σ 2 = � µ i ) 2 ˆ ( y i − ˆ The third layer is litters N − p i =1 If litters are different two measurements from the same litter, but different pigs should be correlated, but maybe not as correlated as two µ i = X ˆ Here is p the number of mean value parameters, and ˆ β from the same pig (Imagine we had information about farm, area, . . . ) Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 6 / 24 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 8 / 24 One layer model Type I and Type III tests - again Lactase data with one layer model Consider again the lactase data set, but ignore information about pig and Type I (in anova ): litter Succesive tests Each term is corrected for the terms PREVIOUSLY listed in the model A relevant one layer model could be: Sums of squares sum to TOTAL sums of squares y i = µ + α ( status i ) + β ( reg i ) + γ ( status i , reg i ) + ε i , Depends on the order they are specified in the model ε i ∼ i.i.d. N (0 , σ 2 ) Type III (in drop1 and anova of lmerTest ): 3 reg 2 To specify this model in R, we write: Parallel tests Each term is corrected for ALL other the terms in the model model1 <- lm(loglact ~ reg + status + reg:status, data = lactase) Sums of squares do NOT generally sum to TOTAL sums of squares 59 6 1 anova(model1) [I] 53 status × reg 2 0 1 Part of the R output is: Does NOT depend on the order they are specified in the model Analysis of Variance Table If balanced data: the SAME! Response: loglact 2 Df Sum Sq Mean Sq F value Pr(>F) status 1 drop1 is really ”Type II” = Type III with the condition: reg 2 2.5843 1.29217 5.2595 0.008248 ** Do NOT test main effects which are part of (fixed) interactions! status 1 1.1288 1.12882 4.5946 0.036680 * reg:status 2 1.4074 0.70368 2.8642 0.065894 . Residuals 53 13.0212 0.24568 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 9 / 24 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 11 / 24
Two layer model Two layer model Two layer model Lactase data with two layer model The simplest real hierarchial model: Now we can include the information about pig: y i = µ + a ( sub i ) + ε i y i = µ + α ( status i ) + β ( reg i ) + γ ( status i , reg i ) + d ( pig i ) + ε i , where a ( sub i ) ∼ N (0 , σ 2 a ) , and ε i ∼ N (0 , σ 2 ) , and all (both a ’s and where d ( pig i ) ∼ N (0 , σ 2 d ) , ε i ∼ N (0 , σ 2 ) , and all independent. The R code for this model is: ε ’s) are independent model2 <-model2 <- lmer(loglact ~ reg*status + (1|pig), The covariance structure is: data = lactase) � 0 anova(model2) , if sub i 1 � = sub i 2 and i 1 � = i 2 summary(model2) σ 2 Part of the R output is: cov ( y i 1 , y i 2 ) = , if sub i 1 = sub i 2 and i 1 � = i 2 a reg σ 2 a + σ 2 Analysis of Variance Table of type 3 with Satterthwaite , if i 1 = i 2 approximation for degrees of freedom Sum Sq Mean Sq NumDF DenDF F.value Pr(>F) status × reg Or the same expressed via the covariance matrix: reg 2.77714 1.38857 2 34.921 6.0872 0.005395 ** status 0.34398 0.34398 1 17.683 2.6514 0.121144 status σ 2 a + σ 2 σ 2 σ 2 0 0 0 reg:status 1.51820 0.75910 2 34.921 5.6265 0.007618 ** a a σ 2 σ 2 a + σ 2 σ 2 0 0 0 [I] 0 a a σ 2 σ 2 σ 2 a + σ 2 0 0 0 V = a a σ 2 a + σ 2 σ 2 σ 2 0 0 0 a a [pig] σ 2 σ 2 a + σ 2 σ 2 0 0 0 a a σ 2 σ 2 σ 2 a + σ 2 0 0 0 a a Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 13 / 24 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 14 / 24 Two layer model Three or more layers Lactase data with two layer model Three or more layers The Basic three layer model is denoted: y i = µ + a ( block i ) + b ( sub i ) + ε i More of the of the R (from summary ) output is: Linear mixed model fit by REML [ ' merModLmerTest ' ] Here a ( block i ) ∼ N (0 , σ 2 a ) , b ( sub i ) ∼ N (0 , σ 2 b ) , and ε i ∼ N (0 , σ 2 ) Formula: loglact ~ reg * status + (1 | pig) Data: lactase all independent. REML criterion at convergence: 79.9 The interpretation of the variance parameters: Random effects: Groups Name Variance Std.Dev. σ 2 is the variance between observations from the same pig (Intercept) 0.1119 0.3345 Residual 0.1349 0.3673 subject Fixed effects:Estimate Std. Error σ 2 df t value Pr(>|t|) b is the variance between subjects within the same block (Intercept) 2.129291 0.187780 37.620000 11.339 1.07e-13 *** σ 2 a is the variance between blocks reg2 0.009363 0.196334 34.810000 0.048 0.9622 reg3 -0.008660 0.196334 34.810000 -0.044 0.9651 The covariance structure: status2 -0.121178 0.232912 37.620000 -0.520 0.6059 reg2:status2 0.109818 0.243523 34.810000 0.451 0.6548 reg3:status2 -0.655019 0.245841 34.980000 -2.664 0.0116 * 0 , if block i 1 � = block i 2 σ 2 if block i 1 = block i 2 and sub i 1 � = sub i 2 , a cov ( y i 1 , y i 2 ) = σ 2 a + σ 2 , if sub i 1 = sub i 2 and i 1 � = i 2 b σ 2 a + σ 2 b + σ 2 , if i 1 = i 2 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 15 / 24 Per Bruun Brockhoff (perbb@dtu.dk) Mixed Linear Models, Module 5 Fall 2014 17 / 24
Recommend
More recommend