Lab #4

Ryan Irey

EPSY 8252



LMER 1

1. Multi-level model

2. Composite Model \[ Y_{ij} = \beta_{00} + b_{0i} + \epsilon_{ij} \]

3. Model fit in R

lmer1 <- lmer(popularity ~ 1 + (1 | class), data = pop)
summary(lmer1)
## Linear mixed model fit by REML ['merModLmerTest']
## Formula: popularity ~ 1 + (1 | class)
##    Data: pop
## 
## REML criterion at convergence: 6330
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -3.566 -0.698  0.002  0.676  3.318 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  class    (Intercept) 0.702    0.838   
##  Residual             1.222    1.105   
## Number of obs: 2000, groups: class, 100
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   5.0779     0.0874 98.9000    58.1   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

4. Intraclass Correlation

var.class <- 0.7021
var.resid <- 1.2218
rho = var.class/(var.class + var.resid)
rho
## [1] 0.3649

An estimated 36.5% of the total variation in popularity is attributable to differences between class



LMER 2

5. Multi-level model

\[ \beta_{1i} = \beta_{10} + b_{1j} \]

\[ \beta_{2i} = \beta_{20} + b_{2j} \]

6. Composite Model \[ Y_{ij} = \beta_{00} + \beta_{10}(female_{i}) + \beta_{20}(extra_{i}) + [b_{0j} + b_{1j}(female_{i}) + b_{2j}(extra_{i}) + \epsilon_{ij}] \]

7. Model fit in R

lmer2 <- lmer(popularity ~ 1 + female + extra + (1 + female + extra | class), 
    data = pop)
summary(lmer2)
## Linear mixed model fit by REML ['merModLmerTest']
## Formula: popularity ~ 1 + female + extra + (1 + female + extra | class)
##    Data: pop
## 
## REML criterion at convergence: 4870
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0190 -0.6496 -0.0106  0.6710  3.1176 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr       
##  class    (Intercept) 2.61044  1.6157              
##           female      0.00537  0.0733   -0.33      
##           extra       0.02984  0.1727   -0.93 -0.04
##  Residual             0.55289  0.7436              
## Number of obs: 2000, groups: class, 100
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   2.0879     0.1828  5.8000    6.91  0.00053 ***
## female        1.2448     0.0373 18.8000   28.23  < 2e-16 ***
## extra         0.4430     0.0234 14.8400   15.49  1.4e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##        (Intr) female
## female -0.117       
## extra  -0.907 -0.065

VarCorr(lmer2)$class
##             (Intercept)     female      extra
## (Intercept)     2.61044 -0.0395683 -0.2596114
## female         -0.03957  0.0053666 -0.0004443
## extra          -0.25961 -0.0004443  0.0298421
## attr(,"stddev")
## (Intercept)      female       extra 
##     1.61569     0.07326     0.17275 
## attr(,"correlation")
##             (Intercept)   female    extra
## (Intercept)      1.0000 -0.33430 -0.93015
## female          -0.3343  1.00000 -0.03511
## extra           -0.9301 -0.03511  1.00000

8. Random effects: variance explanations:

9. Random effects: Corr values

The Corr column represents the correlations between the residuals of each factor included in the model; in this instance, it can be inferred that (1) classes with higher intercepts have lower slopes for the female and extraversion factors, and (2) female-dominate classes have lower extraversion slopes (this variance correlation is not nearly as strong as the intercept-factor variance correlations).

10. Why does the random effect for female not belong?

The variance is so small; it is likely that, on average, the ratio of females to males is roughly equal across classes, and thus wouldn't account for much of the between-class variability in popularity.

11. Interpret the fixed effect estimate in the extra row.

On average, each 1-unit increase in extraversion is associated with a 0.443 unit increase in popularity.

12. Interpret the fixed effect estimate in the female row.

On average, being female is associated with a 1.25 unit increase in popularity.

13. Compute a 95% confidence interval for the fixed effect of extra.

For the fixed effect of extra, the estimated std. error is 0.0234; thus

se = 0.0234
two.se = 2 * 0.0234
extra.est = 0.443
CI.lwr = 0.443 - two.se
CI.upr = 0.443 + two.se
CI = c(CI.lwr, CI.upr)
CI
## [1] 0.3962 0.4898

