Algorithm Search⌘K

Techniqueintro

Method of moments

Also called moment matching estimation.

Estimate parameters by setting the first few sample moments equal to the population moments and solving for the parameters. Simple and consistent, but often not efficient.

The method of moments is a recipe for building an estimator: write the first kk population moments as functions of the kk unknown parameters, replace them by the sample moments, and solve the kk equations for the parameters. The sample moments converge to the population moments by the law of large numbers, so the estimate is consistent whenever the moment map can be inverted continuously. It needs no likelihood and often has a closed form, but it is usually less precise than maximum likelihood and can give values that the data rule out.

In plain words

A model with unknown numbers predicts what the average of the data should be, what the average of the squares should be, and so on. Compute those averages from the data you have. Then choose the unknown numbers so that the model's predictions match what you computed. With two unknowns you match two averages, with three unknowns three.

The idea is old and simple, and it often needs only a little algebra. With a lot of data the averages settle down, so the answer settles near the truth. With little data, or a model that the data fit badly, the answer can be poor or even impossible, such as a negative count.

When it applies

  • The data X1,…,XnX_1, \ldots, X_n are iid with law PθP_\theta, θ∈Θ⊆Rk\theta \in \Theta \subseteq \mathbb{R}^k. The method extends to stationary data whose sample moments converge, as for the Yule-Walker equations.
  • There are functions g1,…,gkg_1, \ldots, g_k with Eθ∣gj(X)∣<∞\mathbb{E}_\theta \lvert g_j(X) \rvert < \infty, usually gj(x)=xjg_j(x) = x^j. Write μj(θ)=Eθ[gj(X)]\mu_j(\theta) = \mathbb{E}_\theta[g_j(X)] and μ(θ)=(μ1(θ),…,μk(θ))\mu(\theta) = (\mu_1(\theta), \ldots, \mu_k(\theta)).
  • The moment map μ:Θ→Rk\mu: \Theta \to \mathbb{R}^k is one-to-one (the parameter is identified by these moments), and the equations can be solved, in closed form or numerically.
  • For consistency, μ−1\mu^{-1} must be continuous at μ(θ)\mu(\theta). For a n\sqrt n normal limit, Eθ[gj(X)2]<∞\mathbb{E}_\theta[g_j(X)^2] < \infty and μ\mu must be differentiable with an invertible Jacobian.

The template

  1. MOMENT-ESTIMATE(x_1, ..., x_n)
  2. 1choose MOMENT-FUNCTIONS g_1, ..., g_k ▷ hole: usually g_j(x) = x^j
  3. 2for j ← 1 to k do
  4. 3m_j ← (1/n) Σ_i g_j(x_i) ▷ sample moments
  5. 4write MOMENT-MAP μ_j(θ) = E_θ[g_j(X)], j = 1..k ▷ hole: from the model
  6. 5θ̂ ← SOLVE(μ(θ) = m) ▷ hole: algebra or a root finder
  7. 6if θ̂ does not exist or lies outside Θ then
  8. 7θ̂ ← REPAIR(m) ▷ hole: report, project or switch method
  9. 8return θ̂ and the plug-in estimate ψ(θ̂)

The holes are the choice of moment functions (line L1), the moment map of the model (line L4), the solver (line L5) and the rule for an impossible solution (line L7). Central moments may replace raw ones: matching EX\mathbb{E}X and EX2\mathbb{E}X^2 is the same as matching the mean and the variance E(X−EX)2\mathbb{E}(X - \mathbb{E}X)^2, with the sample variance taken with divisor nn, σ^2=m2−m12\hat\sigma^2 = m_2 - m_1^2. Say which divisor is used; the sample variance S2S^2 with divisor n−1n - 1 gives a slightly different, equally consistent estimator.

