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
moderation with quantile regressionDear all i hope you are doing good i'm working on my research paper and i want to try the moderate…
Removing Outliers Survey in Stata (For variables time)Hi guys, Appreciate any help. Basically I will want to remove outliers on certain criteria of (time …
desperately in need of helping with exporting sum stats tableI am desperately looking for the solution on exporting the summary stats tables. I typed commands as…
Clogit with Additional Dummy VariablesHi, I am estimating a non-linear model by using clogit. My group variable is "industry by year". I …
Mean of frequency from tabHello, i'm using Stata 16. I am trying to calculate the mean of the frequency values (second column…
Subscribe to:
Post Comments (Atom)
0 Response to performance comparison between NLS and GMM
Post a Comment