[R] Drop in a Loop

Olu Ola oluola2011 at yahoo.com
Tue Sep 15 21:12:13 CEST 2015

Thanks Will.
 Below is the flow of my code

Yhat is the fitted value
Errhat is the difference between the dependent variable and the yhat
gmmdata is the data name
N <- nrow(gmmdata)
B <- 1000
store <- matrix(0,B,11)
for (j in 1:B) {
  index = sample(1:N, N, replace=T)
  errnew = errhat[index]
  yt = yhat + errnew
objective function subroutine
gradient function subroutine  
gmmiv =Optimx() 
  store[j,] = coef(gmmiv)

What I want to do is that if the convergence code from optimx for a particular iteration is Not zero, then it should not be stored in store[j,].

Any help will be appreciated

Thank you

On Tue, 9/15/15, Will Hopper <wjhopper510 at gmail.com> wrote:

 Subject: Re: [R] Drop in a Loop

 Cc: r-help at r-project.org
 Date: Tuesday, September 15, 2015, 2:30 PM

 think you ought to show a small example of how the code
 you're using. Are you saving results at every iteration?
 In a list, data frame, etc? People likely need that to help
 answer your question.

  Also probably have a look the control list
 argument and the save.failures option, that might be
 something you're interested in. 

 - Will 

 On Tue, Sep 15, 2015 at
 1:34 PM, Olu Ola via R-help <r-help at r-project.org>

 I am doing some estimation using optimx and after each round
 of estimation, I store the coefficient. However, I need to
 drop the set of coefficients for which the convergence code
 in optimx is GREATER than Zero. How do I go about this?

 A way forward will be highly appreciated.

 Thank you


 R-help at r-project.org
 mailing list -- To UNSUBSCRIBE and more, see


 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

 and provide commented, minimal, self-contained, reproducible

More information about the R-help mailing list