Why it is consistent. Fix θ\theta. By the law of large numbers, m=(m1,…,mk)→μ(θ)m = (m_1, \ldots, m_k) \to \mu(\theta) in probability. If μ−1\mu^{-1} is continuous at μ(θ)\mu(\theta) and defined on a neighbourhood of it, then θ^=μ−1(m)→μ−1(μ(θ))=θ\hat\theta = \mu^{-1}(m) \to \mu^{-1}(\mu(\theta)) = \theta in probability, because continuous maps keep consistency (proved on consistent estimator). The event that line L7 is needed has probability tending to 0. This is proved; it holds for every θ\theta that meets the conditions.

The asymptotic law. Let Σ(θ)\Sigma(\theta) be the covariance matrix of (g1(X),…,gk(X))(g_1(X), \ldots, g_k(X)), assumed finite, and J(θ)=∂μ/∂θJ(\theta) = \partial\mu/\partial\theta, assumed invertible and continuous. The multivariate central limit theorem gives n(m−μ(θ))→N(0,Σ)\sqrt n (m - \mu(\theta)) \to N(0, \Sigma), and the delta method applied to μ−1\mu^{-1} gives

n(θ^−θ)→N(0,  J−1ΣJ−T)in distribution.\sqrt n(\hat\theta - \theta) \to N\big(0,\; J^{-1} \Sigma J^{-\mathsf T}\big) \quad \text{in distribution}.

Plugging θ^\hat\theta into this matrix gives standard errors.

Classic examples

Normal. For N(μ,σ2)N(\mu, \sigma^2), EX=μ\mathbb{E}X = \mu and EX2=σ2+μ2\mathbb{E}X^2 = \sigma^2 + \mu^2, so μ~=xˉ\tilde\mu = \bar x and σ~2=m2−m12=σ^2\tilde\sigma^2 = m_2 - m_1^2 = \hat\sigma^2, the divisor-nn variance. For x=(3,7,7,9,14)x = (3, 7, 7, 9, 14) this is μ~=8\tilde\mu = 8 and σ~2=64/5=12.8\tilde\sigma^2 = 64/5 = 12.8. Here the method agrees with maximum likelihood.

Gamma. For the gamma law with shape α>0\alpha > 0 and scale β>0\beta > 0, the mean is αβ\alpha\beta and the variance is αβ2\alpha\beta^2. Solving gives

α~=xˉ2/σ^2,β~=σ^2/xˉ.\tilde\alpha = \bar x^2/\hat\sigma^2, \qquad \tilde\beta = \hat\sigma^2/\bar x.

On the same data, α~=64/12.8=5\tilde\alpha = 64/12.8 = 5 and β~=12.8/8=1.6\tilde\beta = 12.8/8 = 1.6; check: 5⋅1.6=85 \cdot 1.6 = 8 and 5⋅1.62=12.85 \cdot 1.6^2 = 12.8. The maximum likelihood estimate of α\alpha has no closed form and needs a root finder such as the Newton-Raphson method; the moment estimate is a common starting point for it.

Binomial with both parameters unknown. For Binomial(k,p)(k, p) counts, the mean is kpkp and the variance is kp(1−p)kp(1-p), so p~=1−σ^2/xˉ\tilde p = 1 - \hat\sigma^2/\bar x and k~=xˉ2/(xˉ−σ^2)\tilde k = \bar x^2/(\bar x - \hat\sigma^2) (Casella and Berger, Section 7.2.1). For the counts (0,0,0,1,9)(0, 0, 0, 1, 9), xˉ=2\bar x = 2 and σ^2=82/5−4=62/5\hat\sigma^2 = 82/5 - 4 = 62/5, so p~=−26/5\tilde p = -26/5 and k~=−5/13≈−0.385\tilde k = -5/13 \approx -0.385. Both lie outside Θ={1,2,…}×(0,1)\Theta = \{1, 2, \ldots\} \times (0, 1). This happens whenever σ^2≥xˉ\hat\sigma^2 \ge \bar x, a sample that is more spread out than any binomial law with that mean.

Mixtures. Pearson (1894) fitted a mixture of two normal laws, five parameters, to measurements of crabs by matching five moments. The equations reduce to one polynomial equation of degree nine, which he solved by hand. The modern alternative is expectation-maximization on the Gaussian mixture model.

Autoregressions. The Yule-Walker equations match the sample autocovariances of a stationary series with those of an autoregressive model; for AR(1), ϕ~=r1/r0\tilde\phi = r_1/r_0.

Variations

  • Generalized method of moments. With more moment conditions Eθ[g(X,θ)]=0\mathbb{E}_\theta[g(X, \theta)] = 0 than parameters, the equations cannot all hold on data, and the generalized method of moments minimizes a weighted quadratic form in the sample moments instead. The plain method is the exactly identified case.
  • Estimating equations. Matching 1n∑ig(xi,θ)=0\frac1n \sum_i g(x_i, \theta) = 0 for functions that depend on θ\theta is an M-estimator. Maximum likelihood is the case gg = the score, which shows that the right moments can recover full efficiency.
  • Other moments. Probability-weighted moments, L-moments, factorial moments for counts and moments of log⁡X\log X are the same template with other gjg_j.
  • Matching other summaries. Matching sample quantiles to population quantiles is the same idea with a different summary; it does not need any moments to exist.
  • Simulated moments. When μ(θ)\mu(\theta) has no formula, estimate it by simulation at each trial θ\theta and solve by a stochastic search.

Pitfalls

  • Estimates the data rule out. For iid Uniform(0,θ)(0, \theta), EX=θ/2\mathbb{E}X = \theta/2 gives θ~=2xˉ\tilde\theta = 2\bar x. For the data (1,2,3,10)(1, 2, 3, 10), θ~=8\tilde\theta = 8, while the largest observation is 10, so θ≥10\theta \ge 10 is certain. The estimate is still inside Θ=(0,∞)\Theta = (0, \infty); truly impossible values come from examples such as the binomial one above.
  • Low efficiency. In the same uniform model, Var⁡(2Xˉ)=θ2/(3n)\operatorname{Var}(2\bar X) = \theta^2/(3n), while the unbiased estimator n+1nmax⁡iXi\frac{n+1}{n}\max_i X_i has variance θ2/(n(n+2))\theta^2/(n(n+2)). The ratio is (n+2)/3(n+2)/3, so the moment estimator needs about n2/3n^2/3 observations for the accuracy that the maximum reaches with nn. Fisher (1922) used efficiency to compare the method with maximum likelihood for Pearson's curves.
  • The choice of moments matters. For Poisson data, EX=λ\mathbb{E}X = \lambda and Var⁡X=λ\operatorname{Var}X = \lambda, so both xˉ\bar x and σ^2\hat\sigma^2 are moment estimators of λ\lambda. On (3,7,7,9,14)(3, 7, 7, 9, 14) they give 8 and 12.8. Use the lowest moments that identify θ\theta; higher moments have larger variance and need more moments to be finite.
  • Moments that do not exist. For Cauchy data no moment exists, and Xˉ\bar X does not converge. Use quantiles or the likelihood.
  • Several roots, or none. Nonlinear moment equations can have several solutions in Θ\Theta, as Pearson's degree nine equation does, or none. The template must say which root is reported.
  • Cancellation. Computing m2−m12m_2 - m_1^2 in floating point loses digits when ∣xˉ∣\lvert \bar x \rvert is large compared with the spread. Compute the central moments by a two-pass formula or by Welford's algorithm.

