The model’s below, evaluate the Cross-level interaction of variables using two different methods. This portion of the analysis I will examine and describe each method and their stories they are portraying.
The first cros level interaction, evaluates studet perception of popularity by gender and teachers experience while radomly finding the association of a school and sex from the factors in the data.
The fixed effect shows a significant interaction between gender and teach exp. On average the popularity index for a boy with a teacher that has 0 exp. is 3.31. For every 1 year increase in experience of the teacher boys perception of popularity increases by .11. For females on average their personal perception of popularity is 4.643 when the teacher has no years of experience. While their personal perception on average is 4.643 for every unit increase in teacher experience their popularity perception decreases by .034.
The random effect for this model examines a random school and suggests thaton average the popularity perception is .6347 higher than the fixed effect and females are .4692 higher than 4.643 (in the fixed effect).
m4_lme <- lme(popular ~ sex*texp, data = popula, random = ~ sex|school, method = "ML")
summary(m4_lme)
## Linear mixed-effects model fit by maximum likelihood
## Data: popula
## AIC BIC logLik
## 4261.85 4306.657 -2122.925
##
## Random effects:
## Formula: ~sex | school
## Structure: General positive-definite, Log-Cholesky parametrization
## StdDev Corr
## (Intercept) 0.6347377 (Intr)
## sex 0.4692521 0.08
## Residual 0.6264320
##
## Fixed effects: popular ~ sex * texp
## Value Std.Error DF t-value p-value
## (Intercept) 3.313651 0.15954654 1898 20.769180 0e+00
## sex 1.329479 0.13183479 1898 10.084432 0e+00
## texp 0.110229 0.01013882 98 10.872007 0e+00
## sex:texp -0.034025 0.00837995 1898 -4.060303 1e-04
## Correlation:
## (Intr) sex texp
## sex -0.046
## texp -0.909 0.042
## sex:texp 0.042 -0.908 -0.046
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -2.93387434 -0.64733763 0.02294381 0.53272602 3.49150352
##
## Number of Observations: 2000
## Number of Groups: 100
The second model, takes a different approach in analyzing the interaction of teacher experience and gender differences. This model is displayed in two steps. By centering the covariates we have created a new center for the variable making the mean the starting point. 0. By doing this we are controlling the outputs and anything below mean will fall below 0 and those above will be higher than 0.
popula %<>% mutate(ctexp = texp - mean(texp))
m4a_lme <- lme(popular ~ sex*ctexp, data = popula, random = ~ sex|school, method = "ML")
summary(m4a_lme)
## Linear mixed-effects model fit by maximum likelihood
## Data: popula
## AIC BIC logLik
## 4261.85 4306.657 -2122.925
##
## Random effects:
## Formula: ~sex | school
## Structure: General positive-definite, Log-Cholesky parametrization
## StdDev Corr
## (Intercept) 0.6347377 (Intr)
## sex 0.4692521 0.08
## Residual 0.6264320
##
## Fixed effects: popular ~ sex * ctexp
## Value Std.Error DF t-value p-value
## (Intercept) 4.885851 0.06660875 1898 73.35149 0e+00
## sex 0.844178 0.05510824 1898 15.31855 0e+00
## ctexp 0.110229 0.01013882 98 10.87201 0e+00
## sex:ctexp -0.034025 0.00837995 1898 -4.06030 1e-04
## Correlation:
## (Intr) sex ctexp
## sex -0.044
## ctexp -0.006 0.000
## sex:ctexp 0.000 -0.004 -0.046
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -2.93387434 -0.64733763 0.02294381 0.53272602 3.49150352
##
## Number of Observations: 2000
## Number of Groups: 100
The second model suggests that on average males perception of popularity is 4.88 when teacher experience is averaged. Females perception of popularity is 5.724 when teacher experience is averaged. When the mean teacher’s experience increases by 1 year boys perception of popularity increases by .11 while females perception decreases by .03.
The random effect for this model examines a random school and suggests thaton average the popularity perception is .6347 higher than the fixed effect and females are .4692 higher than 4.643 (in the fixed effect).
The 2 models, tell very similar stories, they both examine the interaction of teachers experience with gender to see the influence both variables have together on personal perception of popularity.
The differences between both models are the fixed effect calculations but, this difference is because we have centered the variable teachers experience. The reason for this is to control the outliers and to see where gender falls when the mean of teachers experience is the starting point.
The Similarities we can examine is the random effect which demonstrates that a random school’s gender difference has the same difference in either model. Also, despite some numerical differences in the intercepts and slopes the story line of the interaction of teachers experience and gender is still the center of the models. The comparatives shown in the below table illustrates that both models are perfect fits as they both have the same BIC and AIC.
library(texreg)
htmlreg(list(m4_lme, m4a_lme))
| Model 1 | Model 2 | ||
|---|---|---|---|
| (Intercept) | 3.31*** | 4.89*** | |
| (0.16) | (0.07) | ||
| sex | 1.33*** | 0.84*** | |
| (0.13) | (0.06) | ||
| texp | 0.11*** | ||
| (0.01) | |||
| sex:texp | -0.03*** | ||
| (0.01) | |||
| ctexp | 0.11*** | ||
| (0.01) | |||
| sex:ctexp | -0.03*** | ||
| (0.01) | |||
| AIC | 4261.85 | 4261.85 | |
| BIC | 4306.66 | 4306.66 | |
| Log Likelihood | -2122.92 | -2122.92 | |
| Num. obs. | 2000 | 2000 | |
| Num. groups | 100 | 100 | |
| p < 0.001, p < 0.01, p < 0.05 | |||