mkshaw / learn-mlms

Materials for students to learn and instructors to teach multilevel modelling.
https://www.learn-mlms.com
Creative Commons Attribution 4.0 International
29 stars 1 forks source link

Dataset "heck2011.csv" Error? #16

Closed djlacombe closed 9 months ago

djlacombe commented 9 months ago

First, I want to let the authors know that this is an invaluable resource!

I was examining Chapter 8 on centering and imported the data into Stata to see if I could replicate the results. I used the ses_mean variable in the dataset provided (heck2011.csv) and the results are as follows for the first three observations:

. tabstat ses_mean, by(schcode)

Summary for variables: ses_mean Group variable: schcode

schcode | Mean ---------+---------- 1 | -.26675 2 | .6799231 3 | -.548

The means are not close to zero and I was not able to replicate the results. I calculated the ses_cwc variable on my own, using the following commands:

egen grmean = mean(ses), by(schcode)

gen ses_cwc_w = ses - grmean

The means for the first three observations are as follows:

schcode | Mean ---------+---------- 1 | 1.49e-08 2 | 9.17e-09 3 | -1.99e-08

These are close to zero and when I ran the mixed models, I get the following results:

Within: 3.19 Between : 5.89 Contextual: -2.70

It looks like the ses_mean is just the group means without being subtracted from the ses variable.

I was wondering if someone could recalculate the ses_mean variable and rerun the models to see if there is indeed an error.

Thanks!

djlacombe commented 9 months ago

Issue resolved...

I was putting in the wrong variable into the model, ses vs. ses_mean, and now I've confirmed that the results match in Stata.

Sorry for the confusion!

mkshaw commented 9 months ago

Glad you're finding it helpful and the issue was resolved!