Home page for accesible maths 2.4 Fitting Distributions to Data

Style control - access keys in brackets

Font (2 3) - + Letter spacing (4 5) - + Word spacing (6 7) - + Line spacing (8 9) - +

2.4.1 Method of Moments

In this course we will use the method of moments to estimate the parameters of any distributions that we fit. In Math235 you will learn about an alternative method called Maximum Likelihood Estimation.

What is a moment?

In essence, a moment measures shape. For random variables this characterizes the shape of the probability distribution. For example, the first moment is the mean of the distribution. In general, the kth moment for a random variable, X, is defined as:

μk=𝔼(Xk).

Thus the first four moments are:

μ1 =𝔼(X);
μ2 =𝔼(X2);
μ3 =𝔼(X3);
μ4 =𝔼(X4).

Sample moments

Just as the sample mean is an estimate of the population mean, the sample moments are estimates of the population moments. Thus the kth sample moment, for data {xi}i=1n is defined as:

1ni=1nxik.

Method of moments estimators

The method of moments estimator θ^ of a set of parameters θ is defined as the solution to the set of equations:

𝔼(Xk;θ^)=1ni=1nxik,

i.e. the population moment equated to the sample moment.

Theoretically you could use any kth moment to estimate θ^ but typically we use the first p moments where θ is p-dimensional. This amounts to solving a system of p equations.

Example 2.4.1

Let X1,X2,,Xn be a random sample from the probability density given by

f(x)=θsin2x  0xπ

Find the method of moments estimator for θ.

Answer. The distribution has one parameter so we use the first moment equation,

𝔼(X;θ^)=1ni=1nxi.

In order to solve this we first need to calculate the expectation,

𝔼(X;θ) =0πxθsin2(x)dx
=θ[sin(x2)4-xsin2x4+x24]0π
=θπ24.

Substituting this into the first moment equation gives,

𝔼(X;θ^) =1ni=1nxi
  θ^π24 =1ni=1nxi
  θ^ =4i=1nxinπ2.

Derivations for common distributions

The following paragraphs detail the derivations of the method of moments estimates for common distributions.

Bernoulli

The Bernoulli distribution has one parameter, θ and mean θ. The method of moments estimate is thus:

𝔼(X;θ^) =1ni=1nxi
θ^ =1ni=1nxi,

i.e. the estimate of the probability of success is the average number of successes observed in the data. This is probably the estimate you would have thought to use anyway!

Example 2.4.2

Penalty shoot-outs were introduced into World Cup finals in 1982. Since then 26 matches have been decided by penalties, see Table 2.2 for details. In total 240 penalties have been taken resulting in 170 goals. Calculate the method of moments estimate for the probability of a goal from a single shot, be careful to state your assumptions.

Answer. As the outcome of a penalty is goal or no goal, this is a binary response. The Bernoulli distribution seems appropriate to model this but we are making the following assumptions by using it:

  1. 1.

    the probability of a goal is the same for each shot taken;

  2. 2.

    whether or not a goal is scored at each penalty is independent of all the other penalties taken.

Answer. Assuming a Bernoulli distribution the method of moments estimate is number of successes/total number of tries, i.e. θ^=170/240=0.708.

Example 2.4.3

Are the assumptions you made in example 2.4.2 appropriate?

Answer. It is unlikely that the assumptions made are appropriate. This is because of several reasons, including:

  • one person could have taken multiple penalties (across years)

  • one person could be better or worse at taking penalties than another

  • the current ‘‘score’’ could impact on the probability of scoring (mental pressure).

Year Teams Scores Aggregate
1982 West Germany v France 5/5-4/5 9/10
1986 France v Brazil 4/5-3/4 7/9
West Germany v Mexico 4/4-1/3 5/7
Belgium v Spain 5/5-4/5 9/10
1990 Rep. of Ireland v Romania 5/5-4/5 9/10
Argentina v Yugoslavia 3/5-2/5 5/10
Argentina v Italy 4/5-3/5 7/10
West Germany v England 4/5-3/5 7/10
1994 Bulgaria v Mexico 3/4-1/4 4/8
Sweden v Romania 5/6-4/6 9/12
Brazil v Italy 3/5-2/5 5/10
1998 Argentina v England 4/5-3/5 7/10
France v Italy 4/5-3/5 7/10
Brazil v Netherlands 4/4-2/4 6/8
2002 Spain v Rep. of Ireland 3/5-2/5 5/10
South Korea v Spain 5/5-3/4 8/9
2006 Ukraine v Switzerland 3/4-0/3 3/7
Germany v Argentina 4/4-2/3 6/7
Portugal v England 3/5-1/4 4/9
Italy v France 5/5-3/5 8/10
2010 Paraguay v Japan 5/5-3/4 8/9
Uruguay v Ghana 4/5-2/4 6/9
2014 Brazil v Chile 3/5-2/5 5/10
Costa Rica v Greece 5/5-3/4 8/9
Netherlands v Costa Rica 4/4-3/5 7/9
Netherlands v Argentina 2/4-4/4 6/8
Table 2.2: Summary of penalty shoot outs in the World Cup.

Geometric

The Geometric distribution has one parameter, θ and mean 1-θθ. The method of moments estimate is thus:

𝔼(X;θ^) =1ni=1nxi
1-θ^θ^ =1ni=1nxi
θ^ =nn+i=1nxi.

As n is the total number of successes and n+i=1nxi is the total number of attempts, this too is probably the estimate you would have thought to use.

Example 2.4.4

The UK open data initiative publishes statistics on pass rates for driving tests: 2020https://www.gov.uk/government/collections/driving-tests-and-instructors-statistics . A bar plot of the data is in Figure LABEL:drivingtestpass. What distribution would you use to model this data? Calculate the method of moments estimate of its parameter(s).

R> data(driving1213)
R> tot.pass=colSums(driving1213[,c(3,6,9,12,15,18)])
R> barplot(tot.pass, names.arg=c(’1st’,"2nd","3rd","4th","5th","6th+"))

Answer. The data is for number of times until a person passes their driving test. Once passed you do not take the test again (unless your license is removed). This sounds like a Geometric distribution where trials continue until a positive outcome is seen. The method of moments estimate for a Geometric distribution is total number of successes divided by total number of attempts, thus for the driving data, this is approximately θ^=695543/1470463=0.473 as we don’t know how many tests those taking 6+ actually took.

sum(tot.pass)/sum(tot.pass*1:6)

Poisson

The Poisson distribution has one parameter, θ and mean θ. The method of moments estimate is thus:

𝔼(X;θ^) =1ni=1nxi
θ^ =1ni=1nxi,

the same as in the Bernoulli case.

Uniform

The Uniform distribution has two parameters θ=(a,b) with mean (a+b)2 and variance (a-b)212. The method of moments estimate is thus the solution of the simultaneous equations:

𝔼(X;θ^) =1ni=1nxi (2.1)
𝔼(X2;θ^) =1ni=1nxi2. (2.2)

Recall that Var(X)=𝔼(X2)-𝔼(X)2 so that Equation (2.2) can be written as

𝔼(X2;θ^) =1ni=1nxi2
Var(X)+𝔼(X)2 =1ni=1nxi2
(a^-b^)212+(a^+b^)24 =1ni=1nxi2. (2.3)

Substituting in the definition of the population mean and rearranging Equation (2.1) we get,

a^=2ni=1nxi-b^.

Substituting this into Equation (2.3) and rearranging we get,

b^=1ni=1nxi+3n[i=1nxi2-1n(i=1nxi)2]=x¯+3(n-1)ns(x).

Substituting our estimate of b^ back into our estimate for a^ gives,

a^=1ni=1nxi-3n[i=1nxi2-1n(i=1nxi)2]=x¯+3(n-1)ns(x).

Normal

The Normal distribution has two parameters θ=(μ,σ) with mean μ and variance σ2. The method of moments estimate is thus the solution of the simultaneous equations:

𝔼(X;θ^) =1ni=1nxi (2.4)
𝔼(X2;θ^) =1ni=1nxi2. (2.5)

Taking Equation (2.4) we have,

𝔼(X;θ^) =1ni=1nxi
μ^ =1ni=1nxi. (2.6)

Recall that Var(X)=𝔼(X2)-𝔼(X)2 so that Equation (2.5) can be written as

𝔼(X2;θ^) =1ni=1nxi2
Var(X)+𝔼(X)2 =1ni=1nxi2
σ^2+μ^2 =1ni=1nxi2.

Now substituting in μ^ from Equation (2.6) gives

σ^2+μ^2 =1ni=1nxi2
σ^2 =1ni=1nxi2-(1ni=1nxi)2
σ^2 =(n-1)ns2(x).

Whilst most of the formulae above are logical estimates of the parameters in question, it is crucial that you be able to derive and justify your use of them. Many of you may blindly believe that the sky is blue but how many of you can convince someone who insists that the sky is green using scientific and logical arguments? It is at this time in your mathematical career that you need to be making sure that you do not blindly believe and ask why. Sometimes you may not yet have the tools to understand the answer and thus may be told ‘‘you will find out in MathXXX’’ but you should be asking the questions.

Example 2.4.5

Let X1,X2,,Xn be a random sample from the probability mass function given by

pX(x)={1m+1,forx=0,1,2,,m0,otherwise.

Find the method of moments estimator for m.

Answer. There is one parameter so we use the first moment equation:

𝔼(X;m^)=1ni=1nxi

Firstly we need to calculate the expectation of the pmf:

𝔼(X;m) =x=0xpX(x)
=x=0mx1m+1
=1m+1x=0mx
=1m+112m(m+1)=m2.

Substituting this into the first moment equation we get:

m^2 =1ni=1nxi
  m^ =2ni=1nxi.



TIP: General Approach to MoM questions The general approach to answer these questions is: 1. Decide on which distribution to use and what the parameters are. 2. Write down the moment equations (remember: 1 equation per parameter you have to estimate) 3. Calculate the moments using the distribution from (1). 4. Plug-in the moments calculated in (3) into the moment equations from (2) 5. Solve the moment equations for the parameters (might have to use simultaneous equations for multi-parameter problems). This is the general estimator for the distribution of interest. 6. Plug-in specific numbers for the scenario, if given in the question. This is the specific parameter estimate for the data in question.
Now that we can fit parametric models to data, the following section discusses how to assess whether a specific parametric model may be an appropriate approximation.