
Linear Mixed-Effects Regression Nathaniel E. Helwig Assistant Professor of Psychology and Statistics University of Minnesota (Twin Cities) Updated 04-Jan-2017 Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 1 Copyright Copyright © 2017 by Nathaniel E. Helwig Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 2 Outline of Notes 1) Correlated Data: 3) Linear Mixed-Effects Model: Overview of problem Random Intercept Model Motivating Example Random Intercepts & Slopes Modeling correlated data General Framework Covariance Structures Estimation & Inference 2) One-Way RM-ANOVA: Example: TIMSS Data Model Form & Assumptions Estimation & Inference Example: Grocery Prices Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 3 Correlated Data Correlated Data Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 4 Correlated Data Overview of Problem What are Correlated Data? So far we have assumed that observations are independent. Regression: (yi ; xi ) are independent for all n ANOVA: yi are independent within and between groups In a Repeated Measures (RM) design, observations are observed from the same subject at multiple occasions. Regression: multiple yi from same subject ANOVA: same subject in multiple treatment cells RM data are one type of correlated data, but other types exist. Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 5 Correlated Data Overview of Problem Why are Correlated Data an Issue? Thus far, all of our inferential procedures have required independence. Regression: ^ 2 0 −1 2 b ∼ N(b; σ (X X) ) requires the assumption (yjX) ∼ N(Xb; σ In) where b^ = (X0X)−1X0y ANOVA: ^ 2 Pa 2 iid 2 L ∼ N(L; σ j=1 cj =nj ) requires the assumption yij ∼ N(µj ; σ ) ^ Pa where L = j=1 cj µ^j Correlated data are (by definition) correlated. Violates the independence assumption Need to account for correlation for valid inference Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 6 Correlated Data Motivating Example TIMSS Data from 1997 Trends in International Mathematics and Science Study (TIMSS)1 Ongoing study assessing STEM education around the world We will analyze data from 3rd and 4th grade students We have nT = 7; 097 students nested within n = 146 schools > timss = read.table(paste(datapath,"timss1997.txt",sep=""),header=TRUE, + colClasses=c(rep("factor",4),rep("numeric",3))) > head(timss) idschool idstudent grade gender science math hoursTV 1 10 100101 3 girl 146.7 137.0 3 2 10 100103 3 girl 148.8 145.3 2 3 10 100107 3 girl 150.0 152.3 4 4 10 100108 3 girl 146.9 144.3 3 5 10 100109 3 boy 144.3 140.3 3 6 10 100110 3 boy 156.5 159.2 2 1https://nces.ed.gov/TIMSS/ Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 7 Correlated Data Motivating Example Issues with Modeling TIMSS Data Data are collected from students nested within schools. Nesting typically introduces correlation into data at level-1 Students are level-1 and schools are level-2 Dependence/correlation between students from same school We need to account for this dependence when we model the data. Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 8 Correlated Data Modeling Correlated Data Fixed versus Random Effects Thus far, we have assumed that parameters are unknown constants. Regression: b is some unknown (constant) coefficient vector ANOVA: µj are some unknown (constant) means These are referred to as fixed effects Unlike fixed effects, random effects are NOT unknown constants Random effects are random variables in the population Typically assume that random effects are zero-mean Gaussian Typically want to estimate the variance parameter(s) Models with fixed and random effects are called mixed-effects models. Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 9 Correlated Data Modeling Correlated Data Modeling Correlated Data with Random Effects To model correlated data, we include random effects in the model. Random effects relate to assumed correlation structure for data Including different combinations of random effects can account for different correlation structures present in the data Goal is to estimate fixed effects parameters (e.g., b^) and random effects variance parameters. Variance parameters are of interest, because they relate to model covariance structure Could also estimate the random effect realizations (BLUPs) Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 10 One-Way Repeated Measures ANOVA One-Way Repeated Measures ANOVA Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 11 One-Way Repeated Measures ANOVA Model Form and Assumptions Model Form The One-Way Repeated Measures ANOVA model has the form yij = ρi + µj + eij for i 2 f1;:::; ng and j 2 f1;:::; ag where yij 2 R is the response for i-th subject in j-th factor level µj 2 R is the fixed effect for the j-th factor level iid 2 ρi ∼ N(0; σρ) is the random effect for the i-th subject iid 2 eij ∼ N(0; σe) is a Gaussian error term n is number of subjects and a is number of factor levels Note: each subject is observed a times (once in each factor level). Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 12 One-Way Repeated Measures ANOVA Model Form and Assumptions Model Assumptions The fundamental assumptions of the one-way RM ANOVA model are: 1 xij and yi are observed random variables (known constants) iid 2 2 ρi ∼ N(0; σρ) is an unobserved random variable iid 3 2 eij ∼ N(0; σe) is an unobserved random variable 4 ρi and eij are independent of one another 5 µ1; : : : ; µa are unknown constants 6 2 2 2 2 yij ∼ N(µj ; σY ) where σY = σρ + σe is the total variance of Y Pa Using effect coding, µj = µ + αj with j=1 αj = 0 Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 13 One-Way Repeated Measures ANOVA Model Form and Assumptions Assumed Covariance Structure (same subject) For two observations from the same subject yij and yik we have Cov(yij ; yik ) = E[(yij − µj )(yik − µk )] = E[(ρi + eij )(ρi + eik )] 2 = E[ρi + ρi (eij + eik ) + eij eik ] 2 2 = E[ρi ] = σρ given that E(ρi eij ) = E(ρi eik ) = E(eij eik ) = 0 by model assumptions. Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 14 One-Way Repeated Measures ANOVA Model Form and Assumptions Assumed Covariance Structure (different subjects) For two observations from different subjects yhj and yik we have Cov(yhj ; yik ) = E[(yhj − µj )(yik − µk )] = E[(ρh + ehj )(ρi + eik )] = E[ρhρi + ρheik + ρi ehj + ehj eik ] = 0 given that E(ρhρi ) = E(ρheik ) = E(ρi ehj ) = E(ehj eik ) = 0 due to the model assumptions. Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 15 One-Way Repeated Measures ANOVA Model Form and Assumptions Assumed Covariance Structure (general form) The covariance between any two observations is σ2 = !σ2 if h = i and j 6= k Cov(y ; y ) = ρ Y hj ik 0 if h 6= i 2 2 where ! = σρ/σY is the correlation between any two repeated measurements from the same subject. ! is referred to as the intra-class correlation coefficient (ICC). Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 16 One-Way Repeated Measures ANOVA Model Form and Assumptions Compound Symmetry Assumptions imply covariance pattern known as compound symmetry All repeated measurements have same variance All pairs of repeated measurements have same covariance With a = 4 repeated measurements the covariance matrix is 0 2 2 2 2 1 0 1 σY !σY !σY !σY 1 !!! 2 2 2 2 B !σY σY !σY !σY C 2 B ! 1 !! C Cov(yi ) = B 2 2 2 2 C = σY B C @ !σY !σY σY !σY A @ !! 1 ! A 2 2 2 2 !σY !σY !σY σY !!! 1 where yi = (yi1; yi2; yi3; yi4) is the i-th subject’s vector of data. Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 17 One-Way Repeated Measures ANOVA Model Form and Assumptions Note on Compound Symmetry and Sphericity Assumption of compound symmetry is more strict than we need. For valid inference, we need the homogeneity of treatment-difference variances (HOTDV) assumption to hold, which states that Var(yij − yik ) = θ for any j 6= k, where θ is some constant. This is the sphericity assumption for covariance matrix If compound symmetry is met, sphericity assumption will also be met. Var(yij − yik ) = Var(yij ) + Var(yik ) − 2Cov(yij ; yik ) 2 2 2 = 2σY − 2σρ = 2σe Nathaniel E. Helwig (U of Minnesota) Linear Mixed-Effects Regression Updated 04-Jan-2017 : Slide 18 One-Way Repeated Measures ANOVA Estimation and Inference Ordinary Least Squares Estimation Parameter estimates are analogue of balanced two-way ANOVA: 1 µ^ = Pa Pn y = y¯ na j=1 i=1 ij ·· 1 ρ^ = Pa y − µ^ = y¯ − y¯ i a j=1 ij i· ·· 1 α^ = Pn y − µ^ = y¯ − y¯ j n i=1 ij ·j ·· which implies that the fitted values have the form y^ij =µ ^ +ρ ^i +α ^j = y¯i· + y¯·j − y¯·· so that the residuals have the form e^ij = yij − y¯i· − y¯·j + y¯·· Nathaniel E.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages76 Page
-
File Size-