# Generalized method of moments

In econometrics and statistics, the generalized method of moments (GMM) is a generic method for estimating parameters in statistical models. Usually it is applied in the context of semiparametric models, where the parameter of interest is finite-dimensional, whereas the full shape of the data's distribution function may not be known, and therefore maximum likelihood estimation is not applicable.
The method requires that a certain number of moment conditions be specified for the model. These moment conditions are functions of the model parameters and the data, such that their expectation is zero at the parameters' true values. The GMM method then minimizes a certain norm of the sample averages of the moment conditions, and can therefore be thought of as a special case of minimum-distance estimation.
The GMM estimators are known to be consistent, asymptotically normal, and most efficient in the class of all estimators that do not use any extra information aside from that contained in the moment conditions. GMM were advocated by Lars Peter Hansen in 1982 as a generalization of the method of moments, introduced by Karl Pearson in 1894. However, these estimators are mathematically equivalent to those based on "orthogonality conditions" (Sargan, 1958, 1959) or "unbiased estimating equations" (Huber, 1967; Wang et al., 1997).

## Description

Suppose the available data consists of T observations {Y$_t$ }$_{t=1,...,T}$, where each observation Y$_t$ is an n-dimensional multivariate random variable. We assume that the data come from a certain statistical model, defined up to an unknown parameter θ ∈ Θ. The goal of the estimation problem is to find the “true” value of this parameter, θ$_0$, or at least a reasonably close estimate.
A general assumption of GMM is that the data Y$_t$ be generated by a weakly stationary ergodic stochastic process. (The case of independent and identically distributed (iid) variables Y$_t$ is a special case of this condition.)
In order to apply GMM, we need to have "moment conditions", that is, we need to know a vector-valued function g(Y,θ) such that
    $m(\theta _{0})\equiv \operatorname {E} [\,g(Y_{t},\theta _{0})\,]=0,$
where E denotes expectation, and Y$_t$ is a generic observation. Moreover, the function m(θ) must differ from zero for θ ≠ θ$_0$, otherwise the parameter θ will not be point-identified.
The basic idea behind GMM is to replace the theoretical expected value E[⋅] with its empirical analog—sample average:
    ${\hat {m}}(\theta )\equiv {\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta )$
and then to minimize the norm of this expression with respect to θ. The minimizing value of θ is our estimate for θ$_0$.
By the law of large numbers, $\scriptstyle {\hat {m}}(\theta )\,\approx \;\operatorname {E} [g(Y_{t},\theta )]\,=\,m(\theta )$ for large values of T, and thus we expect that $\scriptstyle {\hat {m}}(\theta _{0})\;\approx \;m(\theta _{0})\;=\;0$. The generalized method of moments looks for a number $\scriptstyle {\hat {\theta }}$ which would make $\scriptstyle {\hat {m}}(\;\!{\hat {\theta }}\;\!)$ as close to zero as possible. Mathematically, this is equivalent to minimizing a certain norm of $\scriptstyle {\hat {m}}(\theta )$ (norm of m, denoted as ||m||, measures the distance between m and zero). The properties of the resulting estimator will depend on the particular choice of the norm function, and therefore the theory of GMM considers an entire family of norms, defined as
    $\|{\hat {m}}(\theta )\|_{W}^{2}={\hat {m}}(\theta )^{\mathsf {T}}\,W{\hat {m}}(\theta ),$
where W is a positive-definite weighting matrix, and $m^{\mathsf {T}}$ denotes transposition. In practice, the weighting matrix W is computed based on the available data set, which will be denoted as $\scriptstyle {\hat {W}}$. Thus, the GMM estimator can be written as
    ${\hat {\theta }}=\operatorname {arg} \min _{\theta \in \Theta }{\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta ){\bigg )}^{\mathsf {T}}{\hat {W}}{\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta ){\bigg )}$
Under suitable conditions this estimator is consistent, asymptotically normal, and with right choice of weighting matrix $\scriptstyle {\hat {W}}$ also asymptotically efficient.

## Properties
### Consistency

Consistency is a statistical property of an estimator stating that, having a sufficient number of observations, the estimator will converge in probability to the true value of parameter:
    ${\hat {\theta }}{\xrightarrow {p}}\theta _{0}\ {\text{as}}\ T\to \infty .$
