Longitudinal Multilevel Modeling in R Studio (PART 2) HD
In this three part video series, I will show you how to analyze longitudinal data using multilevel modeling in R studio. In part two of this series, I will show you how to build and interpret the unconditional growth model. The unconditional growth model includes a measure of time across a slope (either being a fixed or a random slope). By running the unconditional growth model, we can test the appropriateness of the slope, and whether the slope for the model should be fixed or random. The unconditional growth model can also be compared with the unconditional means model for "model fit". The unconditional growth model does not include any other predictors (independent variables). All other predictors will be included in the condition growth model, which is the full model. NOTE: All three videos use the "nlme" package for multilevel modeling in R studio. Below is all the R code I used in this video. Please note that angle brackets are not allowed in youtube video descriptions, so I left notes below where the angle brackets need to be inserted within the code. # STEP 1: Upload dataset Data1 (insert angled bracket here)- read.csv(file.choose()) # Make sure your file is a csv file and not an excel worksheet # STEP 2: Open "nlme" package library(nlme) # There are other multilevel modeling packages available such as "lme4" # STEP 3: Examine headers of your data (not required) head(Data1) # STEP 4: Begin plotting the data to see individual slopes # We want to determine whether time should have a fixed or a random slope library(lattice) xyplot(Job_Performance ~ Days_of_Training | ID, data=Data1, type = c("p", "r")) # STEP 5: Run the unconditional growth models. # Unconditional growth model (mod2) - Time as a fixed slope mod2 (insert angled bracket here)-lme(Job_Performance~Days_of_Training,random=~1|ID,data=Data1,method="ML") summary(mod2) intervals(mod2) # When "Days of Training" is treated as a fixed effect, the model is NOT significant and it shows in the fixed effect intervals as well. # Unconditional growth model (mod3) - Time as a random slope mod3 (insert angled bracket here)-lme(Job_Performance~Days_of_Training,random=~Days_of_Training|ID,data=Data1,method="ML") summary(mod3) intervals(mod3) # The two groups sharply contrast in their performance based on training performance overtime, hence why having time as a random slope was a better fit for the model. # STEP 6: Run deviance statistics. # First, rerun the unconditional means model (mod1) from before mod1(insert angled bracket here)-lme(Job_Performance~1,random=~1|ID,data=Data1,method="ML") summary(mod1) intervals(mod1) # Compare unconditional means model (mod1) to unconditional growth model with a fixed slope (mod2) (results (insert angled bracket here)- anova(mod1,mod2)) results$`p-value` # Compare unconditional means model (mod1) to unconditional growth model with a random slope (mod3) (results (insert angled bracket here)- anova(mod1,mod3)) results$`p-value` # STEP 7: Calcu
Похожие видео
Показать еще