Several problems:

1. You havbe an object called "matrix", that actually is a list of two data.frames. WinBUGS does not know about data,frames. You have to provide a matrix here, hence

bugs(....., data=list(Y=as.matrix(Y), Nf=5, ....), ....)


2. In your model file, you have

gamma[1:2 ]
T[1:2 ,1:2 ])
n
an others, all of which need to be passed to WinBUGS as data. I do not see a dingle of these objects to be defined anywhere.

3. Then you have

  parameters.to.save = c("p","rho","sigma2")
but these are not mentioned in the model file,

So this is rather hopeless. My suggestion is to seek advice from a local BUGS expert or from the BUGS mailing list.

You should start to develop your model in BUSG directly, since the R interface is nice for automation, but not for model building, since you do not see the error messages as directly as in WinBUGS/OpenBUGS yourself.


Best,
uwe ligges





On 16.07.2013 17:52, Anamika Chaudhuri wrote:
Hi All:
I am getting an error (highlighted) from running R2WinBUGS in R.
To be able to replicate the situation heres the code:
.#Set working directory
setwd("H://AChaudhuri/Testing/CSVS")
matrix=NULL
csvs <- paste("MVN", 1:2, ".csv", sep="")
for(i in 1:length(csvs)){
   matrix[[i]] <- read.csv(file=csvs[i], header=T)
   print(matrix[[i]])
}

So now I have read in 2 simulated datasets which  look like
  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

My next step is to run a multivariate logit normal model on these datasets
and automate this process for such simulated datasets. Heres the model
statement:
model
  {
   for (j in 1 : Nf)

       {
       p1[j, 1:2 ] ~ dmnorm(gamma[1:2 ], T[1:2 ,1:2 ])

       for (i in 1:2)
       {
      logit(p[j,i])<-p1[j,i]

      Y[j,i] ~ dbin(p[j,i],n)
}}

I am trying to use the following code to run it in R
library("R2WinBUGS")
bugs.output <- list()
for(i in 1:2){

        Y <-(matrix[i])

        bugs.output[[i]] <- bugs(
        data=list(Y=Y, Nf=5), # change for no of sites
     inits=NULL,
        model.file="M-LN_model_trial.txt",
        parameters.to.save = c("p","rho","sigma2"),
n.chains=1, n.iter=12000, n.burnin=5000,
bugs.directory="H://AChaudhuri/winbugs14/WinBUGS14",
working.directory=NULL)}


Error in FUN(X[[1L]], ...) :

   .C(..): 'type' must be "real" for this format

Any suggestion would be helpful.
Thanks!

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.


______________________________________________
R-help@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.

Reply via email to