Hi, I am new to R, and am working on some optimization problems - I was wondering if there was a way that I could show all the iterations in R -i.e. showing for each iteration, what the iteration is, how much the function is, what the norm of the gradient would be... Any help is greatly appreciated! thank you!! -- View this message in context: http://r.789695.n4.nabble.com/how-to-show-iterations-tp4646133.html Sent from the R help mailing list archive at Nabble.com.
If you are writing the loop yourself, you can use print() statements in the loop. If you are using something like optim(), have a look at the documentation and use the trace option under the control argument. Otherwise, put a print statement in the function you are passing to optim. If this fails you can try to edit the default optimization function with fix() to add a print statement where you want it, if the documentation shows that a trace argument is not already built in. Otherwise be more specific with your question please, e.g. include example code. To combine text and the values of object in an print statement, use paste().> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of sffarooqi > Sent: Sunday, October 14, 2012 17:36 > To: r-help at r-project.org > Subject: [R] how to show iterations > > Hi, > I am new to R, and am working on some optimization problems - I was > wondering if there was a way that I could show all the iterations in R -i.e. > showing for each iteration, what the iteration is, how much the function is, > what the norm of the gradient would be... > Any help is greatly appreciated! > thank you!! > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-show- > iterations-tp4646133.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Optimization is not something "R" does... this is something implemented by specific functions that may be in the base install or in add-on packages, but you have not indicated how you are currently approaching your problem. If you are using the optim() function, then I refer you to the fine manual under the control argument. Type ?optim at the R command line. For advice on how to communicate clearly on the topic of R, I recommend that you also read http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example before posting again. On Sun, 14 Oct 2012, sffarooqi wrote:> Hi, > I am new to R, and am working on some optimization problems - I was > wondering if there was a way that I could show all the iterations in R -i.e. > showing for each iteration, what the iteration is, how much the function is, > what the norm of the gradient would be... > Any help is greatly appreciated! > thank you!! > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-show-iterations-tp4646133.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >--------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
The following shows how to use trace() to track and store information about evaluations of the objective function: https://stat.ethz.ch/pipermail/r-help/2010-September/252790.html 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 sffarooqi > Sent: Sunday, October 14, 2012 7:36 AM > To: r-help at r-project.org > Subject: [R] how to show iterations > > Hi, > I am new to R, and am working on some optimization problems - I was > wondering if there was a way that I could show all the iterations in R -i.e. > showing for each iteration, what the iteration is, how much the function is, > what the norm of the gradient would be... > Any help is greatly appreciated! > thank you!! > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-show-iterations- > tp4646133.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.