Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Generalized Method of Moments Estimation PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Generalized method of moments estimation in

Stata 11

David M. Drukker
StataCorp

Stata Conference
Washington, DC 2009

1 / 27
Outline

1 A quick introduction to GMM

2 gmm examples
Ordinary least squares
Two-stage least squares
Cross-sectional Poisson with endogenous covariates
Fixed-effects Poisson regression

2 / 27
A quick introduction to GMM

Method of Moments (MM)


We estimate the mean of a distribution by the sample mean, the
variance by the sample variance, etc
We want to estimate µ = E [y ]
P
We use µb = (1/N) N i =1 yi
This estimator has nice properties because it solves the sample
moment condition
N
X
(1/N) (yi − µ) = 0
i =1
which is the sample analog of the population moment condition

E [y − µ] = 0
Estimators that solve sample moment equations to produce
estimates are called method-of-moments (MM) estimators
This method dates back to Pearson (1895)
3 / 27
A quick introduction to GMM

Generalized method-of-moments (GMM)


The MM only works when the number of moment conditions
equals the number of parameters to estimate
If there are more moment conditions than parameters, the
system of equations is algebraically over identified and cannot
be solved
Generalized method-of-moments (GMM) estimators choose the
estimates that minimize a quadratic form of the sample
moment conditions
GMM gets as close to solving the over-identified system of
sample moment equations as possible
GMM reduces to MM when the number of parameters equals
the number of moment conditions
Hansen (1982) produced many of the key results; Wooldridge
(2002); Cameron and Trivedi (2005) provide good introductions
4 / 27
A quick introduction to GMM

Definition of GMM estimator


Our research question implies q population moment conditions
E [m(wi , θ)] = 0
m is q × 1 vector of functions whose expected values are zero in
the population
wi is the data on person i
θ is k × 1 vector of parameters, k ≤ q
The sample moments that correspond to the population
moments are
P
m(θ) = (1/N) Ni=1 m(wi , θ)
When k < q, GMM chooses the parameters that are as close as
possible to solving the over-identified system of moment
equations
bGMM ≡ arg min m(θ)′ Wm(θ)
θ θ
5 / 27
A quick introduction to GMM

Some properties of the GMM estimator


bGMM ≡ arg min
θ m(θ)′ Wm(θ)
θ

When k = q, the MM estimator solves m(θ) exactly so


m(θ)′ Wm(θ) = 0
W only affects the efficiency of the GMM estimator
Setting W = I yields consistent, but inefficient estimates
Setting W = Cov[m(θ)]−1 yields an efficient GMM estimator
We can take multiple steps to get an efficient GMM estimator
1 Let W = I and get
bGMM1 ≡ arg min
θ m(θ)′ m(θ)
θ
2 bGMM1 to get W,
Use θ c which is an estimate of Cov[m(θ)]−1
3 Get
bGMM2 ≡ arg min
θ c
m(θ)′ Wm(θ)
θ
4 b bGMM1
Repeat steps 2 and 3 using θ GMM2 in place of θ
6 / 27
gmm examples

The gmm command

The new command gmm estimates parameters by GMM


gmm is similar to nl, you specify the sample moment conditions
as substitutable expressions
Substitutable expressions enclose the model parameters in braces
{}

7 / 27
gmm examples Ordinary least squares

The interactive syntax of gmm


For many models, the population moment conditions have the
form
E [ze(β)] = 0
where z is a q × 1 vector of instrumental variables and e(β) is a
scalar function of the data and the parameters β
The corresponding syntax of gmm is
   
gmm (eb expression) ifweight ,in
 
instruments(instrument varlist) options

where some options are


onestep use one-step estimator (default is two-step estimator)
winitial(wmtype) initial weight-matrix W
wmatrix(witype) weight-matrix W computation after first step
vce(vcetype) vcetype may be robust, cluster, bootstrap, hac
8 / 27
gmm examples Ordinary least squares

Ordinary least squares (OLS) is an MM estimator


We know that OLS estimates the parameters of the conditional
expectation of yi = xi β + ǫi under the assumption that
E [ǫ|x] = 0
Standard probability theory implies that
E [ǫ|x] = 0 ⇒ E [xǫ] = 0
So the population moment conditions for OLS are
E [x(y − xβ)] = 0
The corresponding sample moment conditions are
P
(1/N) Ni=1 xi (yi − xi β) = 0
Solving for β yields
P −1 P
b = N
x ′
x N ′
β OLS i =1 i i i =1 xi yi

9 / 27
gmm examples Ordinary least squares

Modeling crime data I

We have (fictional) data on crime in 3,000 communities


. use cscrime2, clear
. describe
Contains data from cscrime2.dta
obs: 3,000
vars: 5 29 Jul 2009 12:02
size: 132,000 (98.7% of memory free) (_dta has notes)

storage display value


variable name type format label variable label

policepc double %10.0g police officers per thousand


arrestp double %10.0g arrests/crimes
convictp double %10.0g convictions/arrests
legalwage double %10.0g legal wage index 0-20 scale
crime double %10.0g property-crime index 0-50 scale

Sorted by:

10 / 27
gmm examples Ordinary least squares

Modeling crime data II

We specify that

crimei = policepci β1 + legalwagei β2 + β3 + ǫi

We want to model

E [crime|policepc, legalwage] = policepcβ1 + legalwageβ2 + β3

If E [ǫ|policepc, legalwage] = 0, the population moment


conditions are
    
policepc 0
E (crime − policepcβ1 − legalwageβ2 − β3 ) =
legalwage 0

11 / 27
gmm examples Ordinary least squares

OLS by GMM I

. gmm (crime - policepc*{b1} - legalwage*{b2} - {b3}), ///


> instruments(policepc legalwage) nolog
Final GMM criterion Q(b) = 2.62e-31
GMM estimation
Number of parameters = 3
Number of moments = 3
Initial weight matrix: Unadjusted Number of obs = 3000
GMM weight matrix: Robust

Robust
Coef. Std. Err. z P>|z| [95% Conf. Interval]

/b1 -.4226003 .0100658 -41.98 0.000 -.4423289 -.4028716


/b2 -7.543894 .3969104 -19.01 0.000 -8.321824 -6.765964
/b3 27.79852 .0546507 508.66 0.000 27.69141 27.90563

Instruments for equation 1: policepc legalwage _cons

12 / 27
gmm examples Ordinary least squares

OLS by GMM II

. regress crime policepc legalwage, robust


Linear regression Number of obs = 3000
F( 2, 2997) = 1384.95
Prob > F = 0.0000
R-squared = 0.6217
Root MSE = 1.7972

Robust
crime Coef. Std. Err. t P>|t| [95% Conf. Interval]

policepc -.4226003 .0100709 -41.96 0.000 -.4423468 -.4028538


legalwage -7.543894 .397109 -19.00 0.000 -8.322528 -6.765261
_cons 27.79852 .054678 508.40 0.000 27.69131 27.90573

13 / 27
gmm examples Two-stage least squares

IV and 2SLS
For some variables, the assumption E [ǫ|x] = 0 is too strong and
we need to allow for E [ǫ|x] 6= 0
If we have q variables z for which E [ǫ|z] = 0 and the correlation
between z and x is sufficiently strong, we can estimate β from
the population moment conditions
E [z(y − xβ)] = 0
z are known as instrumental variables
If the number of variables in z and x is the same (q = k),
solving the the sample moment conditions yields the MM
estimator known as the instrumental variables (IV) estimator
If there are more variables in z than in x (q > k) and we let
P −1
N
W= z′
i =1 i zi in our GMM estimator, we obtain the
two-stage least-squares (2SLS) estimator
14 / 27
gmm examples Two-stage least squares

2SLS on crime data I

The assumption that E [ǫ|policepc] = 0 is false if communities


increase policepc in response an increase in crime (an increase
in ǫi )
The variables arrestp and convictp are valid instruments, if
they measure some components of communities’ toughness-on
crime that are unrelated to ǫ but are related to policepc
We will continue to maintain that E [ǫ|legalwage] = 0

15 / 27
gmm examples Two-stage least squares

2SLS by GMM I

. gmm (crime - policepc*{b1} - legalwage*{b2} - {b3}), ///


> instruments(arrestp convictp legalwage ) nolog onestep
Final GMM criterion Q(b) = .0001736
GMM estimation
Number of parameters = 3
Number of moments = 4
Initial weight matrix: Unadjusted Number of obs = 3000

Robust
Coef. Std. Err. z P>|z| [95% Conf. Interval]

/b1 -.9516683 .0785137 -12.12 0.000 -1.105552 -.7977844


