UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

MLwiN Textbook Examples
Multilevel Analysis Techniques and Applications by Joop Hox
Chapter 2: The Basic Two-Level Regression Model: Introduction

The data set used in this chapter is popular.ws.
Table 2.1 on page 17.
Part1: Intercept only. (M0)
Results for null model:
Part 2: The variable sex is included as a random effect and teacher experience (texp) as fixed effect (M1).
Results for the model:
Table 2.2 on page 20.
Part 1: M1, as shown above.
Part 2: Cross-level interaction with teacher experience (M2). We first created a variable gxtexp, an interaction term of sex and terp. The variable gxtexp is included as a fixed effect.
 
Results for the model:
Table 2.3 on page 21.
Part 1: M1 from Table 2.2.
Part 2: Standardized variables. We first created standardized variables: zpopular, zsex and ztexp.
->AVERage 3 "popular" "sex" "texp"
                 N     Missing    Mean         s.d.
popular       2000         0     5.3080        1.2259       
sex           2000         0     0.48700       0.49996      
texp          2000         0     14.263        6.5518       
->CALCulate "zpopular"=("popular"-5.308)/1.2259
->CALCulate "zsex"=("sex"-.487)/.49996
->CALCulate "ztexp"=("texp"-14.263)/6.6618
Results for the model:
Figure 2.1 on page 23. Return back to model M1. After running M1, from Menu, click on Residuals. From Settings, accept all the default choices and click on Calc. From Plots, choose the first plot, (standardized residuals) x (normal scores).
Figure 2.2 Level 1 standardized residuals plotted against predicted popularity. Choose (standardized residuals) x (fixed part prediction).
Figure 2.3. Level 2 residuals plotted against predicted popularity. From Settings, change level to 2:school. Then click on Calc. From Plots, choose (standardized residuals) x (fixed part prediction).
Figure 2.4. Error bar plot of level 2 residuals. From Plots, choose (residuals +/- 1.0 sd) x rank.
Figure 2.6 Plot of the 100 class regression slopes for pupil gender. We first generated the slope for each class and each gender by choosing Predictions from Model menu and by picking the beta1, the coefficient for variable sex and the intercept term. Pick an unused variable name and rename it to pred to store the predicted values.
After calculating the predicted values, we can then go to Graphs->Customized Graph(s). Our y-variable will be the predicted value and x-variable will be variable sex. Choose group to be school and plot style to be line and that is all.
Click on the graph, we will get Graph Options and we can modify the title and labels accordingly.
NOTE: Although the above process replicates the plot in the book precisely, conceptually it is not very clear why we want to include the first level residuals. The other way to plot the 100 school regression slopes for pupil gender would be not using the first level residuals.

How to cite this page

Report an error on this page

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


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California