Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: GMM with 93+ regressors produces error


From   "Brian P. Poi" <[email protected]>
To   [email protected]
Subject   Re: st: GMM with 93+ regressors produces error
Date   Sat, 26 Feb 2011 17:51:20 -0500


On 2/26/2011 4:08 PM, Julian Reif wrote:
Is it possible to run -gmm- with more than 92 regressors?  I encounter the error "could not evaluate equation 1" when I try to do so.  The following logit example, run on Stata 11.1, reproduces the error:

-------------------
-------------------
clear all
set seed 38
set obs 93
gen id =  _n
expand 10
gen lhs = uniform()<  0.5
xi I.id

* These two commands should produce the same coefficient estimates. -gmm- produces an error here though.
logit lhs _I*
gmm (lhs - exp({xb: _I*}+{b0})/(1+exp({xb:}+{b0}))), instruments( _I*) onestep derivative(/xb = -1*( exp({xb:}+{b0}) / ((1+exp({xb:}+{b0}))^2) ))	derivative(/b0 = -1*( exp({xb:}+{b0}) / ((1+exp({xb:}+{b0}))^2) ))

* Dropping one regressor makes error message go away
drop if id==93
drop _Iid_93
logit lhs _I*
gmm (lhs - exp({xb: _I*}+{b0})/(1+exp({xb:}+{b0}))), instruments( _I*) onestep derivative(/xb = -1*( exp({xb:}+{b0}) / ((1+exp({xb:}+{b0}))^2) ))	derivative(/b0 = -1*( exp({xb:}+{b0}) / ((1+exp({xb:}+{b0}))^2) ))



Julian
*

There is a limit to how long an expression passed to -generate- or -replace- can be, and that is what's causing the error message here. When you specify a substitutable expression with -gmm-, it substitutes your parameter names with the name of a temporary matrix and the appropriate column index. In your case, -gmm- is replacing your substitutable expression with something like

__00002X = lhs - exp( (__000006[1,1] *_Iid_2 + __000006[1,2] *_Iid_3 +
__000006[1,3] *_Iid_4 + __000006[1,4] *_Iid_5 + __000006[1,5] *_Iid_6 + __000006[1,6] *_Iid_7 + __000006[1,7] *_Iid_8 ...

where "..." is rather long in your case, __00002X happens to be the temporary variable -gmm- is using to hold the residuals and __000006 is the temporary matrix of parameters.

When I take the exact expression -gmm- is using here and try and pass it to -replace-, I get

.
. replace k = `express2'
expression too long
r(130);

In terms of -gmm-, the only solution is to write a function evaluator program instead.


   -- Brian Poi
   -- [email protected]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index