Page **1** of **1**

### R2MLwiN and starting values for MCMC estimation

Posted: **Mon Jul 28, 2014 2:30 pm**

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

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Tue Jul 29, 2014 9:16 am**

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.

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Tue Jul 29, 2014 10:41 am**

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

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Tue Jul 29, 2014 10:50 am**

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.

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Tue Jul 29, 2014 3:26 pm**

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

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Fri Aug 01, 2014 3:12 pm**

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

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Wed Nov 27, 2019 11:23 am**

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

### Re: R2MLwiN and starting values for MCMC estimation

Posted: **Wed Nov 27, 2019 5:37 pm**

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.