Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

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

# Re: st: using macros in -gmm-

 From Scott Merryman To statalist@hsphsun2.harvard.edu Subject Re: st: using macros in -gmm- Date Wed, 10 Aug 2011 07:10:04 -0500

```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
<stata.danielbm@gmail.com> 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/
```

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index