Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

🚧 🚧 🚧 Not the final version 🚧 🚧 🚧

EGM solves the consumption-savings model in milliseconds, but there is no likelihood for consumption and wealth data. The method of simulated moments (MSM) needs only the simulator: pick a few statistics of the data, and find the parameters at which the model reproduces them. Theory today, practice on Tuesday.

From solver and simulator to estimator

A solver and a simulator that are debugged let us study a theory: run the model for a range of parameter values and see what the decision maker does. The ultimate goal is to match the model to the observed data, in order to

The workflow of a structural project is the arc of this course: model, implementation, solver, understanding how the model works, estimation, validation, counterfactuals. Step four is where the time goes: solve, simulate, ask whether the result makes economic sense, repeat. It is also where the moments for step five are found.

Estimation versus calibration

The terms are often used interchangeably, and calibration exercises also search for the parameters that fit the data best. What estimation adds:

Estimation often concerns only a subset of the parameters, with the rest fixed at values from the literature, like a calibration. The NFXP estimation of Class 10 fixed β\beta, for instance.

Why not maximum likelihood?

The MLE of Class 10 is the most efficient estimator there is, when the model gives the probability of the observed data. In the bus engine model it does: the logit choice probabilities. In the consumption-savings model it does not, or not easily:

Simulation is cheap where integration is not. The simulator of Class 16 produces a synthetic panel for any θ\theta, and any statistic of the synthetic panel can be compared to the same statistic of the data.

  • Which objects would a likelihood for consumption and wealth data have to integrate out, and which of them does the simulator draw for free?

  • A calibration matches three moments with three parameters exactly. What question can it not answer?

Method of moments, GMM and simulated moments

Matching statistics of the model to statistics of the data has a long history:

Let ziz_i, i=1,…,Ni = 1, \dots, N, be the observed data, one record per individual, and let h(z)h(z) be a vector of qq statistics of one record, the moment functions. Three objects share the name “moments”:

m^N=1N∑i=1Nh(zi)⏟data moments,m(θ)=Eθ h(z)⏟model moments,m~S(θ)=1SN∑s=1SNh(z~s(θ))⏟simulated moments\underbrace{\hat m_N = \frac{1}{N} \sum_{i=1}^N h(z_i)}_{\text{data moments}}, \qquad \underbrace{m(\theta) = \mathbb{E}_\theta\, h(z)}_{\text{model moments}}, \qquad \underbrace{\tilde m_S(\theta) = \frac{1}{SN} \sum_{s=1}^{SN} h\big(\tilde z_s(\theta)\big)}_{\text{simulated moments}}

The model moments are the expectation of hh under the model with parameters θ\theta, the object GMM works with. MSM replaces them by the average over a synthetic sample z~s(θ)\tilde z_s(\theta) of SNS N records, simulated from the model at θ\theta with random draws u~s\tilde u_s. The vector

gN(θ)=m^N−m~S(θ)g_N(\theta) = \hat m_N - \tilde m_S(\theta)

of qq moment conditions is zero in expectation at the true θ0\theta_0 and at no other point, if the moments identify the parameters.

The last clause is the whole trick. With the draws fixed, every evaluation of QN(θ)Q_N(\theta) solves and simulates the model on the same shocks, so the simulated moments are a deterministic function of θ\theta that an optimizer can minimize.

Redraw the shocks at every θ\theta and the criterion is a random function: an optimizer cannot tell a change in the parameters from a change in the draws.

Three conditions make the estimator work, in the words of Corbae & Guvenen (2024):

The count of moments against parameters is the order condition, necessary but not sufficient:

  • The mean of a statistic over individuals is a moment. Is the median? Is a regression coefficient?

  • Why must the number of moments be at least the number of parameters?

The simulated criterion

The data are simulated too, from the “true” parameters, so that we know the answer. The module deaton_egm.py holds the model object of Class 16, the EGM solver of Class 17, which returns the policy as points on the endogenous grid, and the simulator.

Source
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[1], line 9
      5 from scipy.stats import chi2
      6 CODE = pathlib.Path('../gh-code/session19-oct29')         # the model and EGM solver of Classes 16-17
      7 if not CODE.exists():                                     # otherwise fetch it from the code repository
      8     CODE = pathlib.Path(tempfile.mkdtemp())
