[R] Can I monitor the iterative/convergence process while using Optim or MaxLik?

Greg Snow Greg.Snow at imail.org
Tue Sep 14 22:26:25 CEST 2010


The simple way to do this is just to rewrite your function to be optimized to print out the current values that it was called with, this way you will see where it is and what it is doing.  Look at the cat function for how to print the values, also look at the flush.console function.

For example you could take the 1st example on the optim help page and insert the following 2 lines as the 1st 2 lines of the f function:

cat(x, '\n')
flush.console()

and then at each iteration you can see the values tried.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Sally Luo
> Sent: Tuesday, September 14, 2010 1:50 PM
> To: r-help at r-project.org
> Subject: [R] Can I monitor the iterative/convergence process while
> using Optim or MaxLik?
> 
> Hi R-helpers,
> 
> Is it possible that I have the estimates from each step/iteration shown
> on
> the computer screen in order to monitor the process while I am using
> Optim
> or MaxLik?
> 
> Thanks for your help.
> 
> Maomao
> 
> 	[[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.



More information about the R-help mailing list