Page 1 of 1

Multiple membership model in Stata

Posted: Mon Jul 01, 2013 9:55 am
by StephenS
I am trying to run a multiple membership model using runmlwin in Stata (linking to MLWin v 2.27). I have used the code provided in section 16.4 of the MLWin MCMC manual (http://www.bristol.ac.uk/cmm/media/runm ... _Models.do). The code runs fine until the last command (i.e. to fit the multiple membership model), when I get the following error message in Stata:

merge: after merge, not all observations from master or matched
(merged result left in memory)
r(9);

My dataset consists of 357 individuals, who belong to 1 of 83 different primary schools (school1) at the first time point, and 1 of 48 different secondary schools (school3) at the second time point. I have created mmweight variables which are 0.5 for each time point. My Stata code is shown below:

qui runmlwin fmi3 cons age sex , ///
level2(school1: cons) ///
level1(serno: cons) ///
nopause

matrix b = e(b)

matrix V = e(V)

runmlwin fmi3 cons age sex, ///
level2(school1: cons) ///
level1(serno: cons) ///
mcmc(on) initsb(b) initsv(V) ///
nopause

runmlwin fmi3 cons age sex, ///
level2(school1: cons, mmids(school1 school3) mmweights(wt1 wt3) residuals(u)) ///
level1(serno: cons) ///
mcmc(on) initsb(b) initsv(V) ///
nopause

If anyone has a suggestion as to what the problem is, I would be very grateful. Thanks, Stephen.

Re: Multiple membership model in Stata

Posted: Mon Jul 01, 2013 11:29 am
by GeorgeLeckie
Hi Stephen,

The problem comes when we attempt to merge the residuals calculated by MLwiN back into your original data set.
The "master" data are your original data. The "using" data are the data set of school effects to be merged in. The merging variable will be school1, the first of the multiple membership identifier variables.
I think the error is therefore due to the fact that the school IDs which appear in the variable school1 are a subset of all IDs in that classification (half your schools only appear on school2).
So when we attempt to merge back the full set of residuals using school1 as the merging variable we find some schools which are only in the using data (they are neither in the master or the matched).
The solution would normally be to jig your data around so that all schools appear at least once in school1. This will not be feasible with your data. We will look into improving our error trapping so that other users do not run into this problem.

However, I think a cross-classified model will make more sense for your data. There is no reason to expect the variation in student outcomes between-secondary-schools to be the same as the variation in student outcomes between-primary schools so you really want to allow for this by specifying two separate variance components.

Take a look at the following...

Leckie, G. (2013). Cross-Classified Multilevel Models - Concepts. LEMMA VLE Module 12, 1-60.
http://www.bristol.ac.uk/cmm/learning/course.html

Best wishes

George

Re: Multiple membership model in Stata

Posted: Tue Jul 02, 2013 12:55 pm
by StephenS
Hi George

Thank you for your really helpful and quick reply, which makes complete sense. I will look into using the cross-classified models instead.

Best wishes
Stephen