# MATH 6643 Summer 2012 Applications of Mixed Models/Students/smithce/Model2

(Difference between revisions)
 Revision as of 13:35, 29 May 2012 (view source)Smithce (Talk | contribs)← Older edit Latest revision as of 13:36, 29 May 2012 (view source)Smithce (Talk | contribs) Line 149: Line 149: :7 ${\color{Red}\gamma_{01}} = -1.779$ Change in Intercept for Public schools (e.g. Intercept for Public = 13.809 -1.779 = 12.03) :7 ${\color{Red}\gamma_{01}} = -1.779$ Change in Intercept for Public schools (e.g. Intercept for Public = 13.809 -1.779 = 12.03) :8 ${\color{Red}\gamma_{02}} = 3.091$  Increase in mathach associated with 1 unit increase in school mean ses - Contextual effect :8 ${\color{Red}\gamma_{02}} = 3.091$  Increase in mathach associated with 1 unit increase in school mean ses - Contextual effect - :9 ${\color{Blue}\gamma_{11}} = 1.366$  Change in within-school effect for Public schools (e.g. ses slope for Public = 1.517 + 1.366 = 2.883) + :9 ${\color{Blue}\gamma_{11}} = 1.366$  Change in within-school effect for Public schools (e.g. ses slope for Public = 1.517 + 1.366 = 2.883).  Equivalent interpretation: The difference between the slope of Public schools compared to Catholic schools. :10 ${\color{Blue}\gamma_{10}} + {\color{Red}\gamma_{02}} = 1.517 + 3.091 = 4.608$ Between school effect for Catholic schools (e.g. This is the difference going from a student with ses = X in a school with mean ses = Y to a student with ses = X + 1 in a school with mean ses = Y + 1) :10 ${\color{Blue}\gamma_{10}} + {\color{Red}\gamma_{02}} = 1.517 + 3.091 = 4.608$ Between school effect for Catholic schools (e.g. This is the difference going from a student with ses = X in a school with mean ses = Y to a student with ses = X + 1 in a school with mean ses = Y + 1) :11 Continued from 9.  Within school effect for Public Schools is ${\color{Blue}\gamma_{11}} + {\color{Blue}\gamma_{10}} = 1.366 + 1.517$ :11 Continued from 9.  Within school effect for Public Schools is ${\color{Blue}\gamma_{11}} + {\color{Blue}\gamma_{10}} = 1.366 + 1.517$

## Latest revision as of 13:36, 29 May 2012

### Model 2 with Contextual Variable

We can easily create a new variable, ses.m, which we assign the mean ses for the particular school the student is comes from:

dd\$ses.m <- with( dd, cvar( ses, id))


Level 1 Model

$mathach_{ij} = {\color{Red}\beta_{0j}} + {\color{Blue}\beta_{1j}}ses_{ij} + r_{ij}$

Level 2 Model (Between School Model)

${\color{Red}\beta_{0j}} = {\color{Red}\gamma_{00}} + {\color{Red}\gamma_{01}Sector_j} + {\color{Red}\gamma_{02}ses.m_j} + {\color{Red}u_{0j}}$
${\color{Blue}\beta_{1j}} = {\color{Blue}\gamma_{10}} + {\color{Blue}\gamma_{11}Sector_j} + {\color{Blue}u_{1j}}$

Combined Model (by substitution)

$mathach_{ij} = {\color{Red}\gamma_{00}} + {\color{Red}\gamma_{01}Sector_j} + {\color{Red}\gamma_{02}ses.m_j} + {\color{Red}u_{0j}} + ({\color{Blue}\gamma_{10}} + {\color{Blue}\gamma_{11}Sector_j} + {\color{Blue}u_{1j}})ses_{ij} + r_{ij}$
$mathach_{ij} = \underbrace{{\color{Red}\gamma_{00}} + {\color{Red}\gamma_{01}Sector_j} + {\color{Red}\gamma_{02}ses.m_j} + {\color{Blue}\gamma_{10}}ses_{ij} + {\color{Blue}\gamma_{11}Sector_j}ses_{ij}}_{Fixed} + \underbrace{{\color{Red}u_{0j}} + {\color{Blue}u_{1j}}ses_{ij} + r_{ij}}_{Random}$

Fixed Portion of the Model

${\color{Red}\gamma_{00}} + {\color{Red}\gamma_{01}}Sector_j + {\color{Red}\gamma_{02}}ses.m_j + {\color{Blue}\gamma_{10}}ses_{ij} + {\color{Blue}\gamma_{11}}Sector_jses_{ij}$

Random Portion of the Model

${\color{Red}u_{0j}} + {\color{Blue}u_{1j}}ses_{ij} + r_{ij}$

fitc <- lme( mathach ~ ses * Sector + ses.m, dd, random = ~ 1 + ses | id )
# Note that id refers to schools not students!


Linear mixed-effects model fit by REML
Data: dd

 AIC BIC logLik 23891.85 23947.74 -11936.92

Random effects:
Formula: ~1 + ses | id
Structure: General positive-definite, Log-Cholesky parametrization

 StdDev Corr (Intercept) 1.7761 (Intr) ses 0.3652 0.6513 Residual 6.0744

Fixed effects: mathach ~ ses * Sector + cvar(ses, id)

 Value Std.Error DF t-value p-value (Intercept) 13.8095 0.332 3602 41.592 0.00E+00 ses 1.5176 0.231 3602 6.564 0.00E+00 SectorPublic -1.7797 0.464 77 -3.836 3.00E-04 ses.m 3.0918 0.590 77 5.241 0.00E+00 ses:SectorPublic 1.3669 0.3057 3602 4.469 0.00E+00

Correlation:

 (Intr) ses SctrPb cv(,i) ses 0.134 SectorPublic -0.733 -0.126 ses.m -0.1 -0.183 0.238 ses:SectorPublic -0.088 -0.733 0.172 0.011

Standardized Within-Group Residuals:

 Min Q1 Med Q3 Max -3.08703974 -0.7342756 0.02854529 0.74982231 2.85516252

Number of Observations: 3684
Number of Groups: 80

L <- list( 'Effect of ses' = rbind(
"Within-school" =  c( 0,1,0,0,0),
"Contextual"    =  c( 0,0,0,1,0),
"Compositional" =  c( 0,1,0,1,0)))
wald ( fitc , L )


 numDF denDF F.value p.value Effect of ses 2 77 43.03857 <.00001
 Estimate Std.Error DF t-value p-value Lower 0.95 Upper 0.95 Within-school 1.5176 0.231 3602 6.564 <.00001 1.064 1.970 Contextual 3.0918 0.590 77 5.241 <.00001 1.917 4.265 Compositional 4.60810 0.593 77 7.776 <.00001 3.428 5.788

L <- list( "Within school effect of ses" =
rbind( "Catholic" = c(0,1,0,0,0),
"Public" = c(0,1,0,0,1),
"Pub-Cath" = c(0,0,0,0,1))
)


 numDF denDF F.value p.value Within school effect of ses 2 3602 114.536 <.00001
 Estimate Std.Error DF t-value p-value Lower 0.95 Upper 0.95 Catholic 1.5176 0.231 3602 6.564 <.00001 1.064 1.970 Public 2.88311 0.208 3602 13.855 <.00001 2.475 3.291 Pub-Cath 1.3669 0.306 3602 4.469 1.00E-05 0.767 1.965

Notes

1. $Var({\color{Red}u_{0}}) = 1.776^2$
2. $Var({\color{Blue}u_{1}}) = 0.365^2$
3. $Cov({\color{Red}u_{0}},{\color{Blue}u_{1}}) = 0.651$
4. $Var({\color{Black}r_{ij}}) = 6.074^2$
5 ${\color{Red}\gamma_{00}} = 13.809$ Intercept for Catholic schools
6 ${\color{Blue}\gamma_{10}} = 1.517$ Within school effect of ses for Catholic schools
7 ${\color{Red}\gamma_{01}} = -1.779$ Change in Intercept for Public schools (e.g. Intercept for Public = 13.809 -1.779 = 12.03)
8 ${\color{Red}\gamma_{02}} = 3.091$ Increase in mathach associated with 1 unit increase in school mean ses - Contextual effect
9 ${\color{Blue}\gamma_{11}} = 1.366$ Change in within-school effect for Public schools (e.g. ses slope for Public = 1.517 + 1.366 = 2.883). Equivalent interpretation: The difference between the slope of Public schools compared to Catholic schools.
10 ${\color{Blue}\gamma_{10}} + {\color{Red}\gamma_{02}} = 1.517 + 3.091 = 4.608$ Between school effect for Catholic schools (e.g. This is the difference going from a student with ses = X in a school with mean ses = Y to a student with ses = X + 1 in a school with mean ses = Y + 1)
11 Continued from 9. Within school effect for Public Schools is ${\color{Blue}\gamma_{11}} + {\color{Blue}\gamma_{10}} = 1.366 + 1.517$