[R] Timer on a function
Bert Gunter
gunter.berton at gene.com
Thu Mar 15 23:05:06 CET 2012
On Thu, Mar 15, 2012 at 2:24 PM, Ramiro Barrantes
<ramiro at precisionbioassay.com> wrote:
> Hello,
>
> I have a program that consists of a loop fitting a function over many models. Sometimes the fitting on a particular model takes minutes to converge. Is there a way that I can limit the amount of time that R spends on a given model:
AFAIK, no -- this is an OS level issue.
Of course, most iterative fitting procedures have controls for the
number of iterations, convergence criteria, etc. , but there is no
awareness of timing except when the OS is interrogated, e.g. by
?proc.time or ?system.time . Such calls would have to be built into
the fitting function or OS level services would have to be invoked to
run the R process with timing limitations built in. See e.g. ?Rscript
for one possible approach.
Corrections or clever tricks to get around these perceived limitations
welcomed, of course.
-- Bert
Cheers,
Bert
>
> say if my line is:
>
> fittingFunction( func, model.1)
>
> can I have some function:
>
> stopIfUnderTime( fittingFunction( func, model.1) , 5 )
>
> where stopIfUnderTime will return the result if it finishes under 5 seconds, or NA otherwise.
>
> Is there anything like this? (just looked through the web but did not find anything)
>
> Thanks,
> Ramiro
>
>
>
> [[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
More information about the R-help
mailing list