Error running multinomial logit model with random slopes

Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN 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!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
jackethomp
Posts: 1
Joined: Wed Mar 13, 2024 9:07 am

Error running multinomial logit model with random slopes

Post by jackethomp »

Hi

I'm trying to estimate a 2-level multinomial logit model with random slopes but am encountering problems with the estimation.

I'll keep the example simple. I have the following variables in my dataframe:

WPID_RANDOM - respondent id
Country - character variable indicating country
prepared_gov - outcome variable where 1 = "yes, well prepared", 2 = "no, not well prepared," 3 = "prepared"
Gender - 0 = "male," 1 = "female"

There are no missing values in the dataframe.

If I estimate a model with random slopes for gender at the country level, I have the following code:

model1 <- runMLwiN(logit(prepared_gov) ~
Gender +
(1 + Gender | Country),
D = "Unordered Multinomial",
data = dataframe,
estoptions = list(sort.force = TRUE)
)

summary(model1)

However, when I run the model, I get the following output:

/nogui option ignored
ECHO 0


error while obeying batch file C:/Users/-/AppData/Local/Temp/RtmpchhCHz/macrofile_2860395b2cc5.txt at line number 55:
SETV 3 'Gender.No, not well prepared'
Wrong parameters

error while obeying batch file C:/Users/-/AppData/Local/Temp/RtmpchhCHz/macrofile_2860395b2cc5.txt at line number 55:
SETV 3 'Gender.No, not well prepared'

Wrong parameters.
Execution completed

Error in foreign::read.dta(IGLSfile) :
unable to open file: 'No such file or directory'



If I take out the random slope for gender and just specify a random intercept at the country level, the model the runs fine. I notice there isn't an example for a MNL model with random slopes in the documentation. Is something that R2MlWin can't handle?

Thanks in advance
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: Error running multinomial logit model with random slopes

Post by ChrisCharlton »

Can you confirm which versions of MLwiN and R2MLwiN you are using?

This looks like am error in the MLwiN macro that has been generated by R2MLwiN. It is trying to set a random slope for the predictor named Gender.No, not well prepared, which doesn't seem to exist in the data it is working on.

Could you try adding the option debugmode=TRUE into your estoptions? This should leave MLwiN open after the model is set up so that you can confirm which variable names exist via the Data Manipulation>Names window, and we should be able to work out what the actual name is.
Post Reply