Multinomial model 2nd level variables

Welcome to the forum for MLwiN users. Feel free to post your question about MLwiN software here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Remember to check out our extensive software FAQs which may answer your question: http://www.bristol.ac.uk/cmm/software/s ... port-faqs/
Post Reply
labaraba
Posts: 1
Joined: Wed Sep 07, 2011 9:10 pm

Multinomial model 2nd level variables

Post by labaraba »

Dear MLwiN Users

I would like to fit a multinomial model and include 2nd level variables. However, when I try to do this by clicking on "add terms" and selecting the third level, the variable appears in the equation with the subscript for all three levels. When I tried to modify the term again as a higher level variable, I got an error message "wrong parameters(SWAP). Hence, I checked whether the 2nd order variables consist only of a single value for each individual in the same higher order, which is the case. When I fitted an ordered multinomial model and added the variables as common coefficients Mlwin recognizes the variables as 2nd order variables. But when the variables are added as separate coefficients, they appear again with a subscript for all three level.

I checked the descriptives and inspected the data as recommended in the Miscellaneous FAQs whereby I could not identify any differences between values for individuals in the same second order group. Missing values do not exist either. In addition, I conducted a linear regression model with the same first and second level structure in which the second level variables are also identified as such automatically.

Does anyone know which might be the cause for the problems in the multinomial model?
Thanks in advance!

Lena
socgdj
Posts: 9
Joined: Fri Oct 07, 2011 8:36 am

Re: Multinomial model 2nd level variables

Post by socgdj »

I am in exactly the same situation as Lena. Would appreciate some hints on how to solve it!

Göran :)
socgdj
Posts: 9
Joined: Fri Oct 07, 2011 8:36 am

Re: Multinomial model 2nd level variables

Post by socgdj »

If anyone happensto be interested in these unanswered posts, I can inform you that I found the solution to be not only adequate sorting of the file but also putting the key variables in correct order and in the first columns of the data matrix. While this should not be necessary in all applications of MLWin it appears fundamental for fitting multinomial models.

Göran
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Multinomial model 2nd level variables

Post by ChrisCharlton »

That's interesting to hear - I don't suppose that you could provide examples (possibly with the MLwiN sample data) of both ways of setting up the model so that I can investigate why this difference is occurring?
socgdj
Posts: 9
Joined: Fri Oct 07, 2011 8:36 am

Re: Multinomial model 2nd level variables

Post by socgdj »

Dear Chris,
I have to retract: I cannot illustrate the importance of correct ordering of variables in the data matrix. When I went back to my old files I discovered that my memory was not correct :?. The problem I had in getting higher level variables to be correctly treated as such (i.e. to get subscript 'jk' instead of 'ijk' for example) seems to require not only a correctly sorted file, which is trivial, but treating these variables as random effect rather than fixed ones.

I discovered that this is a possible solution also to the post I published the other day and which I also approached your staff on. I can get higher levels correctly treated in multiple response models, but only as random effect. What if I wan them as fixed?

Göran
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Multinomial model 2nd level variables

Post by ChrisCharlton »

I think that this is probably just a display issue. MLwiN determines the subscript to draw for a variable by looping through the data and checking whether it remains constant within each level identifier. In multivariate and multinomial models MLwiN expands the data and adds an extra level under the bottom level to indicate which response/contrast each row belongs to. This data expansion changes the patterns of the explanatory variables so that they are no longer constant within the level identifier, for example in a binomial model using the example "bang" dataset d_lit has just a "j" subscript because it doesn't vary within district:

Code: Select all

woman  district d_lit
1.000	1.000	0.090
2.000	1.000	0.090
3.000	1.000	0.090
4.000	1.000	0.090
...
165.000	2.000	0.110
166.000	2.000	0.110
167.000	2.000	0.110
168.000	2.000	0.110
When fitting the same data to a multinomial model the expanded data looks as follows:

Code: Select all

resp_i  woman  district d_lit.2 d_lit.3 d_lit.4
2.000	1.000	1.000	0.090	0.000	0.000
3.000	1.000	1.000	0.000	0.090	0.000
4.000	1.000	1.000	0.000	0.000	0.090
2.000	2.000	1.000	0.090	0.000	0.000
3.000	2.000	1.000	0.000	0.090	0.000
4.000	2.000	1.000	0.000	0.000	0.090
2.000	3.000	1.000	0.090	0.000	0.000
3.000	3.000	1.000	0.000	0.090	0.000
4.000	3.000	1.000	0.000	0.000	0.090
2.000	4.000	1.000	0.090	0.000	0.000
3.000	4.000	1.000	0.000	0.090	0.000
4.000	4.000	1.000	0.000	0.000	0.090
...
2.000	165.000	2.000	0.110	0.000	0.000
3.000	165.000	2.000	0.000	0.110	0.000
4.000	165.000	2.000	0.000	0.000	0.110
2.000	166.000	2.000	0.110	0.000	0.000
3.000	166.000	2.000	0.000	0.110	0.000
4.000	166.000	2.000	0.000	0.000	0.110
2.000	167.000	2.000	0.110	0.000	0.000
3.000	167.000	2.000	0.000	0.110	0.000
4.000	167.000	2.000	0.000	0.000	0.110
2.000	168.000	2.000	0.110	0.000	0.000
3.000	168.000	2.000	0.000	0.110	0.000
4.000	168.000	2.000	0.000	0.000	0.110
As you can see the each expanded d_lit variable is not constant within any rows and so no longer gets a subscript to indicate this.

The actual formula for the fixed part:
B = inv(t(X)*inv(V)*X)*t(X)*inv(V)*Y

doesn't need to know what level each variable is at, so as long as you have sorted the data correctly I believe that the results should be correct.

I hope this makes sense.
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Multinomial model 2nd level variables

Post by ChrisCharlton »

Actually thinking about it further, fitting multinomial models with IGLS in MLwiN does involve a transformation before and after each iteration to match the formulation set out in Harvey Goldstein's book (chapter 7 in the version at http://www.bristol.ac.uk/cmm/team/hg/multbook1995.pdf). I believe that the level of the fixed effect variables doesn't affect this formula either however.
socgdj
Posts: 9
Joined: Fri Oct 07, 2011 8:36 am

Re: Multinomial model 2nd level variables

Post by socgdj »

Thanks Chris,
Your answer is much appreciated! I hope that its being published in this forum would help others to avoid some of the confusion and extra work it implied for me.

Göran Djurfeldt (socgdj)
Post Reply