Hello, I am trying to use R2WinBUGS to conduct a mixed treatment comparison (MTC) analysis. On the surface, it seems to me that I am following the correct steps: (1) reading the data into R, (2) specifying initial values for the parameters in the model and (3) fitting the model to the data using the bugs() function in R2WinBUGS. However, I get the error message ?incompatible copy? when running bugs(), which is a bit confusing, given that I was able to fit the same model without problems in WinBUGS. The WinBUGS log file produced after calling bugs() indicates that the following items were successfully checked: ?model is syntactically correct?, ?data loaded? and ?model compiled?. I suspect R2WinBUGS does not like the initialization of the model parameters (?!) ? the log file abruptly ends after listing the inits() command. Has anyone encountered similar problems with R2WinBUGS? If so, can you please point me in the right direction? Is there a preferred way to initialize the values of the parameters? Things one should do or should not do? In case this may help, here is the R code that I used: library(R2WinBUGS) s = c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, 11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20) t = c(1,2, 1,2, 1,2, 1,2, 1,2, 1,3, 1,3, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,4, 1,5, 1,5) r = c(320,297, 1,5, 82,61, 68,70, 212,185, 138,143, 5,4, 78,87, 3,0, 0,1, 135,106, 306,298, 12,13, 79,55, 4,3, 9,5, 0,1, 641,631, 77,80, 9,1) n = c(636,619, 114,240, 1410,1428, 1199,1211, 5137,5168, 1052,1050, 285,283, 1634,2219, 532,530, 254,254, 3293,3302, 2913,2891, 431,433, 3966,3866, 223,224, 81,83, 154,151, 5185,5170, 3301, 3304, 459,460) b = c(rep(1,40)) N = 40 NS = 20 NT = 5 data <- list("s","t","r","n","b","N","NS","NT") inits <- function(){ list(T=c(0.02,0.02,0.02,0.02,0.02), best=c(0,0.4,0.07,0.13,0.3), d=c(NA,0,0,0,0), lor=c(-0.12,0.03,-0.07,-0.06,0.16,0.04,0.06,0.11,-0.09,0.01), mu=c(0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0), or=c(0.88,1.04,0.92,0.95,1.18,1.05,1.08,0.90,0.92,1.02), p=c(0.50,0.47,0.01,0.01,0.05,0.04,0.06,0.05,0.04,0.03,0.13, 0.13,0.01,0.01,0.04,0.04,0.00,0.00,0.00,0.00, 0.03,0.03,0.10,0.10,0.03,0.02,0.01,0.01,0.01, 0.01,0.08,0.08,0.00,0.00,0.12,0.11,0.02,0.02,0.01,0.01)) } model.sim = bugs(data,inits, model.file="model.bug", parameters=c("T","best","d","lor","mu","or","p"), n.chains=1,n.iter=20000,n.burnin=5000,n.thin=1, bugs.directory="c:/Program Files/WinBUGS14/", codaPkg=FALSE, debug=FALSE) Thank you in advance for any help you may be able to provide! Sincerely, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: isabella at ghement.ca Web: www.ghement.ca
<isabella <at> ghement.ca> writes:> > > Hello, > > I am trying to use R2WinBUGS to conduct a mixed treatment comparison (MTC) > analysis. > Thank you in advance for any help you may be able to provide! >Can you please provide your model.bug file? Ben Bolker
Dear Ben, Thank you very much for your reply to my R2WinBUGS query. As requested, I am attaching the following files to this e-mail: 1) The .odc file containing the WinBUGS code I am trying to run from R. The nodes to be monitored for posterior inference are: T, best, d, lor, mu, or and p. 2) The .R file containing the call to the bugs() function in the package R2WinBUGS. 3) The .bug file containing the model specification used when calling bugs(). Please note that I have tried to specify the initial values of the parameters using a list rather than a function (as suggested by Peter Alspach), and got the following error message: Error in bugs(data, inits, model.file = "model.bug", parameters = c("T", : Number of initialized chains (length(inits)) != n.chains Many thanks for any insight you may be able to provide into why the call to R2WinBUGS breaks down. In case this may be needed, I am using R 2.6.2 and WinBUGS 1.4. Kind regards, Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [1]isabella at ghement.ca Web: [2]www.ghement.ca On Wed , Ben Bolker sent: ghement.ca> writes: > > > Hello, > > I am trying to use R2WinBUGS to conduct a mixed treatment comparison (MTC) > analysis. > Thank you in advance for any help you may be able to provide! > Can you please provide your model.bug file? Ben Bolker ______________________________________________ R[3]-help at r-project.org mailing list [4]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [5]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. References 1. mailto:isabella at ghement.ca 2. http://www.ghement.ca/ 3. javascript:top.opencompose('-help at r-project.org','','','') 4. file://localhost/tmp/parse.php?redirect=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help 5. file://localhost/tmp/parse.php?redirect=http%3A%2F%2Fwww.R-project.org%2Fposting-guide.html
Hello, Further to my previous e-mail, I think I know why I am having problems with the initialization of model parameters in R2WinBUGS. My model.bug file contains a portion of code which defines some pairwise odds ratios (e.g., or[1,2], or[1,3], or[1,4], or[2,3], or[2,4], or[3,4]) as seen below: for (c in 1:(NT-1)) { for (k in (c+1):NT) { or[c,k] <- log(d[k] - d[c]) } } Apparently, R2WinBUGS can't recognize these values because they form an incomplete matrix. In trying to solve this issue, I arrived at the conclusion that R2WinBUGS may not be able to recognize WinBUGS parameters specified as a matrix (be it complete or incomplete). Is my understanding correct? Any thoughts on how to overcome this predicament would be greatly appreciated. (Thank you very much to Peter Alspach for helping me to narrow down this problem.) Many thanks! Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [1]isabella at ghement.ca Web: [2]www.ghement.ca References 1. mailto:isabella at ghement.ca 2. http://www.ghement.ca/