R2MLwiN and starting values for MCMC estimation

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

R2MLwiN and starting values for MCMC estimation

Post by MannyGomez »

Hi,

I'm estimating a multilevel mixed (2 continuous, 2 binary) model using R2MLwiN.
The model runs fine when estimated by RIGLS. However, when I try estimating the same model using MCMC, I get:
MCMC Error 0315: Prior variance matrix is not positive definite

The most common suggestion here in the forum [http://www.bris.ac.uk/cmm/software/supp ... html#c1096] is to set the off-diagonal elements (covariances) to zero.
I tried to do that using R2MLwiN by specifing the starting values for the level-2 covariance matrix (code below). However, the error persists. I wonder whether the specification below is wrong or whether setting covariance=0 does not fix my problem?


init<-diag(4)

model<- runMLwiN(Formula ="c(walk1, QOL1, probit(death,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(x64=TRUE, EstM=1, mcmcMeth = list(fixM = 1, residM = 1,
Lev1VarM = 2, OtherVarM=2), startval=list(RP.v=init)), MLwiNPath = 'C:/Program Files (x86)/MLwiN v2.29')


Any help would be much appreciated.
Manny

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

Re: R2MLwiN and starting values for MCMC estimation

Post by ChrisCharlton »

I would suggest turning on the debugmode option and then checking the equations window in MLwiN to see what the prior matrix is reported as, and whether it matches what you specified.

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

Re: R2MLwiN and starting values for MCMC estimation

Post by MannyGomez »

Hi Chris,
Thanks for the suggestion. When I included 'debugmode=TRUE', it did not open a MLwiN window? It should, right?
Anyway, I tried to estimate the model manually using MLwiN. I first estimated the model by IGLS to generate the starting values for the MCMC estimation, then went to C1096 and manually set the off diagonal elements of the level-2 covariance matrix to 0. After doing this, I clicked on the MCMC estimation but the MLwiN crashed.

A bit frustrating.. I can send you a sample of the dataset if that helps?

Many thanks,
Manuel

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

Re: R2MLwiN and starting values for MCMC estimation

Post by ChrisCharlton »

Yes, adding debugmode=TRUE into the estoptions list should open the MLwiN window, although the 64-bit script version that you have specified doesn't have a GUI so you will probably need to change x64 to FALSE as well. If you could provide an example of a dataset that causes the same problem I will try to track down what is going on.

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

Re: R2MLwiN and starting values for MCMC estimation

Post by MannyGomez »

Thanks Chris.
The GUI window now opens but the MLwiN is still crashing when trying to estimate the model by MCMC.
I will email you an example dataset.
Manuel

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

Re: R2MLwiN and starting values for MCMC estimation

Post by MannyGomez »

Hi,
After a helpful discussion with Chris, here are some useful notes than may be of interest to other users:

- when prior variance is not definite positive, one may have to fix some of the covariance elements of the covariance matrices stored in C1096.

- This can be done via R2MLwiN by including the option 'clre'.
# 'clre' should be a 3*N matrix where the 1st row is the level of the hierarchy (2: level-1 cov matrix; 3: level-2 cov matrix, etc.)
# 2nd and 3rd rows should provide the pair of coordinates of the matrix. Each column corresponds to an element of the matrix.
# Currently, it's only possible to do this for one level at the time! In addition, current version of MLwiN only allows a full or diagonal matrix at higher levels.

Best,
Manny

Tunze123
Posts: 3
Joined: Mon Oct 28, 2019 5:22 am

Re: R2MLwiN and starting values for MCMC estimation

Post by Tunze123 »

I have the same problem with MCMC, however i dont exactly know how to set off diagonal elements. Can you please be explict on this? Where exactly do i go and how to set off these elements.

Thanks

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

Re: R2MLwiN and starting values for MCMC estimation

Post by ChrisCharlton »

You can find example syntax for this in the User Manual chapter 7 replication materials on https://www.bristol.ac.uk/cmm/software/ ... /examples/, although you will probably want to look at the corresponding text in the manual (downloadable from https://www.bristol.ac.uk/cmm/software/ ... nuals.html) to be able to interpret what it is doing. Note that by doing this you are effectively setting these co-variances to be zero.

As Manny says in his notes, if you are using MCMC in MLwiN you can only set the co-variance matrices to be full or diagonal. You may therefore want to use the shortcut smat option, as described in viewtopic.php?t=1457.

Post Reply