----> 9     urllib.request.urlretrieve('https://raw.githubusercontent.com/fediskhakov/sb-dse-code/main/session19-oct29/deaton_egm.py',
     10                                CODE / 'deaton_egm.py')
     11 sys.path.insert(0, str(CODE))
     12 from deaton_egm import deaton, solve_egm, simulate

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:240, in urlretrieve(url, filename, reporthook, data)
    223 """
    224 Retrieve a URL into a temporary location on disk.
    225 
   (...)    236 data file as well as the resulting HTTPMessage object.
    237 """
    238 url_type, path = _splittype(url)
--> 240 with contextlib.closing(urlopen(url, data)) as fp:
    241     headers = fp.info()
    243     # Just return the local path and the "headers" for file://
    244     # URLs. No sense in performing a copy unless requested.

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:215, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    213 else:
    214     opener = _opener
--> 215 return opener.open(url, data, timeout)

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:521, in OpenerDirector.open(self, fullurl, data, timeout)
    519 for processor in self.process_response.get(protocol, []):
    520     meth = getattr(processor, meth_name)
--> 521     response = meth(req, response)
    523 return response

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:630, in HTTPErrorProcessor.http_response(self, request, response)
    627 # According to RFC 2616, "2xx" code indicates that the client's
    628 # request was successfully received, understood, and accepted.
    629 if not (200 <= code < 300):
--> 630     response = self.parent.error(
    631         'http', request, response, code, msg, hdrs)
    633 return response

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:559, in OpenerDirector.error(self, proto, *args)
    557 if http_err:
    558     args = (dict, 'default', 'http_error_default') + orig_args
--> 559     return self._call_chain(*args)

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:492, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
    490 for handler in handlers:
    491     func = getattr(handler, meth_name)
--> 492     result = func(*args)
    493     if result is not None:
    494         return result

File /opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/urllib/request.py:639, in HTTPDefaultErrorHandler.http_error_default(self, req, fp, code, msg, hdrs)
    638 def http_error_default(self, req, fp, code, msg, hdrs):
--> 639     raise HTTPError(req.full_url, code, msg, hdrs, fp)

HTTPError: HTTP Error 404: Not Found

Only the last ten of the forty simulated periods are “observed”: the first thirty wash out the initial wealth, so the data come from the ergodic distribution of the model. The simulation below runs the same forty periods.

The covariance matrix Ω\Omega of the individual contributions h(zi)h(z_i) is the one object the asymptotics need from the data, and it comes for free once the moments are means over individuals.

The simulated moments solve the model at θ\theta and simulate SS copies of the data with a fixed seed, so the same draws are used at every θ\theta:

The figure plots the criterion in β\beta, with σ\sigma at its true value and a diagonal weighting matrix, for three simulators: S=1S = 1 with fixed draws, S=10S = 10 with fixed draws, and S=1S = 1 with fresh draws at every β\beta.

Source

Three things to see:

Where it breaks: a discrete choice in the simulator. The retirement decision of Class 18 is an indicator 1(u~<P)\mathbf 1(\tilde u < P), so a simulated retirement rate is a step function of θ\theta even with fixed draws: it only changes when a draw crosses the threshold.

This is the problem of McFadden (1989), and the reason the asymptotics of Pakes & Pollard (1989) do not assume a smooth criterion. Gradient-based optimizers fail on the steps; derivative-free ones, Nelder–Mead in our case, walk over them as long as the steps are small compared to the simplex.

  • The criterion with fresh draws is a random variable at every β\beta. What does its expectation look like, and why is the minimum of the expectation not the expectation of the minimum?

  • The model is solved on a grid and the policy is interpolated. Is the simulated moment a smooth function of β\beta even with fixed draws?

Asymptotic properties

The MSM estimator is a GMM estimator with a noisy version of the model moments, and it inherits the GMM theory of Hansen (1982) with one correction. Let DD be the q×Kq \times K Jacobian of the model moments,

D=∂m(θ0)∂θT,D = \frac{\partial m(\theta_0)}{\partial \theta^T},

and Ω\Omega the q×qq \times q asymptotic covariance of the data moments, N(m^N−m(θ0))→dN(0,Ω)\sqrt N (\hat m_N - m(\theta_0)) \xrightarrow{d} N(0, \Omega).

Where does the factor 1+1/S1 + 1/S come from? The moment conditions at θ0\theta_0 carry two independent sources of noise,

