Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomation of WinBUGS from R
    primarykey
    data
    text
    <p>I have a question related to the R Code which calls BUGS. I have run the model in WinBUGS and it runs fine giving me the expected results. Below is the automation code used when I had single outcome or univariate data for Y’s. Now I want to use it for multiple outcomes. I tried a different way of reading the data. There are 2 simulations for testing which are read from csv files.Not sure where to specify in the code so that the same process can be repeated for 2 outcomes instead of one. setwd("C://Tina/USB_Backup_042213/Testing/CSV")</p> <pre><code> matrix=NULL csvs &lt;- paste("MVN", 1:2, ".csv", sep="") for(i in 1:length(csvs)){ matrix[[i]] &lt;- read.csv(file=csvs[i], header=T) print(matrix[[i]]) } Y1 Y2 1 11 6 2 8 5 3 25 13 4 1 13 5 8 22 Y1 Y2 1 9 1 2 7 9 3 25 13 4 1 18 5 9 12 library("R2WinBUGS") bugs.output &lt;- list() for(sim in 1:2){ Y &lt;-(matrix[[sim]]) bugs.output[sim] &lt;- bugs( data=list(Y=as.matrix(Y), Nf=5, n=60, mn=c(-1.59, -2.44), prec=matrix(c(.0001,0,0,.0001),nrow=2,ncol=2), R=matrix(c(.001,0,0,.001),nrow=2,ncol=2)), inits=list(list(gamma=c(0,0), T=matrix(c(0.9,0,0,0.9),nrow=2,ncol=2))), model.file="M-LN_model_trial.txt", parameters.to.save = c("p","rho","sigma2"), n.chains=1, n.iter=12000, n.burnin=5000, debug=TRUE, bugs.directory="C://Tina/USB_Backup_042213/winbugs14/WinBUGS14", working.directory=NULL) } </code></pre> <p>Warning messages: 1: In bugs.output[sim] &lt;- bugs(data = list(Y = as.matrix(Y), Nf = 5, : number of items to replace is not a multiple of replacement length 2: In bugs.output[sim] &lt;- bugs(data = list(Y = as.matrix(Y), Nf = 5, : number of items to replace is not a multiple of replacement length</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload