Page 1 of 1

Using R2MLwiN to write BUGS code

Posted: Tue May 06, 2014 9:27 pm
by MannyGomez
Hi,

I'm trying to use R2MLwiN to write some BUGS code of a bivariate mixed model, but I'm getting the error below:

mod<- runMLwiN(Formula ="c(y1, probit(y2,cons)) ~ (0s|cons+treat) + (1s|cons.y1) + (2s|cons)",
D=c("Mixed", "Normal", "Binomial"), levID = c("cluster", "id"), indata = data,
estoptions=list(x64=TRUE, EstM=1, show.file = T,
mcmcMeth = list(burnin = 1000, iterations = 5000, thinning = 1)),
BUGO = c(version = 4, n.chains = 1, debug = T, seed = 12146, bugs = "C:/Program
Files/WinBUGS14/WinBUGS14.exe", OpenBugs = F), MLwiNPath = 'C:/Program Files (x86)/MLwiN v2.29' )


Warning messages:
1: In runMLwiN(Formula = eq.y, D = c("Mixed", "Normal", "Binomial"), :
The Mixed response model is currently not implemented in WinBUGS/OpenBUGS.
2: In file.remove(modelfile) :
cannot remove file 'C:/Users/mgomes/AppData/Local/Temp/RtmpQvWPs1/modelfile_1f386ddd5173.txt', reason 'No such file or directory'
Error in print(summary(chains.bugs.mcmc)) :
error in evaluating the argument 'x' in selecting a method for function 'print': Error in summary(chains.bugs.mcmc) :
error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'chains.bugs.mcmc' not found


I was trying to double check whether the mixed model I manually wrote in Winbugs (attached) was matching that produced by R2MLwiN?
Any help would be great.
Thanks,
Manny

Re: Using R2MLwiN to write BUGS code

Posted: Fri May 09, 2014 7:04 am
by billb
Hi MannyGomez,
There is a reason why we haven't implemented bivariate mixtures in the MLwiN -> BUGS interface. Basically BUGS struggles with covariance matrices that have constraints in them - in the case of the model you have one variance is constrained to 1 and what you have done in this part of your model looks like it will get around that in the simple case of 2 responses (1 binary and 1 normal) although it will result in a different prior. Generalising to several responses and maintaining
a positive definite covariance matrix would be harder
The problem in what you are doing is that u[cluster,2] is now an overdispersion effect on top of the Binomial variation and NOT equivalent to what we do in MLwiN. In MLwiN what we do is generate a latent Normal response y2* which is positive when y2 is 1 and negative when y2 is 0 and this will then be equivalent to the probit link model for y2 as long as the variance of y2* is fixed at 1 and then we can look at correlations between y2* and y1. What you have done is looked at correlations between any overdispersion in the binary response and the normal response - strictly speaking overdispersion in a binary response doesn't make sense so what you are trying is not that sensible.
Hope that helps,
Bill.

Re: Using R2MLwiN to write BUGS code

Posted: Fri May 09, 2014 7:14 am
by billb
Hi Manny,
Apologies half asleep when I wrote the earlier reply and read your code too quickly. The u terms in your model are simply higher level terms and so they are fine and clustering here is fine. The question is really whether one can construct a correlation between the 2 responses at level 1 without creating a latent normal variable. You are doing this with a conditional formulation i.e. conditioning on the residuals from response y1 in the equation for response 2 and using the link between regression and correlation to construct a correlation coefficient. I think maybe Peter Congdon possibly suggested this in one of his books and it might be a method that works though I'm not sure it's 100% equivalent as prior might be slightly different.
My suggestion is to compare estimates and see what you get.
Best wishes,
Bill.

Re: Using R2MLwiN to write BUGS code

Posted: Fri May 09, 2014 3:13 pm
by MannyGomez
Bill,
Many thanks for your detailed response.
I will compare this approach with the latent Normal variable (Albert and Chib, 1993) and I will let you know.
Best,
Manny