New syntax for runMLwiN: mixed hierarchical model

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
MannyGomez
Posts: 17
Joined: Mon Feb 17, 2014 4:55 pm

New syntax for runMLwiN: mixed hierarchical model

Post by MannyGomez »

Hi Chris,
I'm using runMLwiN in R to estimate a mixed hierarchical model (2 continuous and 2 binary). The data is multilevel with patients (USUBJID) clustered within groups (STUDYID).
In the past I have been using successfully this code:

runMLwiN(Formula ="c(walk1, QOL1, probit(death12mo,denomb1), probit(NYHA_bin,denomb2)) ~
(0s|cons+CRT+SEX+CRTMALE) + (1s|cons.walk1 + cons.QOL1) + (2s|cons)",
D=c("Mixed","Normal","Normal","Binomial","Binomial"),
levID = c("STUDYID", "USUBJID"), indata = data.cca,
estoptions=list(EstM=1, mcmcMeth = list(fixM = 1, residM = 1,
Lev1VarM = 1)), MLwiNPath = 'C:/Program Files (x86)/MLwiN v2.30')


However, with the new updates to the R2MLwiN package this syntax does not work anymore (for various reasons). I'm trying to use the new syntax but haven't been successful so far (tried a few alternatives):

runMLwiN( c(walk1, QOL1, probit(death12mo,denomb1), probit(NYHA_bin,denomb2)) ~
1+CRT+SEX+CRTMALE + (1|STUDYID) + (1|USUBJID),
D=c("Mixed","Normal","Normal","Binomial","Binomial"),
estoptions=list(EstM=1, mcmcMeth = list(fixM = 1, residM = 1, Lev1VarM = 1))
data = data.cca, MLwiNPath = 'C:/Program Files (x86)/MLwiN v2.30')


Could you please help me correct this new syntax? (simple random intercept mixed model, with a separate coefficients for each response)

ChrisCharlton
Posts: 1193
Joined: Mon Oct 19, 2009 10:34 am

Re: New syntax for runMLwiN: mixed hierarchical model

Post by ChrisCharlton »

Obviously as I don't have your data I can't test this fully, but I have successfully managed to get a similar model working with syntax like the following:

Code: Select all

runMLwiN(
c(walk1, QOL1, probit(death12mo,denomb1), probit(NYHA_bin,denomb2)) ~ 1+CRT+SEX+CRTMALE + (1|STUDYID) + (1[1] + 1[2]|USUBJID),
D=c("Mixed","Normal","Normal","Binomial","Binomial"),
estoptions=list(EstM=1, mcmcMeth = list(fixM = 1, residM = 1, Lev1VarM = 1)),
data = data.cca,
MLwiNPath = 'C:/Program Files (x86)/MLwiN v2.30')
If this doesn't work you many want to update to the most recent version of MLwiN, and possibly the development version of R2MLwiN, which is what I tested this with.

MannyGomez
Posts: 17
Joined: Mon Feb 17, 2014 4:55 pm

Re: New syntax for runMLwiN: mixed hierarchical model

Post by MannyGomez »

Thanks Chris.

First of all, just wanted to understand a bit better the new syntax. In particular, the level-2 random component.
Are the numbers in square brackets 1[1] + 1[2]|USUBJID referring to the continuous outcomes (1 and 2)? The R2MLwiN guide suggests that the square brackets are only used when we wish to have common coefficients across outcomes? (in my case I'd like them to be separate for each outcome).

Putting that to a side, the syntax runs fine but I get NaN for the coefficients related to the binary variables (!)
I'm not sure whether this is due to the syntax or something else.
If you don't mind, I'll email you some data to your email, and would be great if you could have a quick look at it.

Manny

ChrisCharlton
Posts: 1193
Joined: Mon Oct 19, 2009 10:34 am

Re: New syntax for runMLwiN: mixed hierarchical model

Post by ChrisCharlton »

Yes, the 1[1] and 1[2] formula elements refer to the first two continuous outcomes. In terms of the MLwiN equation we need to tick on the level-1 random effect for the intercept term for each of the continuous responses, but there can be no such effect for the discrete responses. 1[1] adds a common coefficient (but only common with itself, so essentially the same as a separate coefficient) and 1[2] does the same for the second response. If, say, you wanted a common coefficient for the first two response would would instead have specified 1[1:2].

I'm not sure why you would get NaN values for the coefficients, although it might be due to a numeric problem. You could try switching to a simpler model, or a different nonlinear method and seeing whether that makes any difference. If you send me some example data I will see whether there is anything obvious going on.

Post Reply