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 generate equationsHi, I'm creating a new dummy variable such that a = b/c if d = chocolates or sweets, else a = b*c. …
qregpd application explanationDear all, I am attempting to estimate the effect of temperature and precipitation (at the district …
Summary Statistics for Categorical VariablesDear Statalist, I used the following command Code: sum influenced ibn.size and was wondering if …
Pooled Panel or Cross Sectional DataGood Morning I have a query regarding a data set I am handling. I am trying to see the out-migration…
could not calculate numerical derivatives -- flat or discontinuous region encounteredDear all, I am trying to run the stochastic frontier model based on Battese and Coelli (1995), whic…
Subscribe to:
Post Comments (Atom)
0 Response to performance comparison between NLS and GMM
Post a Comment