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 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Bert Gunter > Sent: Thursday, December 13, 2012 6:21 AM > To: Chenyi Pan > Cc: R-help@r-project.org > Subject: Re: [R] Running MCMC in R > > ?try > ?tryCatch > > (if the suggestion to use an MCMC package does not fix your problem). > > -- Bert > > On Wed, Dec 12, 2012 at 7:49 PM, Chenyi Pan <cp...@virginia.edu> wrote: > > > Dear all > > I am now running a MCMC iteration in the R program. But it is always > > stucked in some loop. This cause big problems for my research. So I want to > > know whether we can skip the current dataset and move to next simulated > > data when the iteration is stucked? Alternatively, can the MCMC chain skip > > the current iteration when it is stucked and automatically to start another > > chain with different starting values. > > > > I am looking forward to your reply. > > > > Best, > > Chenyi > > > > -- > > Chenyi Pan > > Department of Statisitics > > Graduate School of Arts and Sciences, University of Virginia > > Tel: 434-466-9209 > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > -- > > Bert Gunter > Genentech Nonclinical Biostatistics > > Internal Contact Info: > Phone: 467-7374 > Website: > http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb- > biostatistics/pdb-ncb-home.htm > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.