Dear Friends,
I am trying to use GMM to estimate a model that is nonlinear in its parameters.
The model has 3 parameters: rho, sigma1, and sigma2.
I would like to obtain model coefficients, standard errors, and the value of the objective function for different combinations of starting values.
To accomplish this, I set up three do loops, one within the other, and let rho vary according the counter "j", sigma1 vary according to the counter, "k", and sigma2 vary according to the counter "l."
The code is below. The code works. However, I have two questions:
a. How can I get the values of j,k, and l to be displayed after each step in the loop
For example, when I include display j, in the code below, I get "j not found" and the program exits.
b. Sometimes, GMM does not converge and I get the following message, "flat or discontinuous region encountered" and the program exits the do loop. Is there some way I can include
a line which causes the program to go to the next loop increment, rather than exiting the program? In fortran, I could do this with an error handling condition.
Thanks so much!
Srinivasan Rangan
Code:
foreach j in 0.1 0.2 0.3 0.4 0.5 {
foreach k in 5 10 {
foreach l in 5 10 {
gmm (Eq1:abn_ret2_unwinsored_stage1_w - (1 + {rho}*{sigma1})*ue_p_scaled_centered_w - ({sigma2})*(sqrt(1-{rho}^2))*tq2_w_centered) if sample_to_use == 3, instruments(ue_p_scaled_centered_w tq2_centered_w lag2mret_w lag2chusd_w) winitial(identity) vce(cluster cnum) from(rho `j' sigma1 `k' sigma2 `l') technique(bfgs) wmatrix(unadjusted)
mat list e(b)
mat list e(V)
display e(Q)
}
}
}
Related Posts with GMM estimation inside a do loop with foreach
merge command in a loopHello! I have a dataset that I want to merge with a sequence of files that correspond to individual…
egen var1= count(var), by(id quarter) - generating missing valuesHello, I have a dataset which is organised by id and quarter. I want to create a variable, based on…
Databases mergeHi all, so, this is a quite border line question. Hence, sorry if it is out of topic a bit. The de…
Coding a new categorical variable based on an existing categorical variableHi Statalist. I would like to create a few groups based on some of the categories of an existing va…
egen command is only generating missingsHello, i used the egen in previous data anlysis and it worked pretty well. The code looked somehti…
Subscribe to:
Post Comments (Atom)
0 Response to GMM estimation inside a do loop with foreach
Post a Comment