[R] Problems with R2WinBUGS

From: <isabella_at_ghement.ca>
Date: Wed, 16 Apr 2008 18:32:49 -0500

   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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 17 Apr 2008 - 01:07:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Apr 2008 - 22:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive