Dear all,

 

When I do analysis, I have troubled with frequent pop up message:

This chains contains uninitialized variables and the trap report says "
undefined real result"

 

I am looking for your courage and help to continue my further analysis.

 

model{

for (j in 1:2160) {

y[j] ~ dpois(mu[j])

log(mu[j]) <- log(e[districts[j]]) + alpha + beta1*x1[j] + beta2*x2[j] +
beta3*x3[j] + beta4* x4[j] +

             beta5*x5[j] + beta6*x6[j] + beta7*x7[j] + beta8*x8[j] +
phi[districts[j]]+ delta[time[j]] + omega[time[j]]

rho[j]<-exp(alpha + beta1*x1[j] + beta2*x2[j] + beta3*x3[j] + beta4* x4[j] +


           beta5*x5[j] + beta6*x6[j] + beta7*x7[j] + beta8*x8[j] +
phi[districts[j]] + delta[time[j]] + omega[time[j]])
# RR               

}

 

for (i in 1:18) {

e[i] ~ dnorm(0,sigma.e)

phi[i] ~ dnorm(0,tau.phi)                                             

}

 

delta[1]<-0

omega[1] ~ dnorm(0,tau.omega1)
# Adjusted RR in month 1 over all districts/years

for (t in 2:120){

delta[t] ~ dnorm(0,tau.delta)

omega[t] ~ dnorm(omega[t-1],tau.omega)

}

 

#PRIORS

tau.e ~ dgamma(0.001,0.001)

alpha ~ dflat()

beta1 ~ dgamma(1,1)

beta2 ~ dgamma(1,1)

beta3 ~ dgamma(1,1)

beta4 ~ dgamma(1,1)

beta5 ~ dgamma(1,1)

beta6 ~ dgamma(1,1)

beta7 ~ dgamma(1,1)

beta8 ~ dgamma(1,1)

tau.phi ~ dgamma(1,1)

tau.delta ~ dgamma(1,1)

tau.omega1 ~ dgamma(1,1)

tau.omega ~ dgamma(0.001,  0.001)

sigma.e <- 1/sqrt(tau.e)

sigma.phi <- sqrt(1/tau.phi)

sigma.omega1 <- sqrt(1/tau.omega1)

sigma.delta <- sqrt(1/tau.delta) 

sigma.omega <- sqrt(1/tau.omega) 

}

 

#R script to call R2WinBUGS and plot density

 

# Define the dataset

 

library("R2WinBUGS")

library(help="BRugs")

library(help="R2WinBUGS")

data1<-read.csv(file.choose("Data1.csv"), header=TRUE, sep=(","))

 

names(data1)

districslist<-as.data.frame(unique(data1$districts))

data2<-as.data.frame(cbind((1:18),districslist))

names(data2)<-c("D_ID","districts")

data3<-merge(data1, data2,by="districts")

data3<-as.data.frame(data3)

names(data3)

 

data6<-NULL

for (i in 1:18){ 

data4<-data3[data3$D_ID==i,]

data5<-cbind(data4,seq(1,length(data4[,1]),by=1))

data6<-rbind(data6,data5)

}

districts<-data6[,13]

time<- data6[,14]

y<- data1$y

x1<- data1$x1

x2<- data1$x2

x3<- data1$x3

x4<- data1$x4

x5<- data1$x5

x6<- data1$x6

x7<- data1$x7

x8<- data1$x8

data <- list(districts=districts,time=time,
y=y,x1=x1,x2=x2,x3=x3,x4=x4,x5=x5,x6=x6,x7=x7,x8=x8)

 

# Define inits

 

inits <- function(){

list(tau.e=dgamma(1,5, 10), alpha = dnorm(1,1, 1), beta1 = dgamma(1,5,10),
beta2 = dgamma(1,5,10),

beta3 = dgamma(1,5,10), beta4 = dgamma(1,5,10), beta5 = dgamma(1,5,10), 

beta6 = dgamma(1,5,10), beta7 = dgamma(1,5,10), beta8 = dgamma(1,5,10),

tau.phi=dgamma(1,5,10), tau.delta=dgamma(1,5,10), 

tau.omega=dgamma(1,5,10), tau.omega1=dgamma(1,5,10))

}

 

# run the MCMC analysis

 

model_G<- bugs(data, inits, model.file = "C:/model_G.txt",

parameters = c("tau.e", "alpha", "beta1", "beta2", "beta3", "beta4",
"beta5", "beta6", "beta7", "beta8", "tau.phi", "tau.delta", "tau.omega1",
"tau.omega"),

n.chains = 3, n.iter = 2000, n.burnin=500,bugs.directory = "C:/Program
Files/WinBUGS14/",

working.directory=NULL, WINE=NULL, debug=TRUE)

 

BUT, this does not work, the log file says "this chain contains  
uninitialized variables"  and trap says " undefined real resul".
I cannot know where the problems are.
 
Thanks for your kindest help,
 
Sincerely,
 
Kassahun 

 


	[[alternative HTML version deleted]]

