Defining variable as level-2-effect

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
mikeb
Posts: 2
Joined: Wed May 05, 2010 10:41 am

Defining variable as level-2-effect

Post by mikeb »

Dear all,

I want to identify characteristics that determine the use of a certain technology in a hospital. To do so, I will run a 2-level random intercept logistic model. My first level variables are patients’ characteristics; the second level variables will be hospital characteristics, e.g. number of beds. I imported a Stata dataset sorted by (1) hospital id and (2) patient id.

I want to use the total number of hospital beds as an explanatory variable. How can I define this variable as a j-level variable (instead of the default, the ij-level). Do I have to make any adjustments before importing the stata dataset?

Thank you in advance for your help!
Lydia
Posts: 26
Joined: Tue Oct 13, 2009 2:55 pm

Re: Defining variable as level-2-effect

Post by Lydia »

Defining a variable as a level 2 variable is very simple in MLwiN: you just have to make sure that the variable takes on the same value for all the level 1 units that belong to the same level 2 unit. When you enter the variable into a model, MLwiN will look at it, and if it has this property, it will be treated as a level 2 variable and have a j instead of an ij subscript.

Note that the level 2 variable - indeed a variable at any level - should have one row per level 1 unit. You can import the variable into MLwiN with one row per level 2 unit, and then expand it to have one row per level 1 unit in MLwiN; this is perhaps the best way to make sure that it does in fact take the same value for all the level 1 units that belong to the same level 2 unit (or of course doing the same thing in any other software package that offers this facility before importing to MLwiN would be just as good). To do this, as well as the variable in its original form of one row per level 2 unit you need a version of the Level 2 ID variable which has 1 row per level 2 unit (this will tell MLwiN which row of the variable refers to which level 2 unit). You might import this along with the rest of the data or you can create that in MLwiN too like this:
  • Select unreplicate from the Data manipulation menu
    In the Take data window that appears choose your Level 2 ID variable in the drop-down box and under Input columns
    Choose a free column under Output columns
    Press Add to action list and Execute
Once you have your 'short version' of the Level 2 ID variable, you can expand your level 2 variable:
  • From the Data manipulation menu select Merge(replicate)
    Under Merge from ID select your short version of the Level 2 ID variable
    Under Onto ID select the original version of the Level 2 ID variable
    Under Input columns select the short version of the level 2 variable (you can select more than one variable, to do several in one go)
    Under Output columns select a free column for each level 2 variable
    Click Add to action list and Execute
If you find that your level 2 variable is not being recognised as level 2 in the Equations window (i.e. when you add it to the model it has an ij not a j subscript) then this is an indication that you have made a mistake somewhere, and there is a level 2 unit which does not have the same value of the variable for every level 1 unit. See the FAQ on CMM's website which explains how you can check your data to find the mistake when this happens:

http://www.cmm.bristol.ac.uk/MLwiN/tech ... l#twoasone
mikeb
Posts: 2
Joined: Wed May 05, 2010 10:41 am

Re: Defining variable as level-2-effect

Post by mikeb »

Dear Lydia,

thank you so much for your reply, very helpful!
I assume, there will be a mistake in the variables, I need to check it.

Thank you!
svregenm
Posts: 2
Joined: Tue May 02, 2017 9:02 am

Re: Defining variable as level-2-effect

Post by svregenm »

Dear all,

I also have the problem that My level 2 variables are not recognized by MLWIN as level 2 variables. I checked my data in SPSS, and I followed the steps described under the topic: 'My level 2 variables are being treated as level 1 variables' from the FAQ (http://www.bristol.ac.uk/cmm/software/s ... /misc.html) to control my level 2 variables in mlwin. Both checks resulted in the concluded that for all different groups (municipalities) I had only one value for the level 2 variable.

I tried to do the steps described by Lydia:

Note that the level 2 variable - indeed a variable at any level - should have one row per level 1 unit. You can import the variable into MLwiN with one row per level 2 unit, and then expand it to have one row per level 1 unit in MLwiN; this is perhaps the best way to make sure that it does in fact take the same value for all the level 1 units that belong to the same level 2 unit (or of course doing the same thing in any other software package that offers this facility before importing to MLwiN would be just as good). To do this, as well as the variable in its original form of one row per level 2 unit you need a version of the Level 2 ID variable which has 1 row per level 2 unit (this will tell MLwiN which row of the variable refers to which level 2 unit). You might import this along with the rest of the data or you can create that in MLwiN too like this:
Select unreplicate from the Data manipulation menu
In the Take data window that appears choose your Level 2 ID variable in the drop-down box and under Input columns
Choose a free column under Output columns
Press Add to action list and Execute
Once you have your 'short version' of the Level 2 ID variable, you can expand your level 2 variable:
From the Data manipulation menu select Merge(replicate)
Under Merge from ID select your short version of the Level 2 ID variable
Under Onto ID select the original version of the Level 2 ID variable
Under Input columns select the short version of the level 2 variable (you can select more than one variable, to do several in one go)
Under Output columns select a free column for each level 2 variable
Click Add to action list and Execute


But somehow I did not manage to get any result. It might that I do not fully understand what is done.

Did somebody encounter the same problem? How do I get my level 2 variables recognized by mlwin?

Thank you for helping me,

Kind regards,

Sofie Van Regenmortel
svregenm
Posts: 2
Joined: Tue May 02, 2017 9:02 am

MLWIN Difference in subscripts contextual variables multilevel regression with continuous, with binary and with multinom

Post by svregenm »

Dear Sir/Madam,

When adding a contextual variable in MLWIN running a model with a continuous or binary response variable, the subscript takes the letter of the according level (for a 2 level model this is j). However when running a multilevel model with a multinomial response variable, (adding the same contextual variable) the subscript is similar to these of the individual level variables (ijk).

This is not only for my data, but is also shown in the examples of the LEMMA electronic learning environment (see chapter 10). I suppose this is a characteristic of mlwin?

My questions however is the following: although the subscript in the multinomial multilevel model refers to a individual level variable (ijk), does the program mlwin treats it as a contextual (2nd level variable) or as a first level variable?

Despite consulting many books, presentations, manuals, the electronic online course, I cannot find a clear answer. I hope somebody of you came across this and can assure me how the contextual variable is treated in a multilevel multinomial model in mlwin where the subscript is ijk. There is a big difference in treatment I suppose as some groups consist of 50 respondents and others of 200.

Thanks for helping me finding an answer, your help is very much appreciated.

Kind regards,

Sofie Van Regenmortel
Post Reply