[R] R2WinBUGS problem: bugs - storage.mode error

dhocking dhocking at unh.edu
Mon Jul 11 06:22:29 CEST 2011


Sorry for the additional post - I received the suggestion to include the
following additional information:

*> traceback()*
5: FUN(X[[12L]], ...)
4: lapply(data, formatC, digits = digits, format = "E")
3: write.datafile(lapply(data, formatC, digits = digits, format = "E"), 
       file.path(dir, data.file))
2: bugs.data(data, dir = getwd(), digits)
1: bugs(data = win.data, inits = inits, parameters.to.save = params, 
       model.file = "PoissonGLMM.txt", n.chains = nc, n.iter = ni, 
       n.burn = nb, n.thin = nt, debug = TRUE, DIC = TRUE, working.directory
= getwd())



The full code I'm trying to run using R2WinBUGS is:


S <- length(levels(plot))  # Number of sites
C <- count
nobs <- length(count)

sink("PoissonGLMM.txt")
cat("
model {

# Priors
alpha ~ dnorm(0, 1.0E-4)
for(k in 1:8){
	b[k] ~ dnorm(0, 1.0E-4)
}
fS[1] <- 0
for(j in 2:S){
	fS[j] ~ dnorm(0, 1.0E-4)
}

# Likelihood
for(i in 1:nobs){					# loop over observations
	C[i] ~ dpois(lambda[i])			# stochastic component
	log(lambda[i]) <- alpha + b[1]*cday[i] + b[2]*cday2[i] + b[3]*cSoilT[i] +
b[4]*cSoilT2[i] + b[5]*cRainAmt24[i] + b[6]*rainAmt242[i] + b[7]*soak24 +
b[8]*RHpct[i] + fS[plot[i]]
}

}
",fill=TRUE)
sink()

# Bundle data
win.data <- list(cday=cday, cday2=cday2, cSoilT=cSoilT, cSoilT2=cSoilT2,
cRainAmt24=cRainAmt24, cRainAmt242=cRainAmt242, soak24=soak24, RHpct=RHpct,
nobs=nobs, C=C, S=S, plot=plot)

# Bundle data
#win.data <- list("cday", "cday2", "cSoilT", "cSoilT2", "cRainAmt24",
"cRainAmt242", "soak24", "RHpct", "nobs", "C", "S", "plot")

# Initial Values
a.init <- rnorm(1, 0, 0.01)
b.init <- rnorm(8, 0, 0.01)
fS.init <- c(NA, rnorm(S-1, 0, 0.01))

inits <- function(){
	list(alpha = a.init, b = b.init, fS = fS.init)
}

# Parameters to estimate
params <- c("alpha", "b", "fS")

# MCMC settings
nc <- 3
nb <- 300
ni <- 1000
nt <- 5

# Start Gibbs sampler
out <- bugs(data=win.data, inits=inits, parameters.to.save=params,
model.file = "PoissonGLMM.txt", n.chains=nc, n.iter=ni, n.burn=nb,
n.thin=nt, debug=TRUE, DIC=TRUE, working.directory=getwd())

print(out, dig=2)

which(out$summary[,8] > 1.1)


--
View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-problem-bugs-storage-mode-error-tp3658622p3658674.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list