LinZhongjun
2009-Oct-08 19:18 UTC
[R] run WinBUGS under R, and kept getting the error message
Dear R help lists, Hello! I ran WinBUGS under R using the function bugs, but I kept getting the following error message. Error in FUN(X[[3L]], ...) : .C(..): 'type' must be "real" for this format I can not find the reason. I am freaking out. Could any one have a look at the model codes and R codes, and help me with it? Model codes: model { for( i in 1:N) { r[i]~dbin(p[i],n[i]) beta~dnorm(0,1.0E-4) logit(p[i])<-beta+gamm1*x[i,1]+gamm2*x[i,2]+gamm3*x[i,3]) } gamm1~dnorm(0,tau1) tau1~dgamma(1.0E-3,1.0E-3) gamm2~dnorm(0,tau2) tau2~dgamma(1.0E-3,1.0E-3) gamm3~dnorm(0,tau3) tau3~dgamma(1.0E-3,1.0E-3) } R codes: x<- read.table ("C:\\Documents and Settings\\zhong\\Desktop\\bino\\gen.csv", sep=",",header=TRUE) y<-read.table("C:\\Documents and Settings\\zhong\\Desktop\\bino\\phe.csv",sep=",",header=TRUE) library(R2WinBUGS) N <- nrow(x) n<-y$n r<-y$r data <- list ("n","r","x","N") inits <- function(){list(gamm1=0,gamm2=0,gamm3=0,tau1=1,tau2=1, tau3=1,beta=0)} parameters <- c("gamm","tau") logit.sim <- bugs (data, inits, parameters,"bino.model.txt", n.chains=1, n.iter=1000,debug=TRUE) print(logit.sim) plot(logit.sim) attach.bugs(logit.sim) _________________________________________________________________ ÐÄÌø¶·µØÖ÷аæÌåÑ飬¸øÄã360¶ÈµÄÐÄÌøÌåÑ飡 [[alternative HTML version deleted]]