Page 1 of 1

Unexpanded level 2 id column

Posted: Thu Mar 25, 2021 8:05 pm
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!

Re: Unexpanded level 2 id column

Posted: Fri Mar 26, 2021 11:10 am
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).

Re: Unexpanded level 2 id column

Posted: Fri Mar 26, 2021 12:19 pm
by LindaCampbell
Thanks, this works!