1 Data

1.1 Read in data

BASC <- read_sav("BASC.sav")
head(BASC)
## # A tibble: 6 × 24
##   subcode       male  bsi1  bsi2  bsi3  bsi4  bsi5  bsi6  bsi7  bsi8  bsi9 bsi10
##     <dbl>  <dbl+lbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1       3 1 [Male]      74    78    69    NA    NA    NA    NA    NA    NA    NA
## 2       6 0 [Female]    NA    46    59    NA    NA    NA    NA    NA    NA    NA
## 3       7 1 [Male]      48    76    62    46    50    44    56    46    49    41
## 4       8 1 [Male]      54    58    61    52    44    41    44    41    54    51
## 5      10 1 [Male]      42    53    58    53    37    49    48    45    51    NA
## 6      12 1 [Male]      NA    47    44    46    NA    50    49    38    54    39
## # … with 12 more variables: bsi11 <dbl>, age1 <dbl>, age2 <dbl>, age3 <dbl>,
## #   age4 <dbl>, age5 <dbl>, age6 <dbl>, age7 <dbl>, age8 <dbl>, age9 <dbl>,
## #   age10 <dbl>, age11 <dbl>

1.2 Convert from wide to tall

The dataset is in wide format, so we need to convert it to long or tall format.

BASC_tall <- pivot_longer(BASC, c(bsi1:age11), 
names_to = c(".value", "wave"),
names_pattern = "(.{3})(.{1,})" 
) 
head(BASC_tall)
## # A tibble: 6 × 5
##   subcode      male wave    bsi   age
##     <dbl> <dbl+lbl> <chr> <dbl> <dbl>
## 1       3  1 [Male] 1        74  13.7
## 2       3  1 [Male] 2        78  14.3
## 3       3  1 [Male] 3        69  14.6
## 4       3  1 [Male] 4        NA  NA  
## 5       3  1 [Male] 5        NA  NA  
## 6       3  1 [Male] 6        NA  NA

1.3 Center age

I chose to center age 15, but pretty much anything between 13 and 18 is fine if you have a reason.

BASC_tall <- BASC_tall %>%
  mutate(age15 = age - 15)
head(BASC_tall)
## # A tibble: 6 × 6
##   subcode      male wave    bsi   age  age15
##     <dbl> <dbl+lbl> <chr> <dbl> <dbl>  <dbl>
## 1       3  1 [Male] 1        74  13.7 -1.31 
## 2       3  1 [Male] 2        78  14.3 -0.721
## 3       3  1 [Male] 3        69  14.6 -0.389
## 4       3  1 [Male] 4        NA  NA   NA    
## 5       3  1 [Male] 5        NA  NA   NA    
## 6       3  1 [Male] 6        NA  NA   NA

Note that there is a “wave” variable AND an “age” variable. You want to use the age variable because that’s what we care about. Using the wave variable doesn’t make much sense because some people were 11 age their first wave while some were 15. Be sure that you center the correct variable (age) and then use the centered variable.

2 Level 1 and level 2 equations

2.1 Model A: Random effects ANOVA model (no predictors, not even time)

Level 1:

\(Y_{ij} = \pi_{0i} + e_{ij}\)

  • An observation from person i at time j (\(Y_{ij}\)) is equal to person i’s intercept (\(\pi_{0i}\)) plus a person- and time-specific residual (\(e_{ij}\))

Level 2:

Intercept: \(\pi_{0i} = \beta_{00} + r_{0i}\) <- r means it’s random

  • Person i’s intercept (\(\pi_{0i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus a person-specific residual (\(r_{0i}\))
    • Each person can have a different intercept

Combined: Substitute level 2 equations into level 1 equation

\(Y_{ij} = \beta_{00} + r_{0i} + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept)

  • Random: \(r_{0i}\) (intercept)

2.2 Model B: Linear growth model (time is the only predictor) with random intercept only

Level 1:

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij}\)

  • An observation from person i at time j (\(Y_{ij}\)) follows a linear trajectory with person-specific intercept (\(\pi_{0i}\)) and person-specific slope (\(\pi_{1i}\)) plus a person- and time-specific residual (\(e_{ij}\))

Level 2:

Intercept: \(\pi_{0i} = \beta_{00} + r_{0i}\) <- r means it’s random

  • Person i’s intercept (\(\pi_{0i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus a person-specific residual (\(r_{0i}\))
    • Each person can have a different intercept

Slope: \(\pi_{1i} = \beta_{10}\) <- no r means it’s NOT random

  • Person i’s slope (\(\pi_{1i}\)) is equal to the grand intercept (\(\beta_{00}\))
    • Each person CANNOT have a different slope. Everyone has the same slope

Combined: Substitute level 2 equations into level 1 equation

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij} =\)

\((\beta_{00} + r_{0i}) + (\beta_{10}) age15 + e_{ij} =\)

\(\beta_{00} + \beta_{10} age15 + r_{0i} + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope)

  • Random: \(r_{0i}\) (intercept)

2.3 Model C: Linear growth model (time is the only predictor) with random intercept and slope

Level 1:

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij}\)

  • An observation from person i at time j (\(Y_{ij}\)) follows a linear trajectory with person-specific intercept (\(\pi_{0i}\)) and person-specific slope (\(\pi_{1i}\)) plus a person- and time-specific residual (\(e_{ij}\))

Level 2:

Intercept: \(\pi_{0i} = \beta_{00} + r_{0i}\) <- r means it’s random

  • Person i’s intercept (\(\pi_{0i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus a person-specific residual (\(r_{0i}\))
    • Each person can have a different intercept

Slope: \(\pi_{1i} = \beta_{10} + r_{1i}\) <- r means it’s random

  • Person i’s slope (\(\pi_{1i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus a person-specific residual (\(r_{1i}\))
    • Each person can have a different slope

Combined: Substitute level 2 equations into level 1 equation

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij} =\)

\((\beta_{00} + r_{0i}) + (\beta_{10} + r_{1i}) age15 + e_{ij} =\)

\(\beta_{00} + \beta_{10} age15 + r_{0i} + r_{1i} age15 + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope)

  • Random: \(r_{0i}\) (intercept), \(r_{1i}\) (slope)

2.4 Model D: Linear growth model with gender as a level 2 predictor of both intercepts and slopes and random intercept only.

Level 1:

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij}\)

  • An observation from person i at time j (\(Y_{ij}\)) follows a linear trajectory with person-specific intercept (\(\pi_{0i}\)) and person-specific slope (\(\pi_{1i}\)) plus a person- and time-specific residual (\(e_{ij}\))

Level 2:

Intercept: \(\pi_{0i} = \beta_{00} + \beta_{01} MALE + r_{0i}\) <- r means it’s random

  • Person i’s intercept (\(\pi_{0i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus an effect of MALE (\(\beta_{01}\)) plus a person-specific residual (\(r_{0i}\))
    • Each person can have a different intercept
  • MALE is coded 0/1, so this means that the intercept for the group coded 0 (female) will reduce to \(\beta_{00}\) while the intercept for the group coded 1 (male) will reduce to \(\beta_{00} + \beta_{01}\).

Slope: \(\pi_{1i} = \beta_{10} + \beta_{11} MALE\) <- no r means it’s NOT random

  • Person i’s slope (\(\pi_{1i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus an effect of MALE (\(\beta_{11}\))
    • Each person CANNOT have a different slope. Everyone has the same slope.
  • MALE is coded 0/1, so this means that the slope for the group coded 0 (female) will reduce to \(\beta_{10}\) while the slope for the group coded 1 (male) will reduce to \(\beta_{10} + \beta_{11}\).

Combined: Substitute level 2 equations into level 1 equation

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij} =\)

\((\beta_{00} + \beta_{01} MALE + r_{0i}) + (\beta_{10} + \beta_{11} MALE) age15 + e_{ij} =\)

\(\beta_{00} + \beta_{10} age15 + \beta_{01} MALE + \beta_{11} MALE*age15 + r_{0i} + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope for time), \(\beta_{01}\) (slope for MALE), \(\beta_{11}\) (difference in slopes between groups)

  • Random: \(r_{0i}\) (intercept)

2.5 Model E: Linear growth model with gender as a level 2 predictor of both intercepts and slopes and random intercept and slope.

Level 1:

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij}\)

  • An observation from person i at time j (\(Y_{ij}\)) follows a linear trajectory with person-specific intercept (\(\pi_{0i}\)) and person-specific slope (\(\pi_{1i}\)) plus a person- and time-specific residual (\(e_{ij}\))

Level 2:

Intercept: \(\pi_{0i} = \beta_{00} + \beta_{01} MALE + r_{0i}\) <- r means it’s random

  • Person i’s intercept (\(\pi_{0i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus an effect of MALE (\(\beta_{01}\)) plus a person-specific residual (\(r_{0i}\))
    • Each person can have a different intercept
  • MALE is coded 0/1, so this means that the intercept for the group coded 0 (female) will reduce to \(\beta_{00}\) while the intercept for the group coded 1 (male) will reduce to \(\beta_{00} + \beta_{01}\).

Slope: \(\pi_{1i} = \beta_{10} + \beta_{11} MALE + r_{1i}\) <- r means it’s random

  • Person i’s slope (\(\pi_{1i}\)) is equal to the grand intercept (\(\beta_{00}\)) plus an effect of MALE (\(\beta_{11}\)) plus a person-specific residual (\(r_{1i}\))
    • Each person can have a different slope
  • MALE is coded 0/1, so this means that the slope for the group coded 0 (female) will reduce to \(\beta_{10}\) while the slope for the group coded 1 (male) will reduce to \(\beta_{10} + \beta_{11}\).

Combined: Substitute level 2 equations into level 1 equation

\(Y_{ij} = \pi_{0i} + \pi_{1i} age15 + e_{ij} =\)

\((\beta_{00} + \beta_{01} MALE + r_{0i}) + (\beta_{10} + \beta_{11} MALE + r_{1i}) age15 + e_{ij} =\)

\(\beta_{00} + \beta_{10} age15 + \beta_{01} MALE + \beta_{11} MALE*age15 + r_{0i} + r_{1i} age15 + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope for time), \(\beta_{01}\) (slope for MALE), \(\beta_{11}\) (difference in slopes between groups)

  • Random: \(r_{0i}\) (intercept), \(r_{1i}\) (slope for time)

3 Analysis

3.1 Model A: Random effects ANOVA model (no predictors, not even time)

\(Y_{ij} = \beta_{00} + r_{0i} + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept)

  • Random: \(r_{0i}\) (intercept)

SPSS code:

mixed bsi
/print solution testcov g
/method = ml
/fixed = intercept
/random intercept |subject(subcode) covtype(un).

R code:

# unconditional model
modela <- lmer(bsi ~ 1 + (1|subcode),
BASC_tall,
REML = "false")
# model results - fixed effects
summary(modela)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bsi ~ 1 + (1 | subcode)
##    Data: BASC_tall
## 
##      AIC      BIC   logLik deviance df.resid 
##   9613.2   9629.0  -4803.6   9607.2     1411 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9951 -0.5839 -0.1657  0.4153  6.9094 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  subcode  (Intercept) 25.68    5.068   
##  Residual             41.37    6.432   
## Number of obs: 1414, groups:  subcode, 211
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  45.4949     0.3976   114.4

3.2 Model B: Linear growth model (time is the only predictor) with random intercept

\(Y_{ij} = \beta_{00} + \beta_{10} age15 + r_{0i} + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope)

  • Random: \(r_{0i}\) (intercept)

SPSS code:

mixed bsi
/print solution testcov g
/method = ml
/fixed = intercept age15
/random intercept |subject(subcode) covtype(un).

R code:

# linear model with random intercept
modelb_15 <- lmer(bsi ~ 1 + age15 + (1|subcode),
BASC_tall,
REML = "false")
# model results - fixed effects
summary(modelb_15)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bsi ~ 1 + age15 + (1 | subcode)
##    Data: BASC_tall
## 
##      AIC      BIC   logLik deviance df.resid 
##     9574     9595    -4783     9566     1409 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7611 -0.6091 -0.1894  0.4347  6.7759 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  subcode  (Intercept) 24.41    4.940   
##  Residual             40.52    6.365   
## Number of obs: 1413, groups:  subcode, 211
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  46.1420     0.4038  114.28
## age15        -0.7663     0.1282   -5.98
## 
## Correlation of Fixed Effects:
##       (Intr)
## age15 -0.268

3.3 Model C: Linear growth model (time is the only predictor) with random intercept and slope

\(Y_{ij} = \beta_{00} + \beta_{10} age15 + r_{0i} + r_{1i} age15 + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope)

  • Random: \(r_{0i}\) (intercept), \(r_{1i}\) (slope)

SPSS code:

mixed bsi
/print solution testcov g
/method = ml
/fixed = intercept age15
/random intercept age15|subject(subcode) covtype(un).

R code:

# linear model with random intercept and slope
modelc_15 <- lmer(bsi ~ 1 + age15 + (1 + age15|subcode),
BASC_tall,
REML = "false")
# model results - fixed effects
summary(modelc_15)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bsi ~ 1 + age15 + (1 + age15 | subcode)
##    Data: BASC_tall
## 
##      AIC      BIC   logLik deviance df.resid 
##   9526.0   9557.5  -4757.0   9514.0     1407 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1701 -0.6139 -0.1676  0.4306  6.0859 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subcode  (Intercept) 30.570   5.529         
##           age15        1.309   1.144    -0.90
##  Residual             38.523   6.207         
## Number of obs: 1413, groups:  subcode, 211
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  46.0244     0.4416  104.22
## age15        -0.7845     0.1497   -5.24
## 
## Correlation of Fixed Effects:
##       (Intr)
## age15 -0.655

3.4 Model D: Linear growth model with gender as a level 2 predictor of both intercepts and slopes and random intercept.

\(Y_{ij} = \beta_{00} + \beta_{10} age15 + \beta_{01} MALE + \beta_{11} MALE*age15 + r_{0i} + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope for time), \(\beta_{01}\) (difference between groups at time = 0), \(\beta_{11}\) (difference in slopes between groups)

  • Random: \(r_{0i}\) (intercept)

SPSS code:

mixed bsi
/print solution testcov g
/method = ml
/fixed = intercept age15 male age15*male
/random intercept |subject(subcode) covtype(un).

R code:

# linear model with random intercept, gender as predictor
modeld_15 <- lmer(bsi ~ 1 + age15 + male + age15*male + (1|subcode),
BASC_tall,
REML = "false")
# model results - fixed effects
summary(modeld_15)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bsi ~ 1 + age15 + male + age15 * male + (1 | subcode)
##    Data: BASC_tall
## 
##      AIC      BIC   logLik deviance df.resid 
##   9568.5   9600.1  -4778.3   9556.5     1407 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6167 -0.6035 -0.1844  0.4525  6.6777 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  subcode  (Intercept) 24.42    4.942   
##  Residual             40.21    6.341   
## Number of obs: 1413, groups:  subcode, 211
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  45.9706     0.5467  84.090
## age15        -0.4267     0.1699  -2.511
## male          0.2946     0.8106   0.363
## age15:male   -0.7866     0.2578  -3.051
## 
## Correlation of Fixed Effects:
##            (Intr) age15  male  
## age15      -0.297              
## male       -0.674  0.200       
## age15:male  0.196 -0.659 -0.258

3.5 Model E: Linear growth model with gender as a level 2 predictor of both intercepts and slopes and random intercept and slope.

\(Y_{ij} = \beta_{00} + \beta_{10} age15 + \beta_{01} MALE + \beta_{11} MALE*age15 + r_{0i} + r_{1i} age15 + e_{ij}\)

  • Fixed: \(\beta_{00}\) (intercept), \(\beta_{10}\) (slope for time), \(\beta_{01}\) (difference between groups at time = 0), \(\beta_{11}\) (difference in slopes between groups)

  • Random: \(r_{0i}\) (intercept), \(r_{1i}\) (slope for time)

SPSS code:

mixed bsi
/print solution testcov g
/method = ml
/fixed = intercept age15 male age15*male
/random intercept age15 |subject(subcode) covtype(un).

R code:

# linear model with random intercept and slope, gender as predictor
modele_15 <- lmer(bsi ~ 1 + age15 + male + age15*male + (1 + age15|subcode),
BASC_tall,
REML = "false")
# model results - fixed effects
summary(modele_15)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bsi ~ 1 + age15 + male + age15 * male + (1 + age15 | subcode)
##    Data: BASC_tall
## 
##      AIC      BIC   logLik deviance df.resid 
##   9523.6   9565.6  -4753.8   9507.6     1405 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2270 -0.6178 -0.1703  0.4253  6.0419 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subcode  (Intercept) 30.502   5.523         
##           age15        1.114   1.055    -0.95
##  Residual             38.627   6.215         
## Number of obs: 1413, groups:  subcode, 211
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  45.9313     0.5983  76.771
## age15        -0.5295     0.1964  -2.697
## male          0.1491     0.8853   0.168
## age15:male   -0.6004     0.2923  -2.055
## 
## Correlation of Fixed Effects:
##            (Intr) age15  male  
## age15      -0.683              
## male       -0.676  0.461       
## age15:male  0.459 -0.672 -0.652

4 Results

4.1 Plots of the fixed effects

For the models in (D) and (E) – including description of 95% prediction intervals around the fixed effects (based on the random effects, as we’ve done in class, not CIs / standard errors).

Your plots should look something like this.

4.1.1 Model D

The lines for the fixed effects are

tidy(modeld_15)
## # A tibble: 6 × 6
##   effect   group    term            estimate std.error statistic
##   <chr>    <chr>    <chr>              <dbl>     <dbl>     <dbl>
## 1 fixed    <NA>     (Intercept)       46.0       0.547    84.1  
## 2 fixed    <NA>     age15             -0.427     0.170    -2.51 
## 3 fixed    <NA>     male               0.295     0.811     0.363
## 4 fixed    <NA>     age15:male        -0.787     0.258    -3.05 
## 5 ran_pars subcode  sd__(Intercept)    4.94     NA        NA    
## 6 ran_pars Residual sd__Observation    6.34     NA        NA

Girls: \(\hat{Y} = 45.971 + -0.427age15\)

Boys: \(\hat{Y} = 46.265 + -1.213age15\)

The random intercept variance is \(24.425\); the random intercept standard deviation is the square root of the variance, or \(4.942\)

  • 95% of individual intercepts are between \(mean intercept \pm 1.96*SD_{intercept}\)

    • 95% of girls’ intercepts are between \([36.284, 55.657]\)
    • 95% of boys’ intercepts are between \([36.579, 55.952]\)

The random slope variance is \(0\) (no random slope)

  • All girls have a slope of \(-0.427\)
  • All boys have a slope of \(-1.213\)

4.1.2 Model E

The lines for the fixed effects are

tidy(modele_15)
## # A tibble: 8 × 6
##   effect   group    term                   estimate std.error statistic
##   <chr>    <chr>    <chr>                     <dbl>     <dbl>     <dbl>
## 1 fixed    <NA>     (Intercept)              45.9       0.598    76.8  
## 2 fixed    <NA>     age15                    -0.530     0.196    -2.70 
## 3 fixed    <NA>     male                      0.149     0.885     0.168
## 4 fixed    <NA>     age15:male               -0.600     0.292    -2.05 
## 5 ran_pars subcode  sd__(Intercept)           5.52     NA        NA    
## 6 ran_pars subcode  cor__(Intercept).age15   -0.946    NA        NA    
## 7 ran_pars subcode  sd__age15                 1.06     NA        NA    
## 8 ran_pars Residual sd__Observation           6.22     NA        NA

Girls: \(\hat{Y} = 45.931 + -0.53age15\)

Boys: \(\hat{Y} = 46.08 + -1.13age15\)

The random intercept variance is \(30.502\); the random intercept standard deviation is the square root of the variance, or \(5.523\)

  • 95% of individual intercepts are between \(mean intercept \pm 1.96*SD_{intercept}\)

    • 95% of girls’ intercepts are between \([35.107, 56.756]\)
    • 95% of boys’ intercepts are between \([35.256, 56.905]\)

The random slope variance is \(1.114\); the random intercept standard deviation is the square root of the variance, or \(1.055\)

  • 95% of individual slopes are between \(mean slope \pm 1.96*SD_{slope}\)

    • 95% of girls’ slopes are between \([-2.598, 1.539]\)
    • 95% of boys’ slopes are between \([-3.199, 0.939]\)

4.2 Model D and E results

The fixed effects for models D and E are very similar.

  • Average effects are similar

The random effects tell different stories

  • In model D, there is a random intercept but NO random slope. People can have different intercepts (i.e., score at age 15) but they all have the same slopes.

  • In model E, there is a random intercept AND a random slope. People can have different intercepts AND different slopes.

  • There is also a -0.95 correlation between intercepts and slope, so high intercepts have lower (more negative) slopes and low intercepts have higher slopes.

5 Additional questions

Incorporate these into your Results and Discussion. Please bold or underline or highlight them in some way. Indicate which question you’re answering. You should be able to answer these questions in 3 to 5 sentences. These are not essay questions; I just want a few complete sentences conveying your thoughts on these topics.

5.1 Use Model A to calculate the intraclass correlation (ICC) and interpret it.

tidy(modela)
## # A tibble: 3 × 6
##   effect   group    term            estimate std.error statistic
##   <chr>    <chr>    <chr>              <dbl>     <dbl>     <dbl>
## 1 fixed    <NA>     (Intercept)        45.5      0.398      114.
## 2 ran_pars subcode  sd__(Intercept)     5.07    NA           NA 
## 3 ran_pars Residual sd__Observation     6.43    NA           NA

6.43 is the square root of the residual variance

5.07 is the square root of the intercept variance

ICC = \(\frac{\sigma_{r_{0i}}^2}{\sigma_{r_{0i}}^2 + \sigma_{e}^2} = \frac{5.07^2}{5.07^2 + 6.43^2} = 0.383\)

About 38.3% of the variance is at level 2 (the person); it’s because people are different from one another.

About 61.7% of the variance is at level 1 (the occasion); it’s because people vary from occasion to occasion.

5.2 Use likelihood ratio tests to decide on the best model.

LL_b <- -2*glance(modelb_15)[1,2]
LL_c <- -2*glance(modelc_15)[1,2]
LL_d <- -2*glance(modeld_15)[1,2]
LL_e <- -2*glance(modele_15)[1,2]

5.2.1 B vs C: Is a random slope necessary in the model with only time?

  • 2 parameters (random slope and intercept-slope covariance)
  • Observed \(\chi^2\) = 52.041
  • Significant: C > B
  • A random slope is necessary in the model with only time

5.2.2 D vs E: Is a random slope necessary in the model with time and gender?

  • 2 parameters (random slope and intercept-slope covariance)
  • Observed \(\chi^2\) = 48.923
  • Significant: E > D
  • A random slope is necessary in the model with time and gender

5.2.3 B vs D: Does adding gender as a predictor improve the model when there’s only a random intercept?

  • 2 parameters (effect of gender on intercept, effect of gender on slope)
  • Observed \(\chi^2\) = 9.464
  • Significant: D > B
  • Adding gender as a predictor improves the model when there’s only a random intercept

5.2.4 C vs E: Does adding gender as a predictor improve the model when there’s both a random intercept and a random slope?

  • 2 parameters (effect of gender on intercept, effect of gender on slope)
  • Observed \(\chi^2\) = 6.346
  • Significant: E > C
  • Adding gender as a predictor improves the model when there’s both a random intercept and a random slope

Models C and D are better than B. Model E is better than both C and D. Model E is the best model. Another way to think about it is what each model adds. A model with random slopes was better than a model without. A model with gender was better than a model without. The model with both random slopes and gender (E) is the best model.

5.3 Use your best model to address to following questions:

Model E is the best model. This question is about mapping the research question to the correct model parameter.

5.3.1 What can you say about whether boys and girls have different levels of behavioral problems in high school?

This is largely about the fixed intercept – in this case, BSI at age 15. But you might also mention the fixed slope.

5.3.2 What can you say about whether boys and girls have different amounts of change in behavioral problems in high school?

This is about the fixed slope. On average, what is the change over time?

5.3.3 What can you say about heterogeneity (variability) in average BSI score in high school?

The words “heterogeneity” and “variability” should tell you that this is about the random effects – how individual people vary. As with the first question, this is largely about the intercept variance but you might also mention the slope variance.

5.3.4 What can you say about variability in how students’ behavioral problems change over time?

This is about the slope variance. How do people vary in their change over time?

5.3.5 What is the variance explained for your best model? Interpret the value.

Compare Model E to the random effects ANOVA (Model A)

6.43 is the square root of the residual variance for Model A

  • The residual variance for Model A is 41.37

6.22 is the square root of the residual variance for Model E

  • The residual variance for Model E is 38.63

Variance explained = \(\frac{\sigma_{e}^2(Model1) - \sigma_{e}^2(Model2)}{\sigma_{e}^2(Model1)}=\frac{2.746}{41.373}=\) \(0.066\)

The best model (E) explains about \(6.6\)% of the residual variance from Model A.

  • The residual variance is the error in individual trajectories, so \(6.6\)% of that error is explained by adding time, gender, and random slopes

5.4 How does this model address missing data? For example, what does it do with people who are missing outcome values, predictor values, etc.

Mixed models use all available observations, so there are no dropped cases (as in repeated-measures ANOVA).

5.5 Big picture summary: What is going on in terms of behavioral problems for boys and girls between ages 11 and 21? Explain to a layperson.

summary(modele_15)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: bsi ~ 1 + age15 + male + age15 * male + (1 + age15 | subcode)
##    Data: BASC_tall
## 
##      AIC      BIC   logLik deviance df.resid 
##   9523.6   9565.6  -4753.8   9507.6     1405 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2270 -0.6178 -0.1703  0.4253  6.0419 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subcode  (Intercept) 30.502   5.523         
##           age15        1.114   1.055    -0.95
##  Residual             38.627   6.215         
## Number of obs: 1413, groups:  subcode, 211
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  45.9313     0.5983  76.771
## age15        -0.5295     0.1964  -2.697
## male          0.1491     0.8853   0.168
## age15:male   -0.6004     0.2923  -2.055
## 
## Correlation of Fixed Effects:
##            (Intr) age15  male  
## age15      -0.683              
## male       -0.676  0.461       
## age15:male  0.459 -0.672 -0.652
confint(modele_15)
## Computing profile confidence intervals ...
##                  2.5 %      97.5 %
## .sig01       4.8749247  6.25872613
## .sig02      -1.0000000 -0.73626829
## .sig03       0.7161142  1.45599326
## .sigma       5.9552003  6.49010802
## (Intercept) 44.7529341 47.10999512
## age15       -0.9191514 -0.13898447
## male        -1.5967298  1.89070950
## age15:male  -1.1775791 -0.01949949

Girls and boys don’t differ in their behavior problems at age 15. Both boys and girls decrease in behavior problems over time, with boys showing a steeper decline. There is a lot of variability in both age 15 behavior problems and change in behavior problems over time.

(This answer directly ties back to your answers to the questions above, such as “What can you say about whether boys and girls have different levels of behavioral problems in high school?” You answered those statistically and technically. Here, just put it in plain language.)