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
Julian Reif <[email protected]>
To
[email protected]
Subject
Re: st: GMM with 93+ regressors produces error
Date
Sat, 26 Feb 2011 17:46:05 -0600
On Feb 26, 2011, at 3:34 PM, Stas Kolenikov wrote:
> This is not the limits of -gmm- issue, but that of perfect
> collinearity. You have 93 groups, you generate 93 dummies, and you
> still add {b0} on top of that. That ain't gonna be identified, sorry.
> Dropping one variable should've given that away. No limits for -gmm-
> are reported in -help limits-, although I would suspect that with
> complicated expressions you might start hitting the limits on the # of
> literals or operators in your expressions. (Some of my calls to -gmm-,
> collected via cycles in local macros, expand to eight or so lines, but
> still run.)
No, I used -xi- to create the dummy variables and it automatically omits one dummy to prevent that collinearity issue (unless one specifies the noomit option). You can see that collinearity is not the issue here by changing the line -set obs 93- to -set obs 92-; there is no error then:
--------------
--------------
clear all
set seed 38
set obs 92
gen id = _n
expand 10
gen lhs = uniform() < 0.5
xi I.id
* These two commands produce the same coefficient estimates
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) ))
On Feb 26, 2011, at 4:51 PM, Brian P. Poi wrote:
> 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.
Thanks Brian, I will try using the function evaluator program.
Julian
On Feb 26, 2011, at 3:34 PM, Stas Kolenikov wrote:
> This is not the limits of -gmm- issue, but that of perfect
> collinearity. You have 93 groups, you generate 93 dummies, and you
> still add {b0} on top of that. That ain't gonna be identified, sorry.
> Dropping one variable should've given that away. No limits for -gmm-
> are reported in -help limits-, although I would suspect that with
> complicated expressions you might start hitting the limits on the # of
> literals or operators in your expressions. (Some of my calls to -gmm-,
> collected via cycles in local macros, expand to eight or so lines, but
> still run.)
>
> On Sat, Feb 26, 2011 at 4:08 PM, Julian Reif <[email protected]> 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
>> *
>> * 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/
>>
>
>
>
> --
> Stas Kolenikov, also found at http://stas.kolenikov.name
> Small print: I use this email account for mailing lists only.
>
> *
> * 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/
*
* 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/