Hello,
In the last few weeks I have compared the performance of the -nl and -gmm commands since I am working with nonlinear functional forms. I have been dealing with one issue for a couple of days now and cannot get around it. I would appreciate your help.
The example I use is based on the manual entry on the use of the -gmm command for exponential regression model with panel data and exogenous regressors. It considers multiplicative fixed effects so the equation to be estimated is:
y_it = exp(x_it' b + n_i) + err_it
where x_it is a vector of k explanatory variables and n_i are the individual fixed effects. The manual provides the program to estimate the model by GMM. I tried to write a program to estimate the same model using NLS. Setting k=3, the two programs are:
*GMM program - from manual:
program gmm_poi
version 11
syntax varlist if, at(name)
tempvar mu mubar ybar
qui gen double `mu' = exp(x1*`at'[1,1] + x2*`at'[1,2] + x3*`at'[1,3]) `if'
qui egen double `mubar' = mean(`mu') `if', by(id)
qui egen double `ybar' = mean(y) `if', by(id)
replace `varlist' = y - `mu'*`ybar'/`mubar' `if'
end
*NLS program:
program nlpoi
version 11
syntax varlist(min=1 max=1) if, at(name)
local depvar `varlist'
tempvar mu mubar ybar
qui gen double `mu' = exp(x1*`at'[1,1] + x2*`at'[1,2] + x3*`at'[1,3]) `if'
egen double `mubar' = mean(`mu') `if', by(id)
egen double `ybar' = mean(`depvar') `if', by(id)
replace `depvar' = `mu'*`ybar'/`mubar' `if'
end
However, when I run the code, I get an error message for NLS (while GMM does work). In the command line:
*data:
use http://www.stata-press.com/data/r11/poisson1 , clear
*gmm - FE:
gmm gmm_poi, nequations(1) parameters(b1 b2 b3) instruments(x1 x2 x3, noconstant) onestep
*NLS -FE:
nl poi @ y , parameters(b1 b2 b3)
I cannot figure out why this is a problem for NLS. When I simplify the NLS code to take out the fixed effects, the program runs well.
Best wishes,
Paulo
Related Posts with performance comparison between NLS and GMM
How to change the values of timer in the unit of hours rather than the seconds?The output of command timer is in the unit of seconds, how to cite it and display the duration in se…
treatment effects regression adjustmentsHello everyone, I am working on the treatment effects regression adjustments (treatment variable is…
Problem Collapsing DataHello All, I have a panel dataset with 28 years and several U.S. states. Currently, I am trying to …
weak instrumentshello, I estimate a model with the command ivregress 2sls. I have two endogenous variables. Can I co…
How to obtain Wald chi-square from running logistic regressions?Hello statalists, I was an SPSS user and switched to STATA a couple years ago. I have a question ab…
Subscribe to:
Post Comments (Atom)
0 Response to performance comparison between NLS and GMM
Post a Comment