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
Creating a new variable by using a string variable in STATAFor example, X is a variable X 123 234 35 67 82 Now the values are saved as strings. If I want to cr…
Logit model: how to interpret negative AMEs?Dear Statalist, I am using Stata 15.1 with Windows 10. I have a logit model on cross-border deals i…
Store variable names for specific conditionHi all, I wonder if its possible save or store a list of variable names with a specific condition, …
Endogenous Explanatory Variable in a Multinomial Logit EstimationHi Statalist I am wondering what are the possible options for modelling endogeneity in a multinomia…
egen newvar = divide(existingvar), by(existingvar2)Hi! I know how to perform : Code: egen v5 = sum(var4), by(var1) var1 var4 v5 1 301 4323 1 4…
Subscribe to:
Post Comments (Atom)
0 Response to GMM estimation inside a do loop with foreach
Post a Comment