Unexpanded level 2 id column

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
LindaCampbell
Posts: 2
Joined: Thu Mar 25, 2021 7:51 pm

Unexpanded level 2 id column

Post by LindaCampbell »

Hello everyone,

I'm hoping someone here can help!

I have a dataset of a cross-sectional study, where 152 patients are nested within 11 clinic districts (therefore a 2-level model). I know it's a small sample, our data collection stopped because of covid. I have sorted on these two levels (patient ID at level 1 and clinic).

I'm currently following the online guidelines for running a multilevel bayesian CFA with an ordinal set of variables. In the guidelines, it says to do the following:
• Select Equations from the Model menu.
• Click on the Responses button.
• Selectvariables from the response list.
• Click on the Done button.
• Click on the responses and the Y variable window will appear.
• Select 2-ij for the number of levels.
• Select [clinic] from the level 2(j) pull down list.
• Click on the Done button.

However, when I do this and select 'clinic', i'm given the following error warning:

"Unexpanded level 2 id column(clinic) must not contain consequtive repeated codes, in multivariate or multinomial models. Use the GENerate command to create unique id codes (IDEN 2 'clinic')."

I've been looking at some of the online resources for dealing with error codes and one source advises the following:

"The reason that repeated values are a problem is that MLwiN needs to create an expanded dataset when you fit a multinomial model, as described in the User's Guide. (With a Normal response model, MLwiN does not expand the dataset). The process that it uses to expand the dataset requires that the level 1 IDs satisfy this condition. In the expanded dataset, a new level 1 is created and the level you specified as level 1 is now level 2, so the level 2 referred to in the error message is the level you specified as level 1.
The sequence to use for level 1 in place of Months can be created either using a command or via the GUI. To create using the GUI, select 'Generate vector' from the 'Data Manipulation' menu. In the window that appears, select 'Sequence' under 'Type of vector'. Select any free column next to 'Output column' and type 1 next to 'Start number', the length of your dataset (this would be for example the length of your Month variable) next to 'End number' and 1 next to 'Step value' and select 'Generate'. To create using a command, in the Command interface window type 'Gene 1 n 1 c100', replacing n by the length of your dataset and c100 by any free column; for example if your Months variable is of length 4587 and column 48 is free you could type 'Gene 1 4587 1 c48'."

I have therefore created a new patient ID variable by generating a vector, but when I try and add this to level 2, I get the same error message. Any thoughts/ideas?

Thanks in advance for any help anyone can give!
ChrisCharlton
Posts: 1252
Joined: Mon Oct 19, 2009 10:34 am

Re: Unexpanded level 2 id column

Post by ChrisCharlton »

As you are fitting a multivariate model there will already be a level-1 identifier included for the response indicator. When setting up the model you would therefore need to specify three levels, with patient at level-2 and clinic at level-3. MLwiN checks that the identifier variable you set at level-2 does not have consecutive repeating codes, however this will be the case for clinic and hence the error. You can find more information about setting up multivariate models in chapter 14 of the MLwiN user's guide (A User’s Guide to MLwiN) and chapter 18 of the MCMC guide (MCMC estimation in MLwiN).
LindaCampbell
Posts: 2
Joined: Thu Mar 25, 2021 7:51 pm

Re: Unexpanded level 2 id column

Post by LindaCampbell »

Thanks, this works!
Post Reply