[S] MCMC error message

Xu Fan (fan@stat.cmu.edu)
Sat, 9 May 1998 21:33:01 -0400


The MCMC (an iterational simulation) breaks with error message (see below).
Can anyone tell me the reason?

#1 error message
#2 codes

#1 error message
31962
31963
31964
31965
Error: Missing value where logical needed: if(r > u) {
Beta[, i + 1] <- candidate
. . .

#2 codes
date()

# MCMC for Beta
date()

N <- 100000
options(object.size=1e8)
Beta <- matrix(0, 10, N)
sigma <- 0.5
accept <- rep(0, N)

for (i in 1:(N-1)){
candidate <- rnorm(10, Beta[,i], sigma)
r <- lik(choice.1, candidate) / lik(choice.1, Beta[,i])

u <- runif(1)

if (r > u){
Beta[,i+1] <- candidate
accept[i] <- 1
}
else
Beta[,i+1] <- Beta[,i]

cat(i, "\n")
}

date()

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news