Notating the Multilevel Modeling of Longitudinal Data Recall the typical -level model Y ij = γ 00 + (γ 0 + u j )X ij + u 0j + e ij Dr. J. Kyle Roberts Southern Methodist University Simmons School of Education and Human Development Department of Teaching and Learning For the multilevel repeated measures model, we have measurement occasions nested inside individuals. Y ti = β 00 + (β 0 + u j )T ti + u 0i + e ti where T ti is a variable designating the time at which Y ti is measured Notating (cont.) Notating (cont.) From before, we can take the full mixed model. Y ti = β 00 + (β 0 + u j )T ti + u 0i + e ti and break it into levels such that the measurement level is Y ti = π 0i + π i T ti + e ti When we add variables at the measurement level into these models, they are referred to as time-varying covariates. Supposing that Y ti is student GPA at time t. A time-varying covariate could be the number of hours of coursework the student was taking at time t. This would be modeled as: and the student level is: Y ti = β 00 + (β 0 + u j )T ti + β 0 X ti + u 0i + e ti π 0i = β 00 + u 0i π i = β 0 + u i Variables at the student level would be referred to as time-invariant covariates, such as gender. These would be modeled as: This model is also referred to as the null model in the multilevel repeated measures as it is the reference model from which we will test all future models. Y ti = β 00 + (β 0 + u j )T ti + β 0 X ti + β 0 Z i + u 0i + e ti
Data Generation > par(mfrow = c(, )) > boxplot(reading ~, data = read.data, xlab = "Weeks of Instr + ylab = "Reading Score") > boxplot(reading ~ id, data = read.data, xlab = "Student ID", + ylab = "Reading Score") > set.seed(00) > read.data <- data.frame(expand.grid( = 0:, + id = :0), treatment = rep(c("control", "treat"), + each = 0), reading = c(sort(rnorm(0,, + 0)), sort(rnorm(0,, 0)), sort(rnorm(0, +, 0)), sort(rnorm(0,, 0)), sort(rnorm(0, + 0, 0)), sort(rnorm(0,, )), sort(rnorm(0, +, )), sort(rnorm(0,, )), sort(rnorm(0, +, )), sort(rnorm(0,, )))) > read.data <- factor(read.data) Reading Score Reading Score Weeks of Instruction Student ID > print(xyplot(reading ~ id, data = read.data, Repeated Measures ANOVA reading 0 > summary(aov(reading ~ factor() + Error(id), + data = read.data)) Error: id Residuals 0 Error: Within factor() 0..0.e-0 Residuals.
Add as a Between Subjects Factor The Multilevel Time Series > (m0 <- lmer(reading ~ + ( id), read.data)) > summary(aov(reading ~ factor() * treatment + + Error(id), data = read.data)) Error: id treatment 0. 0. Residuals 0 Error: Within factor() 0..0.e- factor():treatment.0..0e-0 Residuals 0. Formula: reading ~ + ( id) 0 0-0 0 00 id (Intercept).... -0. Residual.. (Intercept).0.0 0.... (Intr) -0. The Multilevel Time Series (cont.) Adding a treatment effect > (m <- lmer(reading ~ + treatment + ( + id), read.data)) > coef(m0) (Intercept).0000. 0..0.00.0.0.0.00.0.0. 0. 0. 0.0... 0.. Formula: reading ~ + treatment + ( id) 00 0-0 id (Intercept). 0.0.. -0. Residual.. (Intercept) 0..0.0... treatmenttreat -..0-0. (Intr)
Adding a treatment effect (cont.) Adding an interaction effect > (m <- lmer(reading ~ * treatment + ( + id), read.data)) > coef(m) (Intercept) treatmenttreat..0 -. 0.0. -...0 -...00 -...0 -. 0.0.0 -.. 0.0 -. 0..0 -. 0..0 -. 0..0 -. Formula: reading ~ * treatment + ( id) 0-0. 00 id (Intercept) 0.... -0.0 Residual.0. (Intercept).0. 0..0.. treatmenttreat -.. -.00 :treatmenttreat.0.00. Adding an interaction effect (cont.) > coef(m) (Intr) trtmnt -0. treatmnttrt -0.0 0. wks:trtmntt 0. -0.0-0. Comparing Model Fit (Intercept) treatmenttreat.0.0 -..0. -... -..0. -... -. 0.0. -.. -. -..00.00 -..0 -. -. 0 0.. -. :treatmenttreat.0.0.0.0.0.0.0.0 > anova(m0, m, m) Models: m0: reading ~ + ( id) m: reading ~ + treatment + ( id) m: reading ~ * treatment + ( id) Df AIC BIC loglik Chisq Chi Df Pr(>Chisq) m0 0. 0. -0. m 0.0 0. -0. 0.0 0. m 0. 0. -0.. 0.00
Interaction Plot > interaction.plot(read.data$, read.data$treatment, + fitted(m), xlab = "Weeks", ylab = "Reading", + lwd =, lty =, col = c("black", "grey")) Growth Trajectories for m0 > print(xyplot(fitted(m0) ~ id, read.data, Reading 0 0 0 read.data$treatment treat control fitted(m0) 0 Weeks Growth Trajectories for m > print(xyplot(fitted(m) ~ id, read.data, fitted(m) 0