Skip to content

Commit 4dfdac1

Browse files
20250219 - sex as a predictor of the intercepts and slopes
1 parent b1c3bd3 commit 4dfdac1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hlm.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ ggplot(
115115

116116
```{r}
117117
linearMixedModel <- lmer(
118-
math ~ female + ageYearsCentered + (1 + ageYearsCentered | id),
118+
math ~ female + ageYearsCentered + female:ageYearsCentered + (1 + ageYearsCentered | id), # random intercepts and slopes; sex as a fixed-effect predictor of the intercepts and slopes
119119
data = mydata,
120120
REML = FALSE, #for ML
121121
na.action = na.exclude,
@@ -197,8 +197,8 @@ ranef(linearMixedModel)
197197

198198
```{r}
199199
linearMixedModel_nlme <- lme(
200-
math ~ female + ageYearsCentered,
201-
random = ~ 1 + ageYearsCentered|id,
200+
math ~ female + ageYearsCentered + female:ageYearsCentered, # sex as a fixed-effect predictor of the intercepts and slopes
201+
random = ~ 1 + ageYearsCentered|id, # random intercepts and slopes
202202
data = mydata,
203203
method = "ML",
204204
na.action = na.exclude)

0 commit comments

Comments
 (0)