[R] Problem retrieving data from R2InBUGS

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Nov 13 18:48:09 CET 2010


This is strange and does not happen for me.

Anyway, if it is a problem at all, then I doubt it is in R2WinBUGS: 
R2WinBUGS asks WinBUGS to write the coda files and afterwards calls the 
following function

read.bugs <- function(codafiles, ...){
     if(!is.R() && !require("coda"))
         stop("package 'coda' is required to use this function")
     mcmc.list(lapply(codafiles, read.coda,
                      index.file = file.path(dirname(codafiles[1]), 
"codaIndex.txt"),
                      ...))
}

that keeps the order from the codaIndex file and just calls other 
functions such as read.coda and mcmc.list() from the coda package.

Anyway, if the problem persists for you, you may want to send me an 
example that is reproducible, i.e. including data, model files and what 
you function calls in R were ....

Best,
Uwe Ligges






On 12.11.2010 20:55, Barth B. Riley wrote:
> Dear list
>
> I am calling the functiton bugs() provided by R2WinBugs to performs an IRT analysis. The function returns a set of estimated parameters over n replications/iterations. For each replication, two sets of person measures (theta1 and theta2) and two sets of item difficulty parameters (diff1 and diff2) are returned. The code used to obtain these estimates is as follows:
>
> sim<- bugs(data,init,model.file="drift.bugs",parameters=c("theta1","theta2","diff1","diff2"),n.chains=n.chains,n.iter=n.reps,n.burnin=1000,bin=1,n.thin=1,digits=3, codaPkg=T)
> sim.list<- read.bugs(sim)
>
> However, when I read the coda files using read.bugs the order of the columns in the parameter  matrix are as follows:
>
>    [1] "deviance"    "diff1[1]"    "diff1[10]"   "diff1[100]"  "diff1[11]"   "diff1[12]"   "diff1[13]"
>     [8] "diff1[14]"   "diff1[15]"   "diff1[16]"   "diff1[17]"   "diff1[18]"   "diff1[19]"   "diff1[2]"
> ...
> ...
> .............................................................. "diff2[10]"   "diff2[100]"  "diff2[11]"
>   [106] "diff2[12]"   "diff2[13]"   "diff2[14]"   "diff2[15]"   "diff2[16]"   "diff2[17]"   "diff2[18]"
>   [113] "diff2[19]"   "diff2[2]"    "diff2[20]"   "diff2[21]"   "diff2[22]"   "diff2[23]"   "diff2[24]"
> ...
> ...
> ............................................................................. "theta1[1]"   "theta1[10]"
>   [204] "theta1[100]" "theta1[101]" "theta1[102]" "theta1[103]" "theta1[104]" "theta1[105]" "theta1[106]"
>   [211] "theta1[107]" "theta1[108]" "theta1[109]" "theta1[11]"  "theta1[110]" "theta1[111]" "theta1[112]"
>
> The columns, in other words, are not in numerical order according to the index of the item difficulty or person measure parameter. Rather they appear to be in text-sorted order (e.g., 1, 10, 100...). Any ideas as to what might be going on?
>
>
> Thanks
>
> Barth
>
> PRIVILEGED AND CONFIDENTIAL INFORMATION
> This transmittal and any attachments may contain PRIVILEGED AND
> CONFIDENTIAL information and is intended only for the use of the
> addressee. If you are not the designated recipient, or an employee
> or agent authorized to deliver such transmittals to the designated
> recipient, you are hereby notified that any dissemination,
> copying or publication of this transmittal is strictly prohibited. If
> you have received this transmittal in error, please notify us
> immediately by replying to the sender and delete this copy from your
> system. You may also call us at (309) 827-6026 for assistance.
>
> ______________________________________________
> 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.



More information about the R-help mailing list