Hi All:

Not sure why my previous question never got posted. Here I am seeking some
help on my code. I am using the following code to run MCMC simulation on
the following data using the model below:
# Data
matrix<-NULL
> csvs<-paste("MVN", 1:2,".csv",sep="")
> for (i in 1:length(csvs)){
+ matrix[[i]]<- read.csv(file=csvs[i],header=TRUE)
+ 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
#Model
model
{
 for (j in 1 : Nf)

  {
  p1[j, 1:2 ] ~ dmnorm(gamma[1:2], T[1:2 ,1:2])
# T is the precision matrix or inverse sigma for MVN

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

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

 }


  }
# Hyper-priors:

 gamma[1:2] ~ dmnorm(mn[1:2],prec[1:2 ,1:2])
mn<-c(-1.59,-2.44)
prec<-structure(.Data = c(.001,0,0,.001),.Dim = c(2, 2))
expit[1]<-exp(gamma[1])/(1+exp(gamma[1]))
expit[2]<-exp(gamma[2])/(1+exp(gamma[2]))
  T[1:2 ,1:2] ~ dwish(R[1:2 ,1:2], 2)
 sigma2[1:2, 1:2] <-inverse(T[,])
 rho <- sigma2[1,2]/sqrt(sigma2[1,1]*sigma2[2,2])
R<-structure(.Data = c(.001,0,0,.001),.Dim = c(2, 2))
 }

# R2WinBUGS code to run MCMC
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
       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

Thanks for your help.
Anamika

        [[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.

Reply via email to