On Thu, 1 Oct 2009, László Sándor wrote:
Hi all,
I tried to write up a relatively simple GMM estimation, but I needed a
moment-evaluator program to do some simulation for each evaluation
(this basically becomes the method of simulated moments). I tried to
follow of the example of David Drukker, presented in DC this summer
(slides 23-26): http://www.stata.com/meeting/dcconf09/abstracts.html
(A similar example is in the -help gmm- file too.)
His GMM evaluator function is tailored for the application, thus uses
some actual variable names, not locals coming from the command. I did
the same (though I also needed to use Mata). Crucially, he had no
varlist in his command either: "gmm xtfe ," (But mentioned a varlist
in the syntax -- still, it worked for him.)
Could you look into what goes wrong here? The error messages did not
help me much. I don't know where is it expecting a varlist, and how I
could provide it. (I admit I am not good with ado files yet.)
Laszlo might want to look at the reference manual entry for -gmm-, which
is available in PDF format to all Stata 11 users. In particular, the
technical note after example 9 shows how to write a moment evaluator
program that allows you to specify your own dependent and independent
variables. Examples 10 and 11 also show how to do this, as does the
program on page 616.
Laszlo wrote:
... varlist in his command either: "gmm xtfe ," (But mentioned a varlist
in the syntax -- still, it worked for him.)
In your moment evaluator program, near the top there will be a line like
this:
syntax varlist if, at(name) ...
That `varlist' does not contain the names of your dependent variables.
Rather, it contains the names of temporary variables that you are to fill
in with the sample residuals for each of the moment equations. The number
of variables in `varlist' equals the number you specify in the
nequations() option or the number of names you specify in the equations()
option. The ... in my -syntax- statement is the key to passing other
information to your moment evaluator program. In the examples in the
Reference manual, the moment evaluator program accepts additional options
mylhs() and myrhs(), which are how you pass the name of the dependent and
independent variables to the program when you call -gmm-.
Laszlo called -gmm- using the command
. gmm msm moment, nequations(1) parameters(cons hp weight ac)
instruments(cons hp weight ac cons2 hp2 weight2 ac2, noconstant)
When you use the moment-evaluator program with -gmm-, you do not specify a
variable name after the name of the moment-evaluator program, so the
command should be something more like
. gmm msm, nequations(1) parameters(cons hp weight ac)
instruments(cons hp weight ac cons2 hp2 weight2 ac2, noconstant)
perhaps with additional options depending on what options you decide to
pass onto your moment-evaluator program.
None of the examples in the -gmm- reference manual entry discuss using
Mata to compute the sample residuals in the moment-evaluator program, but
there is nothing in principle that stops you from doing so. We will
consider adding an example in the help file for -gmm- that shows how to do
this.
-- Brian Poi
-- [email protected]