Sufficient conditions for a GMM estimator to be consistent are as follows:
* ${\hat {W}}_{T}{\xrightarrow {p}}W,$ where W is a positive semi-definite matrix,
* $\,W\operatorname {E} [\,g(Y_{t},\theta )\,]=0$ only for $\,\theta =\theta _{0},$
* The space of possible parameters $\Theta \subset \mathbb {R} ^{k}$ is compact,
* $\,g(Y,\theta )$ is continuous at each θ with probability one,
* $\operatorname {E} [\,\textstyle \sup _{\theta \in \Theta }\lVert g(Y,\theta )\rVert \,]<\infty .$
The second condition here (so-called Global identification condition) is often particularly hard to verify. There exist simpler necessary but not sufficient conditions, which may be used to detect non-identification problem:
* Order condition. The dimension of moment function m(θ) should be at least as large as the dimension of parameter vector θ.
* Local identification. If g(Y,θ) is continuously differentiable in a neighborhood of $\theta _{0}$, then matrix $W\operatorname {E} [\nabla _{\theta }g(Y_{t},\theta _{0})]$ must have full column rank.
In practice applied econometricians often simply assume that global identification holds, without actually proving it.$^{:2127}$

### Asymptotic normality

Asymptotic normality is a useful property, as it allows us to construct confidence bands for the estimator, and conduct different tests. Before we can make a statement about the asymptotic distribution of the GMM estimator, we need to define two auxiliary matrices:
    $G=\operatorname {E} [\,\nabla _{\!\theta }\,g(Y_{t},\theta _{0})\,],\qquad \Omega =\operatorname {E} [\,g(Y_{t},\theta _{0})g(Y_{t},\theta _{0})^{\mathsf {T}}\,]$
Then under conditions 1–6 listed below, the GMM estimator will be asymptotically normal with limiting distribution:
${\sqrt {T}}{\big{\hat {\theta }}-\theta _{0}{\big )}\ {\xrightarrow {d}}\ {\mathcal {N}}{\big0,(G^{\mathsf {T}}WG)^{-1}G^{\mathsf {T}}W\Omega W^{\mathsf {T}}G(G^{\mathsf {T}}W^{\mathsf {T}}G)^{-1}{\big ]}.$
Conditions:
* ${\hat {\theta }}$ is consistent (see previous section),
* The set of possible parameters $\Theta \subset \mathbb {R} ^{k}$ is compact,
* $\,g(Y,\theta )$ is continuously differentiable in some neighborhood N of $\theta _{0}$ with probability one,
* $\operatorname {E} [\,\lVert g(Y_{t},\theta )\rVert ^{2}\,]<\infty ,$
* $\operatorname {E} [\,\textstyle \sup _{\theta \in N}\lVert \nabla _{\theta }g(Y_{t},\theta )\rVert \,]<\infty ,$
* the matrix $G'WG$ is nonsingular.

### Relative Efficiency

So far we have said nothing about the choice of matrix W, except that it must be positive semi-definite. In fact any such matrix will produce a consistent and asymptotically normal GMM estimator, the only difference will be in the asymptotic variance of that estimator. It can be shown that taking
    $W\propto \ \Omega ^{-1}$
will result in the most efficient estimator in the class of all (generalized) method of moment estimators. Only infinite number of orthogonal conditions obtains the smallest variance, the Cramér–Rao bound.
In this case the formula for the asymptotic distribution of the GMM estimator simplifies to
    ${\sqrt {T}}{\big{\hat {\theta }}-\theta _{0}{\big )}\ {\xrightarrow {d}}\ {\mathcal {N}}{\big0,(G^{\mathsf {T}}\,\Omega ^{-1}G)^{-1}{\big ]}$
The proof that such a choice of weighting matrix is indeed locally optimal is often adopted with slight modifications when establishing efficiency of other estimators. As a rule of thumb, a weighting matrix inches closer to optimality when it turns into an expression closer to the Cramér–Rao bound.
Proof. We will consider the difference between asymptotic variance with arbitrary W and asymptotic variance with $W=\Omega ^{-1}$. If we can factor this difference into a symmetric product of the form CC' for some matrix C, then it will guarantee that this difference is nonnegative-definite, and thus $W=\Omega ^{-1}$ will be optimal by definition. :
| $\,V(W)-V(\Omega ^{-1})$ | $\,=(G^{\mathsf {T}}WG)^{-1}G^{\mathsf {T}}W\Omega WG(G^{\mathsf {T}}WG)^{-1}-(G^{\mathsf {T}}\Omega ^{-1}G)^{-1}$ |
| | $\,=(G^{\mathsf {T}}WG)^{-1}{\BigG^{\mathsf {T}}W\Omega WG-G^{\mathsf {T}}WG(G^{\mathsf {T}}\Omega ^{-1}G)^{-1}G^{\mathsf {T}}WG{\Big )}(G^{\mathsf {T}}WG)^{-1}$ |
| | $\,=(G^{\mathsf {T}}WG)^{-1}G^{\mathsf {T}}W\Omega ^{1/2}{\BigI-\Omega ^{-1/2}G(G^{\mathsf {T}}\Omega ^{-1}G)^{-1}G^{\mathsf {T}}\Omega ^{-1/2}{\Big )}\Omega ^{1/2}WG(G^{\mathsf {T}}WG)^{-1}$ |
| | $\,=A(I-B)A^{\mathsf {T}},$ |
| where we introduced matrices A and B in order to slightly simplify notation; I is an identity matrix. We can see that matrix B here is symmetric and idempotent: $B^{2}=B$. This means I−B is symmetric and idempotent as well: $I-B=(I-B)(I-B)^{\mathsf {T}}$. Thus we can continue to factor the previous expression as ||
| | $\,=A(I-B)(I-B)^{\mathsf {T}}A^{\mathsf {T}}={\BigA(I-B){\Big )}{\BigA(I-B){\Big )}^{\mathsf {T}}\geq 0$ |

## Implementation

One difficulty with implementing the outlined method is that we cannot take W = Ω$^{−1}$ because, by the definition of matrix Ω, we need to know the value of θ$_0$ in order to compute this matrix, and θ$_0$ is precisely the quantity we do not know and are trying to estimate in the first place. In the case of Y$_t$ being iid we can estimate W as
    ${\hat {W}}_{T}({\hat {\theta }})={\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},{\hat {\theta }})g(Y_{t},{\hat {\theta }})^{\mathsf {T}}{\bigg )}^{-1}.$
Several approaches exist to deal with this issue, the first one being the most popular:
* Two-step feasible GMM: Step 1: Take W = I (the identity matrix) or some other positive-definite matrix, and compute preliminary GMM estimate $\scriptstyle {\hat {\theta }}_{(1)}$. This estimator is consistent for θ$_0$, although not efficient.Step 2: ${\hat {W}}_{T}({\hat {\theta }}_{(1)})$ converges in probability to Ω$^{−1}$ and therefore if we compute $\scriptstyle {\hat {\theta }}$ with this weighting matrix, the estimator will be asymptotically efficient.
* Iterated GMM. Essentially the same procedure as 2-step GMM, except that the matrix ${\hat {W}}_{T}$ is recalculated several times. That is, the estimate obtained in step 2 is used to calculate the weighting matrix for step 3, and so on until some convergence criterion is met. Asymptotically no improvement can be achieved through such iterations, although certain Monte-Carlo experiments suggest that finite-sample properties of this estimator are slightly better.
    ${\hat {\theta }}_{(i+1)}=\operatorname {arg} \min _{\theta \in \Theta }{\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta ){\bigg )}^{\mathsf {T}}{\hat {W}}_{T}({\hat {\theta }}_{(i)}){\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta ){\bigg )}$
* Continuously updating GMM (CUGMM, or CUE). Estimates $\scriptstyle {\hat {\theta }}$ simultaneously with estimating the weighting matrix W: In Monte-Carlo experiments this method demonstrated a better performance than the traditional two-step GMM: the estimator has smaller median bias (although fatter tails), and the J-test for overidentifying restrictions in many cases was more reliable.
    ${\hat {\theta }}=\operatorname {arg} \min _{\theta \in \Theta }{\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta ){\bigg )}^{\mathsf {T}}{\hat {W}}_{T}(\theta ){\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},\theta ){\bigg )}$
Another important issue in implementation of minimization procedure is that the function is supposed to search through (possibly high-dimensional) parameter space Θ and find the value of θ which minimizes the objective function. No generic recommendation for such procedure exists, it is a subject of its own field, numerical optimization.

## Sargan–Hansen J-test

When the number of moment conditions is greater than the dimension of the parameter vector θ, the model is said to be over-identified. Sargan (1958) proposed tests for over-identifying restrictions based on instrumental variables estimators that are distributed in large samples as Chi-square variables with degrees of freedom that depend on the number of over-identifying restrictions. Subsequently, Hansen (1982) applied this test to the mathematically equivalent formulation of GMM estimators. Note, however, that such statistics can be negative in empirical applications where the models are misspecified, and likelihood ratio tests can yield insights since the models are estimated under both null and alternative hypotheses (Bhargava and Sargan, 1983).
Conceptually we can check whether ${\hat {m}}({\hat {\theta }})$ is sufficiently close to zero to suggest that the model fits the data well. The GMM method has then replaced the problem of solving the equation ${\hat {m}}(\theta )=0$, which chooses $\theta$ to match the restrictions exactly, by a minimization calculation. The minimization can always be conducted even when no $\theta _{0}$ exists such that $m(\theta _{0})=0$. This is what J-test does. The J-test is also called a test for over-identifying restrictions.
Formally we consider two hypotheses:
* $H_{0}:\ m(\theta _{0})=0$ (the null hypothesis that the model is “valid”), and
* $H_{1}:\ m(\theta )\neq 0,\ \forall \theta \in \Theta$ (the alternative hypothesis that model is “invalid”; the data does not come close to meeting the restrictions)
Under hypothesis $H_{0}$, the following so-called J-statistic is asymptotically chi-squared distributed with k–l degrees of freedom. Define J to be:
    $J\equiv T\cdot {\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},{\hat {\theta }}){\bigg )}^{\mathsf {T}}{\hat {W}}_{T}{\bigg{\frac {1}{T}}\sum _{t=1}^{T}g(Y_{t},{\hat {\theta }}){\bigg )}\ {\xrightarrow {d}}\ \chi _{k-\ell }^{2}$ under $H_{0},$
where ${\hat {\theta }}$ is the GMM estimator of the parameter $\theta _{0}$, k is the number of moment conditions (dimension of vector g), and l is the number of estimated parameters (dimension of vector θ). Matrix ${\hat {W}}_{T}$ must converge in probability to $\Omega ^{-1}$, the efficient weighting matrix (note that previously we only required that W be proportional to $\Omega ^{-1}$ for estimator to be efficient; however in order to conduct the J-test W must be exactly equal to $\Omega ^{-1}$, not simply proportional).
Under the alternative hypothesis $H_{1}$, the J-statistic is asymptotically unbounded:
    $J\ {\xrightarrow {p}}\ \infty$ under $H_{1}$
To conduct the test we compute the value of J from the data. It is a nonnegative number. We compare it with (for example) the 0.95 quantile of the $\chi _{k-\ell }^{2}$ distribution:
* $H_{0}$ is rejected at 95% confidence level if $J>q_{0.95}^{\chi _{k-\ell }^{2}}$
* $H_{0}$ cannot be rejected at 95% confidence level if $J<q_{0.95}^{\chi _{k-\ell }^{2}}$

## Scope

Many other popular estimation techniques can be cast in terms of GMM optimization:
* Ordinary least squares (OLS) is equivalent to GMM with moment conditions:
    $\operatorname {E} [\,x_{t}(y_{t}-x_{t}^{\mathsf {T}}\beta )\,]=0$
* Weighted least squares (WLS)
    $\operatorname {E} [\,x_{t}(y_{t}-x_{t}^{\mathsf {T}}\beta )/\sigma ^{2}(x_{t})\,]=0$
* Instrumental variables regression (IV)
    $\operatorname {E} [\,z_{t}(y_{t}-x_{t}^{\mathsf {T}}\beta )\,]=0$
* Non-linear least squares (NLLS):
    $\operatorname {E} [\,\nabla _{\!\beta }\,g(x_{t},\beta )\cdot (y_{t}-g(x_{t},\beta ))\,]=0$
* Maximum likelihood estimation (MLE):
    $\operatorname {E} [\,\nabla _{\!\theta }\ln f(x_{t},\theta )\,]=0$

## An Alternative to the GMM

In method of moments, an alternative to the original (non-generalized) Method of Moments (MoM) is described, and references to some applications and a list of theoretical advantages and disadvantages relative to the traditional method are provided. This Bayesian-Like MoM (BL-MoM) is distinct from all the related methods described above, which are subsumed by the GMM. The literature does not contain a direct comparison between the GMM and the BL-MoM in specific applications.

## Implementations

* R Programming wikibook, Method of Moments
* R
* Stata
* EViews
* SAS
* Gretl