* This code sample demonstates a method for selecting a valid set of
* instruments for a GMM where some of the moment conditions are suspected
* of being incorrect.
*
* It is based on a recent paper by Donald Andrews, entitled "Consistent
* Moment Selection Procedures for Generalized Method of Moments Estimation."
* Econometrica, Vol. 67, No. 3, pp 543-564. To do this precisely as
* described by Andrews requires running GMM with all subsets of a given
* size out of the instrument set. The following code provides a systematic
* method for generating such subsets.
*
* Most of the code is written to be as general as possible. In this
* particular example, we demonstrate the use of the "pos" index to set
* up MASK arrays for a GMM estimated using the NLSYSTEM command.
*
* Note that this is not a complete program--you need to add instructions
* to read in your data, do any transformations, etc. For the NLSYSTEM case,
* as shown here, you will also need to define your non-linear parameters,
* and define the formula to be estimated (we refer to it as "mygmmfrml"
* in the NLSYSTEM command included below):
*
* The sections of code specific to this application (i.e. the sections
* which need to be changed for other applicatiosn) are bracketed
* by "*******************" lines.
*
* Written by Estima
* August, 1999
*
declare vect[int] pos
*
* pop is the population size (10 in this example)
* pick is the number of items to be picked
*
compute pop =10
compute pick=5
dim pos(pick)
*****************************************************************
* Variable definitions specific to this example:
*
* Set up the MASK array to be used for this particular application:
dec rect mask(pop,1)
* Initialize bookkeepping variable:
compute bestuzwzu=-1.0
*
* End of application-specific variable definitions
*****************************************************************
*
* start with 1,2,...,pick. The vector of integers "pos" is always filled with an increasing
* sequence of values between 1 and pop.
*
ewise pos(i)=i
*
compute fixpos=pick
begin {
loop {
*****************************************************************
* Insert code here to do what you want with the indexes in pos. In this example, we
* specify the masking arraying and estimate using NLSYTEM:
compute mask=%const(0.0)
do j=1,pick
compute mask(pos(j),1)=1.0
end do j
nlsystem(mask=mask,zudep,instruments,noprint) / mygmmfrml
if bestuzwzu<0.or.%uzwzu=1.and.pos(fixpos)==pop+fixpos-pick)
compute fixpos=fixpos-1
*
* If all slots are at their limit, we're done.
*
if fixpos==0
break
*
* Increment the selected slot by one, and set all
* following slots to their preceding slot plus one.
*
compute pos(fixpos)=pos(fixpos)+1
do j=1,pick-fixpos
compute pos(fixpos+j)=pos(fixpos)+j
end do j
compute fixpos=pick
}
}