Page 1 of 1

Error running multinomial logit model with random slopes

Posted: Wed Mar 13, 2024 9:18 am
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

Re: Error running multinomial logit model with random slopes

Posted: Thu Mar 21, 2024 4:58 pm
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.