Exercises

  1. For iid exponential data with rate λ\lambda (EX=1/λ\mathbb{E}X = 1/\lambda), find the moment estimator, and use the delta method to find its asymptotic variance. Answer. λ~=1/xˉ\tilde\lambda = 1/\bar x. With g(t)=1/tg(t) = 1/t, g′(1/λ)2Var⁡X=λ4⋅λ−2=λ2g'(1/\lambda)^2 \operatorname{Var}X = \lambda^4 \cdot \lambda^{-2} = \lambda^2, so n(λ~−λ)→N(0,λ2)\sqrt n(\tilde\lambda - \lambda) \to N(0, \lambda^2). This is also the maximum likelihood estimator.
  2. For iid Uniform(a,b)(a, b), find the moment estimators from the mean and the divisor-nn variance, and evaluate them on (3,7,7,9,14)(3, 7, 7, 9, 14). Answer. The mean is (a+b)/2(a + b)/2 and the variance is (b−a)2/12(b - a)^2/12, so a~=xˉ−3σ^2\tilde a = \bar x - \sqrt{3\hat\sigma^2} and b~=xˉ+3σ^2\tilde b = \bar x + \sqrt{3\hat\sigma^2}. Here 38.4=6.197\sqrt{38.4} = 6.197, so (a~,b~)=(1.803,14.197)(\tilde a, \tilde b) = (1.803, 14.197); both agree with the data, since 1.803<31.803 < 3 and 14.197>1414.197 > 14.
  3. For the beta law with parameters α,β>0\alpha, \beta > 0, with mean α/(α+β)\alpha/(\alpha+\beta) and variance αβ/((α+β)2(α+β+1))\alpha\beta/((\alpha+\beta)^2(\alpha+\beta+1)), find the moment estimators and the condition on the data for them to lie in Θ\Theta. Answer. With c=xˉ(1−xˉ)/σ^2−1c = \bar x(1 - \bar x)/\hat\sigma^2 - 1, α~=xˉc\tilde\alpha = \bar x c and β~=(1−xˉ)c\tilde\beta = (1 - \bar x) c. They are positive exactly when 0<xˉ<10 < \bar x < 1 and σ^2<xˉ(1−xˉ)\hat\sigma^2 < \bar x(1 - \bar x).
  4. Show that for Bernoulli(p)(p) data the moment estimator from EX\mathbb{E}X and the maximum likelihood estimator are both xˉ\bar x, and that matching EX2\mathbb{E}X^2 instead gives nothing new. Answer. ℓ′(p)=nxˉ/p−n(1−xˉ)/(1−p)=0\ell'(p) = n\bar x/p - n(1 - \bar x)/(1 - p) = 0 gives p=xˉp = \bar x. Since X2=XX^2 = X for 0 and 1 data, m2=m1m_2 = m_1.
  5. Prove the efficiency ratio (n+2)/3(n+2)/3 for the uniform example. Answer. Var⁡X=θ2/12\operatorname{Var}X = \theta^2/12, so Var⁡(2Xˉ)=θ2/(3n)\operatorname{Var}(2\bar X) = \theta^2/(3n). The maximum MM has density ntn−1/θnn t^{n-1}/\theta^n on [0,θ][0, \theta], so EM=nθ/(n+1)\mathbb{E}M = n\theta/(n+1) and EM2=nθ2/(n+2)\mathbb{E}M^2 = n\theta^2/(n+2), which give Var⁡(n+1nM)=θ2/(n(n+2))\operatorname{Var}\big(\tfrac{n+1}{n}M\big) = \theta^2/(n(n+2)). Divide.

References

  1. Karl Pearson, Contributions to the mathematical theory of evolution, Philosophical Transactions of the Royal Society A 185, 1894, pp. 71 to 110 (a mixture of two normal curves fitted by its first five moments, through an equation of degree nine)
  2. George Casella and Roger L. Berger, Statistical Inference, second edition, Duxbury, 2002, Section 7.2.1 (method of moments, with the binomial example in which both k and p are unknown)
  3. Larry Wasserman, All of Statistics, Springer, 2004, Section 9.2 (method of moments, with its consistency and asymptotic normality)
  4. R. A. Fisher, On the mathematical foundations of theoretical statistics, Philosophical Transactions of the Royal Society A 222, 1922, pp. 309 to 368 (efficiency, and the loss of efficiency of the method of moments compared with maximum likelihood)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples