Hello, I am performing Newton Raphson iteration where the parameter vector which I want to optimize is an *nx1* vector. I am running a while loop which will continue unless a stopping condition is satisfied Now, the stopping condition will have to be such that the parameter vector after two successive iterations are very close to each other,*component wise*. I have tried the* all* function, in which case the number of iterations are enormous. Is there any better way to do this? Thanking all in advance, Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/comparing-two-vectors-tp4651282.html Sent from the R help mailing list archive at Nabble.com.
On 29-11-2012, at 14:28, soham chakraborty wrote:> Hello, > I am performing Newton Raphson iteration where the parameter vector which I > want to optimize is an *nx1* vector.Are you trying to solve a system of nonlinear equations? Have a look at package nleqslv. Are you max-/min-imizing a function? Look at R provided functions such as optim, nlminb and the CRAN Optimizing Task View.> I am running a while loop which will continue unless a stopping condition is > satisfied > Now, the stopping condition will have to be such that the parameter vector > after two successive iterations are very close to each other,*component > wise*. > I have tried the* all* function, in which case the number of iterations are > enormous. > Is there any better way to do this?How have you been using all()? Berend
Berend, I am working with a time series data.The log-likelihood is to be maximized for a set of parameters. Lets say that x1 and x2 are the output from two successive iterations.I am trying to find out, *if(all(abs(x1-x2)<.0001,say))* -- View this message in context: http://r.789695.n4.nabble.com/comparing-two-vectors-tp4651282p4651760.html Sent from the R help mailing list archive at Nabble.com.
On 03-12-2012, at 08:01, soham chakraborty wrote:> Berend, > I am working with a time series data.The log-likelihood is to be maximized > for a set of parameters. > Lets say that x1 and x2 are the output from two successive iterations.I am > trying to find out, > *if(all(abs(x1-x2)<.0001,say))* >You are posting from Nabble. Please do not boldify code. In the real R-help mailing list bold tags are converted to *. Your code becomes unreadable. What is the "say" doing here: if(all(abs(x1-x2)<.0001,say)) This should be if(all(abs(x1-x2)<.0001)) Without a reproducible example it is impossible to give an answer. Follow these instructions:> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.Berend> > > > -- > View this message in context: http://r.789695.n4.nabble.com/comparing-two-vectors-tp4651282p4651760.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.