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: using macros in -gmm-


From   Daniel Borowczyk Martins <[email protected]>
To   [email protected]
Subject   Re: st: using macros in -gmm-
Date   Wed, 10 Aug 2011 13:44:38 +0100

Thanks, Scott.
You're right. It work is fine.
I wasn't running the locals and the -gmm- syntax in one go, so the
locals weren't recognized in when I later tried to run the -gmm- bit.
Thanks again,
Daniel

On Wed, Aug 10, 2011 at 1:10 PM, Scott Merryman
<[email protected]> wrote:
> This works:
>
> sysuse sp500,clear
> tsset date
> local first = 1
> local last = 3
> gmm (close- {b0}- {b1}*volume), instruments(l(`first'/`last').volume)
>
> local regressor "volume"
> gmm (close- {b0}- {b1}*volume), instruments(l(`first'/`last').`regressor')
>
> Perhaps, -set trace on- will help locate the problem.
>
> Scott
>
>
> On Wed, Aug 10, 2011 at 6:38 AM, Daniel Borowczyk Martins
> <[email protected]> wrote:
>> Dear stata users,
>>
>> I am unable to male use of macros with the -gmm- stata command.
>>
>> Here's an example.
>>
>> 1. Take a cross section data set with variables y and x.
>> 2. I want to estimate an IV regression on the model "y constant x"
>> 3. x is endogenous.
>> 4. I use lags of x to instrument it. I define the  first and last lags
>> of the instrument set as two macros.
>>
>> local first = 1
>> local last = 3
>>
>> gmm (y - {b0} - {b1}*x1), instruments(l(`first'/`last').x1)
>>
>> I get the following error "l(`first'/`last') numlist in operator invalid"
>>
>> I tried with scalar rather than local and the same problem arises.
>>
>> However, typing
>>
>> gmm (y - {b0} - {b1}x1), instruments(l(1/3).x1)
>>
>> works fine.
>>
>> Now, if I define x1 as a local, we can see that -gmm- doesn't "read" macros.
>>
>> local regressor "x1"
>>
>> gmm (y - {b0} - {b1}*x1), instruments(l(1/3).`regressor')
>>
>> I get the following message "Model not identified. There are more
>> parameters than instruments".
>>
>> Is there anyway to circumvent this problem? I want to embed
>> estimations using -gmm- in a dofile that works with several locals....
>>
>> Thanks in advance.
>> Daniel
>
> *
> *   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/


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