Created
January 18, 2017 14:01
-
-
Save TanyaMurphy/b1b85c68f6f01af429c84efd5115cd3e to your computer and use it in GitHub Desktop.
R code for multi-level models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From http://rpsychologist.com/r-guide-longitudinal-lme-lmer#three-level-models | |
# lme | |
lmer(y ~ time * tx + | |
(time | therapist/subjects), | |
data=df) | |
## expands to | |
lmer(y ~ time * tx + | |
(time | therapist:subjects) + | |
(time | therapist), | |
data=df) | |
# nlme | |
lme(y ~ time * tx, | |
random = ~time | therapist/subjects, | |
data=df) | |
## expands to | |
lme(y ~ time * tx, | |
random = list(therapist = ~time, | |
subjects = ~time), | |
data=df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment