No Residuals at Level 1

Welcome to the forum for MLwiN users. Feel free to post your question about MLwiN software here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Remember to check out our extensive software FAQs which may answer your question: http://www.bristol.ac.uk/cmm/software/s ... port-faqs/
Post Reply
runner21
Posts: 5
Joined: Fri Feb 19, 2016 3:47 am

No Residuals at Level 1

Post by runner21 »

I'm running a simulation study, and when I run the final model residuals are only estimated at level two. I generated the data in SAS as follows:
Residuals at level one generated from a normal distribution with a mean of 0 and a standard deviation of 8.94
Residuals at level two generated from a normal distribution with a mean of 0 and a standard deviation of 4.47 (resulting in 20% ICC)
Xij predictor generated from a normal distribution with a mean of 50 and a standard deviation of 10
Yij outcome generated as [100 + 1(xij-grandmean) + 0.5(schmean-grandmean) + uoj + eij], where schmean is the mean for each school (level two unit)

The predictors are grand-mean centered in the model. After reading in the data, I setup the macro as:
RESP 'yij'
IDEN 2 'schid'
IDEN 1 'id'
ADDT 'cons'
SETV 2 'cons'
SETV 1 'cons'
CENT 1
ADDT 'xij'
CENT 0
CENT 1
ADDT 'schmean'
CENT 0

When I run the model, the coefficients are estimated fairly well; however, it appears that the residuals are not estimated correctly, as (omega)e = 0.000(0.000) and (omega)u = 100.988(1.844).

I have re-worked the data generation a few times and get the same result. If anyone has any thoughts I would very much appreciate them!
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: No Residuals at Level 1

Post by ChrisCharlton »

I have attempted to replicate your model as follows:

Code: Select all

NOTE clear worksheet
WIPE

NOTE set random number seed
SEED 1

NOTE number of level-1 units
SET b1 10000

NOTE number of level-2 units in each level-1 unit
SET b2 100

NOTE number of level-2 units
CALC b3 = b1/b2

NOTE generate id column
NAME C1 'id'
GENErate 1 b1 1 'id'

NOTE create short version of school-id (one row per school)
NAME C2 'schshort'
GENErate 1 b3 1 'schshort'

NOTE create expanded version of school-id (one row per id)
NAME C3 'schid'
CODE b3 b2 1 'schid'

NOTE generate level-2 residuals
NAME C4 'u0j' 
NRANdom b3 'u0j' 
CALC 'u0j' = 'u0j'*4.47

NOTE expand level-2 residuals to full length of data
MERGe 'schshort' 'u0j' 'schid' 'u0j'

NOTE generate level-1 residuals
NAME C5 'eij' 
NRANdom b1 'eij' 
CALC 'eij' = 'eij'*8.94

NOTE create column for intercept
NAME C6 'cons' 
PUT b1 1 'cons'

NOTE generate xij
NAME C7 'xij' 
NRANdom b1  'xij' 
CALC 'xij'=50+('xij'*10) 

NOTE create schmean (mean xij for each school)
NAME C8 'schmean'
MLAVerage  'schid'   'xij'   'schmean'

NOTE create grandmean (mean xij over all data)
NAME C9 'grandmean'
MLAVerage  'cons'   'xij'   'grandmean' 

NOTE create yij
NAME C10 'yij'
calc 'yij'=100+('xij'-'grandmean') + (0.5*('schmean'-'grandmean')) + 'u0j' + 'eij'

NOTE set up model
RESP 'yij'
IDEN 2 'schid' 
IDEN 1 'id'
ADDT  'cons'
SETV 2  'cons'
SETV 1  'cons' 
CENT 1
ADDT 'xij'
CENT 0
CENT 1
ADDT 'schmean'  
CENT 0

NOTE run the model
BATCh 1
MAXI 20
STARt
However I don't see the same behaviour as you, as I get (omega)e = 81.157 (1.154) and (omega)u = 15.993(2.377). Could you confirm that my simulation method matches yours?

One thing that it is worth checking is that you are sorting the data correctly according to the model hierarchy and that your ID variables are correct (you can confirm this via the hierarchy window) as if this is wrong you can end up with results similar to what you are seeing.
runner21
Posts: 5
Joined: Fri Feb 19, 2016 3:47 am

Re: No Residuals at Level 1

Post by runner21 »

The sorting was the issue- I re-sorted and I now have estimates that I would expect. Thank you so very much for your suggestions and assistance!
Post Reply