/b2 -2.304205 .9648523 -2.39 0.017 -4.195281 -.4131291
/b3 29.88578 .3135637 95.31 0.000 29.2712 30.50035

Instruments for equation 1: arrestp convictp legalwage _cons

16 / 27
gmm examples Two-stage least squares

2SLS by GMM II

. ivregress 2sls crime legalwage (policepc = arrestp convictp) , robust


Instrumental variables (2SLS) regression Number of obs = 3000
Wald chi2(2) = 696.63
Prob > chi2 = 0.0000
R-squared = .
Root MSE = 3.0516

Robust
crime Coef. Std. Err. z P>|z| [95% Conf. Interval]

policepc -.9516683 .0785137 -12.12 0.000 -1.105552 -.7977844


legalwage -2.304205 .9648523 -2.39 0.017 -4.195281 -.4131291
_cons 29.88578 .3135637 95.31 0.000 29.2712 30.50035

Instrumented: policepc
Instruments: legalwage arrestp
convictp

17 / 27
gmm examples Cross-sectional Poisson with endogenous covariates

Poisson with endogenous covariates

We want to model to E [yi |xi , νi ] = exp(xi β)νi


This setup allows the distribution of νi to depend on xi
Mullahy (1997) showed that we can use instrumental variables zi
and the population moment conditions
E [zi (yi exp(xi β) − 1)] = 0
to estimate β

18 / 27
gmm examples Cross-sectional Poisson with endogenous covariates

. use accident2, clear


. describe
Contains data from accident2.dta
obs: 948
vars: 6 29 Jul 2009 11:59
size: 26,544 (99.7% of memory free)

storage display value


variable name type format label variable label

kids float %9.0g


cvalue float %9.0g
tickets float %9.0g
traffic float %9.0g
male float %9.0g
accidents float %9.0g

Sorted by:

traffic and male are exogenous variables


tickets is an endogenous variable
kids and cvalue are instrumental variables

19 / 27
gmm examples Cross-sectional Poisson with endogenous covariates

. gmm (accidents*exp(-tickets*{b1} - traffic*{b2} - male*{b3} - {b4}) - 1), ///


> instruments(kids cvalue traffic male) onestep nolog
Final GMM criterion Q(b) = .0109217
GMM estimation
Number of parameters = 4
Number of moments = 5
Initial weight matrix: Unadjusted Number of obs = 948

Robust
Coef. Std. Err. z P>|z| [95% Conf. Interval]

/b1 1.745919 .1984268 8.80 0.000 1.357009 2.134828


/b2 .1216527 .0421674 2.88 0.004 .0390061 .2042993
/b3 4.693161 .5129505 9.15 0.000 3.687797 5.698526
/b4 -11.51383 1.208924 -9.52 0.000 -13.88327 -9.144379

Instruments for equation 1: kids cvalue traffic male _cons

20 / 27
gmm examples Fixed-effects Poisson regression

More complicated moment conditions

The structure of the moment conditions for some models is too


complicated to fit into the interactive syntax used thus far
For example, Wooldridge (1999, 2002); Blundell, Griffith, and
Windmeijer (2002) discuss estimating the fixed-effects Poisson
model for panel data by GMM.
In the Poisson panel-data model we are modeling
E [yit |xit , ηi ] = exp(xit β + ηi )
Hausman, Hall, and Griliches (1984) derived a conditional
log-likelihood function when the outcome is assumed to come
from a Poisson distribution with mean exp(xit β + ηi ) and ηi is
an observed component that is correlated with the xit

21 / 27
gmm examples Fixed-effects Poisson regression

Wooldridge (1999) showed that you could estimate the


parameters of this model by solving the sample moment
equations
P P  
yi
i t xit yit − µit µ =0
i

These moment conditions do not fit into the interactive syntax


because the term µi depends on the parameters
Need to use moment-evaluator program syntax

22 / 27
gmm examples Fixed-effects Poisson regression

Moment-evaluator program syntax


An abbreviated form of the program syntax for gmm is
   
gmm moment program if in weight ,
equations(moment cond names)
parameters(parameter names)
 
instruments() options
The moment program is an ado-file of the form
program gmm_eval
version 11
syntax varlist if, at(name)
quietly {
<replace elements of varlist with error
part of moment conditions>
}
end
23 / 27
gmm examples Fixed-effects Poisson regression