gN(θ0)=m^N−m(θ0)⏟data  −  (m~S(θ0)−m(θ0))⏟simulation,g_N(\theta_0) = \underbrace{\hat m_N - m(\theta_0)}_{\text{data}} \;-\; \underbrace{\big(\tilde m_S(\theta_0) - m(\theta_0)\big)}_{\text{simulation}},

the data moments with variance Ω/N\Omega / N and the simulated moments with variance Ω/(SN)\Omega / (SN), because they average SNSN records from the same distribution. Their sum has variance (1+1/S) Ω/N(1 + 1/S)\, \Omega / N, and this is the only place where the simulation enters the theory.

What the factor costs: with S=1S = 1 the standard errors are 2\sqrt 2 times the GMM ones, with S=10S = 10 they are 5% larger, and simulating more than ten copies of the data buys very little.

Three more things to read off the theorem:

Where it breaks: every formula above needs DD, the derivative of a function we only know through a simulator. The theorem does not require a smooth criterion, Pakes & Pollard (1989) cover step functions, but the standard errors do need the slope.

In practice DD is computed by finite differences of m~S(θ)\tilde m_S(\theta) with fixed draws, and the step size must be small enough to be a derivative but large enough to jump over the steps and the interpolation kinks of the solver. Tuesday’s class shows how much rides on that choice.

  • The MLE of Class 10 attains the Cramér–Rao bound. Why is the MSM estimator never as efficient, even with S→∞S \to \infty and the optimal WW?

  • A parameter that moves two moments in exactly opposite directions to another parameter. Is it identified?

The weighting matrix and the two-step estimator

The optimal weighting matrix is the inverse of the covariance of the moment conditions, which is unknown but estimable. For moments that are means over individuals, Ω^\hat\Omega is the sample covariance of the contributions h(zi)h(z_i), the one line np.cov(h.T) above, computed from the data once.

For moments of other kinds, autocovariances of a time series for instance, a Newey–West estimator or a bootstrap replaces it, and when the data moments come from published tables rather than micro data, Ω^\hat\Omega is itself simulated from the model at a first-step estimate.

Iterating steps 2 and 3 until θ\theta stops changing is the iterated MSM; the continuously updated version makes WW a function of θ\theta inside the criterion. In practice the weighting matrix is often simplified, and Altonji & Segal (1996) is the reason: in small samples the optimal WW is estimated with error that is correlated with the moment conditions, and the second step can be more biased than the first. The choices seen in applied work, from the simplest up:

Many ways to skin a cat, and the choice should be reported with the estimates.

The test of overidentifying restrictions

With more moments than parameters the criterion is not zero at the optimum, and its size says whether the extra moments are compatible with the model.

The test is valid only with the optimal weighting matrix: with any other WW the criterion at the optimum has a different distribution. And it tests the moments chosen, not the model: a model that fits three moments can be rejected by a fourth.

All three weighting matrices recover β=0.92\beta = 0.92 and σ=0.5\sigma = 0.5 within one standard error, in under a second each, and the standard errors shrink as the weighting improves. The JJ-test does not reject: the third moment is compatible with a model that fits the first two, as it should be when the data come from the model itself.

The formula is not the only way to a standard error. A bootstrap resamples the individuals, re-runs the whole two-step estimation with a fresh simulation seed, and reports the spread of the estimates across replications.

It costs hundreds of estimations, minutes here and days in a large model, but it needs no Jacobian and no asymptotic argument. The Monte Carlo of the next class is the same idea with the true parameters known.

  • The standard errors with the identity matrix are larger than with the optimal one, yet the point estimates are nearly the same. When would they differ a lot?

  • The JJ-test uses N/(1+1/S)N / (1 + 1/S). What happens to it if SS is forgotten in the normalization?

Choosing the moments

The choice of moments is the crucial part of an MSM estimation, and more art than science. The principles:

The figure maps the criterion over (β,σ)(\beta, \sigma) with the diagonal weighting matrix, with all three moments on the left and with the two wealth moments only on the right.

Source

With three moments the criterion has one basin around the truth. With the two wealth moments only, the basin stretches into a valley: a lower β\beta with a higher σ\sigma produces nearly the same mean and spread of wealth, impatience traded against precautionary saving.

The rank condition still holds along the valley, DD has rank two, but its columns are nearly collinear: the standard errors explode and an optimizer stops anywhere along the floor. The consumption moment breaks the trade-off because σ\sigma moves consumption growth and β\beta does not.

Where it breaks, in applications:

Andrews et al. (2017) give a measure of what each moment contributes to each estimate, Λ=−(DTWD)−1DTW\Lambda = -(D^T W D)^{-1} D^T W, the matrix that maps a perturbation of the moments into a perturbation of the estimates. It is a by-product of the standard errors and belongs in every MSM paper.

  • Which moments of the retirement data of Class 18 would identify the disutility of work δ\delta, and which the taste shock scale σ\sigma?

  • Wealth is measured with error in survey data. Which of the three moments above is hurt most?

MSM in practice

Why is the method so widely used in applied work?

The price is efficiency: the standard errors are larger than those of the MLE, the weighting matrix is often simplified because of its small-sample bias, and the choice of moments is a judgment call that has to be defended. Two relatives extend the idea: indirect inference Gourieroux et al., 1993Smith, 1993 matches the coefficients of an auxiliary model, a regression or a VAR, estimated on the data and on the simulations, and simulated moments of time series Lee & Ingram, 1991Duffie & Singleton, 1993 match autocovariances of one long simulated path.

Two life-cycle applications of the kind we estimate next class:

Iskhakov & Keane (2021) estimate a dynamic model of labor supply, savings and human capital on Australian survey data by MSM, and use it to evaluate a reform of the pension system: the whole arc from model to counterfactual in one paper.

  • An MSM paper reports a table of data moments and simulated moments at the estimates. What should the reader look for in it beyond the fit?

  • The counterfactual changes a policy parameter and simulates the model again. Which of the sources of noise in the estimates carry over to the counterfactual?

References
  1. McFadden, D. (1989). A Method of Simulated Moments for Estimation of Discrete Response Models Without Numerical Integration. Econometrica, 57(5), 995. 10.2307/1913621
  2. Pakes, A., & Pollard, D. (1989). Simulation and the Asymptotics of Optimization Estimators. Econometrica, 57(5), 1027–1057. 10.2307/1913622
  3. Hansen, L. P. (1982). Large Sample Properties of Generalized Method of Moments Estimators. Econometrica, 50(4), 1029–1054. 10.2307/1912775
  4. Corbae, D., & Guvenen, F. (2024). Method of Moments Estimators. In Quantitative Economics with Heterogeneity: A Guidebook. Princeton University Press.
  5. Altonji, J. G., & Segal, L. M. (1996). Small-Sample Bias in GMM Estimation of Covariance Structures. Journal of Business & Economic Statistics, 14(3), 353–366. 10.1080/07350015.1996.10524661
  6. Andrews, I., Gentzkow, M., & Shapiro, J. M. (2017). Measuring the Sensitivity of Parameter Estimates to Estimation Moments. The Quarterly Journal of Economics, 132(4), 1553–1592. 10.1093/qje/qjx023
  7. Gourieroux, C., Monfort, A., & Renault, E. (1993). Indirect Inference. Journal of Applied Econometrics, 8(S1), S85–S118. 10.1002/jae.3950080507
  8. Smith, A. A., Jr. (1993). Estimating Nonlinear Time-Series Models Using Simulated Vector Autoregressions. Journal of Applied Econometrics, 8(S1), S63–S84. 10.1002/jae.3950080506
  9. Lee, B.-S., & Ingram, B. F. (1991). Simulation estimation of time-series models. Journal of Econometrics, 47(2), 197–205. 10.1016/0304-4076(91)90098-X
  10. Duffie, D., & Singleton, K. J. (1993). Simulated Moments Estimation of Markov Models of Asset Prices. Econometrica, 61(4), 929–952. 10.2307/2951768
  11. Gourinchas, P.-O., & Parker, J. A. (2002). Consumption over the Life Cycle. Econometrica, 70(1), 47–89. 10.1111/1468-0262.00269
  12. French, E. (2005). The Effects of Health, Wealth, and Wages on Labour Supply and Retirement Behaviour. The Review of Economic Studies, 72(2), 395–427. 10.1111/j.1467-937X.2005.00337.x
  13. Iskhakov, F., & Keane, M. (2021). Effects of taxes and safety net pensions on life-cycle labor supply, savings and human capital: The case of Australia. Journal of Econometrics, 223(2), 401–432. 10.1016/j.jeconom.2020.01.023
  14. Adda, J., & Cooper, R. W. (2023). Dynamic Economics: Quantitative Methods and Applications. MIT Press. https://mitpress.mit.edu/9780262547888/dynamic-economics