In this section, we load the exam scores data set, activate the help page for it, and examine the first 6 lines of the data frame object.
school normexam schgend schavg vr intake standLRT sex type
1 1 0.261324 mixed 0.166175 mid 50% bottom 25% 0.619059 F Mxd
2 1 0.134067 mixed 0.166175 mid 50% mid 50% 0.205802 F Mxd
3 1 -1.723882 mixed 0.166175 mid 50% top 25% -1.364576 M Mxd
4 1 0.967586 mixed 0.166175 mid 50% mid 50% 0.205802 F Mxd
5 1 0.544341 mixed 0.166175 mid 50% mid 50% 0.371105 F Mxd
6 1 1.734899 mixed 0.166175 mid 50% bottom 25% 2.189437 M Mxd
student
1 143
2 145
3 142
4 141
5 138
6 155
We first compute the correlation coefficient between exam scores and LRT scores using all students in the data set. We then compute the mean exam scores and mean LRT scores by school. The correlation coefficient between mean school exam scores and mean school LRT scores is then calculated.
[1] 0.59165
[1] 0.692412
We draw a scatter diagram of the exam scores against the LRT scores and add the regression line. Next we superimpose on the scatter plot the mean school exam scores and mean school LRT scores (in color cyan) and add the regression line based on the mean school scores.
Goldstein, H., Rasbash, J., et al (1993). A multilevel analysis of school examination results. Oxford Review of Education, 19, 425-433.