the 95% CI is (0.3962, 0.4898)



LMER 3

14. Multi-level model:

\[ \beta_{1i} = \beta_{10} + \beta_{11}(G_{j}) + b_{1j} \]

\[ \beta_{2i} = \beta_{20} + \beta_{21}(G_{j}) + b_{2j} \]

15. Composite Model \[ Y_{ij} = \beta_{00} + \beta_{01}(teacherExp_{j}) + \beta_{10}(female_{i}) + \beta_{11}(teacherExp_{j})(female_{i}) + \beta_{20} + \beta_{21}(teacherExp_{j})(extra_{i}) + b_{0j} + b_{1j}(female_{i}) + b_{2j}(extra_{i}) + \epsilon_{ij} \]

16. Fit model in R

lmer3 <- lmer(popularity ~ 1 + female + extra + teacherExp + teacherExp:female + 
    teacherExp:extra + (1 + female + extra | class), data = pop)
summary(lmer3)
## Linear mixed model fit by REML ['merModLmerTest']
## Formula: 
## popularity ~ 1 + female + extra + teacherExp + teacherExp:female +  
##     teacherExp:extra + (1 + female + extra | class)
##    Data: pop
## 
## REML criterion at convergence: 4787
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1209 -0.6485 -0.0196  0.6870  3.0506 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr       
##  class    (Intercept) 0.49710  0.7051              
##           female      0.00414  0.0643   -0.44      
##           extra       0.00558  0.0747   -0.60 -0.45
##  Residual             0.55208  0.7430              
## Number of obs: 2000, groups: class, 100
## 
## Fixed effects:
##                   Estimate Std. Error       df t value Pr(>|t|)
## (Intercept)       -1.21436    0.27420  0.02200   -1.29     0.94
## female             1.26564    0.09268  0.02300    4.28     0.91
## extra              0.80289    0.04042  0.35500   17.47     0.25
## teacherExp         0.22689    0.01699  0.02400    4.67     0.91
## female:teacherExp -0.00177    0.00592  0.02500   -0.11     0.98
## extra:teacherExp  -0.02470    0.00257  0.49200   -8.60     0.22
## 
## Correlation of Fixed Effects:
##             (Intr) female extra  tchrEx fml:tE
## female      -0.102                            
## extra       -0.840 -0.161                     
## teacherExp  -0.916  0.107  0.770              
## fml:tchrExp  0.103 -0.918  0.142 -0.136       
## extr:tchrEx  0.748  0.142 -0.902 -0.826 -0.142

VarCorr(lmer3)$class
##             (Intercept)    female     extra
## (Intercept)     0.49710 -0.020019 -0.031822
## female         -0.02002  0.004139 -0.002156
## extra          -0.03182 -0.002156  0.005583
## attr(,"stddev")
## (Intercept)      female       extra 
##     0.70506     0.06434     0.07472 
## attr(,"correlation")
##             (Intercept)  female   extra
## (Intercept)      1.0000 -0.4413 -0.6041
## female          -0.4413  1.0000 -0.4486
## extra           -0.6041 -0.4486  1.0000

17. Which of the five fixed effects estimates should be interpreted? Explain.

Only the female:teacherExp and extra:teacherExp interaction terms should be interpreted. The addition of a Level-2 predictor yields these interactions, and the effects are interpreted directly from the cross-level interactions.

18. Based on deviance, which of the three models fitted thus far seems to fit the best? Explain.

Based on the deviance, LMER 3 seems to fit the best because the deviance criterion is lowest for this model.

19. Based on AIC, which of the three models fitted thus far seems to fit the best? Explain.

AIC(lmer1)
## [1] 6337
AIC(lmer2)
## [1] 4891
AIC(lmer3)
## [1] 4813

Based on the AIC for each model, LMER 3 has the lowest AIC value, and thus seems to fit the best.

20. Based on BIC, which of the three models fitted thus far seems to fit the best? Explain.

BIC(lmer1)
## [1] 6353
BIC(lmer2)
## [1] 4947
BIC(lmer3)
## [1] 4885

Based on the BIC for each model, LMER 3 has the lowest BIC value, and thus seems to fit the best.