|
|
|
||||
|
|
|||||
MLwiN data files, hsb12.ws , hsb12a.ws and willett.ws
Outline
Starting MLwiN and opening data
To open an existing MLwiN worksheet, you can do the following.
Once you have the data open, you can see the variable names, number of cases (valid and missing) and min/max like this.
You can view the data in a kind of spreadsheet like this.
Model 1: Predicting MathAch from meanses
This model is from page 331 of the Singer article.
This model uses a school level predictor, meanses, to predict MathAch. Further, we recognize that each school may have a different intercept, so the intercept is random at level 2 and level 1. We can write this model using multiple equations as shown below.
Level 1: MathAchij = β0j + rij
Level 2: β0j = γ00 + γ01(MeanSES) + u0j
Combining the two equations into one by substituting the level 2 equation into the level 1 equation, we have the equation below, with the random effects identified by placing them in square brackets.
MathAchij = γ00 + γ01(MeanSES) + [ u0j + rij ]
The term u0j is a random effect at level 2, representing random variation in the average math achievement among (between) schools.
The term rij is a random effect at level 1, representing random variation in the math achievement of students within schools.
We can create and run this model in MLwiN as shown below.
The Equations window should then look like the one below.

The results of model should look like this below.

Comments:
Model 2: Predicting MathAch from cses
This model is from page 335 of the Singer article.
This model is referred to as a random-coefficient model by Raudenbush and Bryk. Pretend that we will a run regression of MathAch on centered ses on each school; that is, we are going to run 160 regressions. We can then ask the following questions.
Here is the model expressed using multiple equations.
Level 1: MathAchij = β0j + β1j (cses) + rij
Level 2: β0j = γ00 + u0j
Level 2: β1j = γ10 + u1j
Combining the two equations into one by substituting the level 2 equation to level 1 equation, we have the following with the random effects identified by placing them in square brackets.
MathAchij = γ00 + γ10(cses) + [ u1j(cses) + u0j + rij ]
Instead of using meanses we would like to use centered SES or cses to predict math achievement. Change meanses to cses and make it random at level 2. The Equation window should look like this.

The results of model should look like this below.

Comments:
Model 3: Predicting MathAch from meanses, sector, cses, meansesBYcses and sectorBYcses
This model is shown in the Singer article on pages 337 and 338.
This model is referred as an intercepts and slopes-as-outcomes model by Raudenbush and Bryk. The questions that we are interested in are:
We can express this as a multiple equation model like this.
Level 1: MathAchij = β0j + β1j (cses) + rij
Level 2: β0j = γ00 + γ01(MeanSES) + γ02(Sector) + u0j
Level 2: β1j = γ10 + γ11(MeanSES) + γ12(Sector) + u1j
Combining the two equations into one by substituting the level 2 equations into the level 1 equation, we have the following equation. The random effects are identified by placing them in square brackets.
MathAchij = γ00 + γ01(MeanSES) + γ02(Sector) + γ10 (cses) + γ11(MeanSES*cses) + γ12(Sector*cses) + [ u0j + u1j(cses) + rij ]
We can do this in MLwiN like this.
Your model should look like this (but maybe out of order).

The results of model should look like this below.

Let us focus on the interactions with cses. The sectorBYcses interaction is significant. When sector is 0 (public), the slope for cses is 2.939 and when sector is 1 (Catholic) the slope for cses is 2.939 + -1.644 = 1.295. We can view this interaction by generating the predicted values and graphing them.


Click Apply

The slope of cses for public schools (sector 0) is 2.939 because this is the coefficient for cses. Catholic schools (sector = 1) have a slope of 2.939 + -1.644 = 1.295 (coefficient for cses plus the coefficient for csesBYsector, illustrated in the graph above).
The meansesBYcses interaction is tricky to interpret. The interaction term is 1.042, which means that for every one unit increase in the average SES for a school, the slope between cses and MathAch is expected to increase by 1.042. In short, as the SES for a school increases, we predict the slope of cses would increase. We can visually see this as shown below.
Viewing predicted values for meansesBYcses interaction


Click Apply.

The slope of cses when meanses is 0 is 12.114. As meanses increases, so does cses, because the meansesBYcses interaction term is positive (1.042). In fact, when meanses increases by 1 point, the slope for cses increases by 1.042. So if a school has a meanses of 1, then the predicted slope for cses would be 12.114 + 1.042.
Repeating the Examples
In the examples above, we have simplified matters in a number of ways to help focus on the process of creating models in the MLwiN equation editor and getting the results. However, we have concealed a number of tasks that needed to be performed to be able to run the models; namely, how to input the data into MLwiN and how to create some of the variables used in the models. We will repeat the steps of running examples 1, 2 and 3 again but this time show how to input the data into MLwiN and how to create the variables.
Inputting Data
We believe that the easiest way to get your data into MLwiN is to convert it from a Stata data file to an MLwiN data file. There are other methods for getting your data into MLwiN, but we have found them to be much more difficult than this method. We have the data file as a Stata data file called hsb12a.dta . Notice this is called hsb12a -- this file is unlike the prior file not only because it is a Stata file, but also because it does not have lots of the variables already computed for us, namely meanses, cses, meansesBYcses and sectorBYcses.
We use a Stata command called stata2mlwin to help convert the Stata data file to an MLwiN data file. You can get stata2mlwin from within Stata like this.
net from http://www.ats.ucla.edu/stat/stata/ado/analysis net install stata2mlwin
Assuming you have downloaded hsb12a.dta as c:\alda\hsb12a.dta you can convert the file like this.
stata2mlwin using hsb12a
Then, you can complete the conversion by starting MLwiN and doing the following steps.
Model 1 (again): Predicting MathAch from meanses
This model is from page 331 of the Singer article.
This process is much like before, however we need to do a couple of extra
steps that were done for us before:
1) we must sort the data on school and then student (our
level 2 and level 1 variables)
2) We need to create meanses.
The Equations window should then look like the one below.

The results of model should look like this below.

Model 2 (again): Predicting MathAch from cses
This model is from page 335 of the Singer article.
We need to add an extra step that we did not perform before -- we need to create cses (the group mean centered version of ses). We do this by taking ses minus the average value of ses within the school meanses.
The Equations window should then look like the one below.

The results of model should look like this below.

Model 3 (again): Predicting MathAch from meanses, sector, cses, meansesBYcses and sectorBYcses
This model is shown in the Singer article on pages 337 and 338.
To run this model we need to create meansesBYcses by multiplying meanses by cses. We also need to create the interaction of cses by sector (a continuous by categorical interaction).

Create and add cses by sector interaction by
clicking Model then Main Effects and Interactions
Under categorical pick sector
Select sector
Enter 0 for public and 1 for catholic then
Apply

Close the window
Under categorical, select sector (again)
Under continuous select cses
Click Main Effects and fill in the boxes to get the main effects and
interactions like this.

Click Build
Close the window
Your model should look like this (but maybe out of order).

The results of model should look like this below.

For more information on multilevel modeling and MLwiN, please see the following:
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services