Panel Accident data

. use xtaccidents
. describe
Contains data from xtaccidents.dta
obs: 5,000
vars: 7 31 May 2008 19:50
size: 160,000 (98.5% of memory free)

storage display value


variable name type format label variable label

id float %9.0g
male float %9.0g
t float %9.0g
kids float %9.0g
cvalue float %9.0g
tickets float %9.0g
accidents float %9.0g

Sorted by: id t
. by id: egen max_a = max(accidents )
. drop if max_a ==0
(3750 observations deleted)

24 / 27
gmm examples Fixed-effects Poisson regression

program xtfe
version 11
syntax varlist if, at(name)
quietly {
tempvar mu mubar ybar
generate double ‘mu’ = exp(kids*‘at’[1,1] ///
+ cvalue*‘at’[1,2] ///
+ tickets*‘at’[1,3]) ‘if’
egen double ‘mubar’ = mean(‘mu’) ‘if’, by(id)
egen double ‘ybar’ = mean(accidents) ‘if’, by(id)
replace ‘varlist’ = accidents ///
- ‘mu’*‘ybar’/‘mubar’ ‘if’
}
end

25 / 27
gmm examples Fixed-effects Poisson regression

FE Poisson by gmm

. gmm xtfe , equations(accidents) parameters(kids cvalue tickets) ///


> instruments(kids cvalue tickets, noconstant) ///
> vce(cluster id) onestep nolog
Final GMM criterion Q(b) = 1.50e-16
GMM estimation
Number of parameters = 3
Number of moments = 3
Initial weight matrix: Unadjusted Number of obs = 1250
(Std. Err. adjusted for 250 clusters in id)

Robust
Coef. Std. Err. z P>|z| [95% Conf. Interval]

/kids -.4506245 .0969133 -4.65 0.000 -.6405711 -.2606779


/cvalue -.5079946 .0615506 -8.25 0.000 -.6286315 -.3873577
/tickets .151354 .0873677 1.73 0.083 -.0198835 .3225914

Instruments for equation 1: kids cvalue tickets

26 / 27
gmm examples Fixed-effects Poisson regression

FE Poisson by xtpoisson, fe

. xtpoisson accidents kids cvalue tickets, fe nolog


Conditional fixed-effects Poisson regression Number of obs = 1250
Group variable: id Number of groups = 250
Obs per group: min = 5
avg = 5.0
max = 5
Wald chi2(3) = 104.31
Log likelihood = -351.11739 Prob > chi2 = 0.0000

accidents Coef. Std. Err. z P>|z| [95% Conf. Interval]

kids -.4506245 .0981448 -4.59 0.000 -.6429848 -.2582642


cvalue -.5079949 .0549888 -9.24 0.000 -.615771 -.4002188
tickets .151354 .0825006 1.83 0.067 -.0103442 .3130521

27 / 27
References

Bibliography
Blundell, Richard, Rachel Griffith, and Frank Windmeijer. 2002.
“Individual effects and dynamics in count data models,” Journal of
Econometrics, 108, 113–131.
Cameron, A. Colin and Pravin K. Trivedi. 2005. Microeconometrics:
Methods and applications, Cambridge: Cambridge University Press.
Hansen, L. P. 1982. “Large-sample properties of Generalized
Method-of-Moment Estimators,” Econometrica, 1029–1054.
Hausman, Jerry A., Bronwyn H. Hall, and Zvi Griliches. 1984.
“Econometric Models for Count Data with an Application to the
Patents-R&D Relationship,” Econometrica, 52(4), 909–938.
Mullahy, J. 1997. “Instrumental variable estimation of Poisson
Regression models: Application to models of cigarette smoking
behavior,” Review of Economics and Statistics, 79, 586–593.
Pearson, Karl. 1895. “Contributions to the mathematical theory of
evolution—II. Skew variation in homogeneous material,”
27 / 27
gmm examples Fixed-effects Poisson regression

Philosophical Transactions of the Royal Society of London, Series


A, 186, 343–414.
Wooldridge, Jeffrey. 2002. Econometric Analysis of Cross Section and
Panel Data, Cambridge, Massachusetts: MIT Press.
Wooldridge, Jeffrey M. 1999. “Distribution-free estimation of some
nonlinear panel-data models,” Journal of Econometrics, 90, 77–90.

27 / 27

You might also like