An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121212/3c8ad28b/attachment.pl>
Running MCMC in R
5 messages · Chenyi Pan, Whit Armstrong, Bert Gunter +2 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121213/9063c193/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121213/08606493/attachment.pl>
I am now running a MCMC iteration in the R program. But it is always stucked in some loop.
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
So I want to know whether we can skip the current dataset and move to next simulated data when the iteration is stucked?
Yes, though the method of doing so will depend entirely on which function and which package you are using. and
Alternatively, can the MCMC chain skip the current iteration when it is stucked and automatically to start another chain with different starting values.
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
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Bert Gunter Sent: Thursday, December 13, 2012 6:21 AM To: Chenyi Pan Cc: R-help at 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 <cp2xd at 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 at 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 at 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.