Skip to content

Running MCMC in R

5 messages · Chenyi Pan, Whit Armstrong, Bert Gunter +2 more

#
I never like it when folk just say "Please read and follow the posting guide referenced in every R help email" but ... please, read and follow the posting guide referenced in every R help email if you want any useful kind of answer.

In the mean time, it would have helped a lot to say
i) Is this a problem in your own code or in a contributed or core package?
ii) If not your own, in which package and which function?
iii) What does 'stuck' mean? Failing to converge (and according to what criterion)? Failing to complete a prescribed number of iterations? Failing to start? 

and also if you could have provided data and an example that would let someone see what is going on instead of trying to guess.

Failing that, however, the answers to your questions are
Yes, though the method of doing so will depend entirely on which function and which package you are using.

and
Possibly, though the method of doing so will depend entirely on which function and which package you are using.

S

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
#
And if by "stuck" you mean "taking too long a time" you can generate an error at a given
time limit by using setTimeLimit() and tryCatch() or try() can catch that error. E.g.

   > timeOut <- function (expr, cpu = Inf, elapsed = Inf) 
   {
       setTimeLimit(cpu = cpu, elapsed = elapsed, transient = TRUE)
       on.exit(setTimeLimit()) # should not be needed, but averts future error message
       expr
   }
   > timeOut({s<-0 ; for(i in 1:1e7)s <- s + 1/i ; s}, elapsed=1)
   Error: reached elapsed time limit
   > timeOut({s<-0 ; for(i in 1:1e7)s <- s + 1/i ; s}, elapsed=10) # log(1e7) + gamma
   [1] 16.69531
   > tryCatch(timeOut({s<-0 ; for(i in 1:1e7)s <- s + 1/i ; s}, elapsed=1),
   +          error = function(e) NA_real_)
   [1] NA

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com