[R] a question on R optimization functions

Ravi Varadhan rvaradhan at jhmi.edu
Fri Mar 25 15:30:51 CET 2011


You might want to use `trace' and/or other debugging options to better understand when and why this happens.

Ravi.
____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Ben Bolker <bbolker at gmail.com>
Date: Friday, March 25, 2011 8:11 am
Subject: Re: [R] a question on R optimization functions
To: r-help at stat.math.ethz.ch


> Dajiang J. Liu <dajiang.liu <at> gmail.com> writes:
>  
>  > I use nlminb or optim for maximizing likelihood functions. Sometimes,
>  > the parameter values happen to be NA, then the program will hang there
>  > and iterate forever without stopping. No error message will be
>  > produced. So I can not use error catch method such as "try". Are there
>  > any suggestions how I can circumvent this problem? Maybe I can time 
> a
>  > function, and if the time exceeds a threshold, it will be stopped. 
> I
>  > am not sure if this is feasible in R. As a note, I am running
>  > simulations with thousands of replicates, so there needs to be a
>  > systematic way of doing this. Are there any suggestions on how to do
>  > this? Thank you very much!
>  
>     It would be very surprising (I suppose not impossible, but
>  *very* surprising) if this behavior were generated by R's optimization
>  functions; it would be much more likely for it to be an infinite
>  loop/hang somewhere inside your objective function.
>  
>    See ?setTimeLimit (which will fail if the problem is inside
>  C code that you have written ...)
>  
>    Ben Bolker
>  
>  ______________________________________________
>  R-help at r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list