Artificial Intelligence 🤖
Estimators and Point Estimation

Estimators and Point Estimation

This section investigates methods for estimating values for model parameters using sample observations. Specifically, a statistic is referred to as an estimator if we use it as a value for θ\theta; we shall denote this estimator as θ^\hat{\theta}. It is important to note here that θ^\hat{\theta} is a random variable.

Bias-Variance Decomposition

At this point, we are going to digress a bit and discuss some important properties of point estimators. First, we define the Mean Squared Error (MSE) of an estimator θ^\hat{\theta} of a parameter θ\theta to be:

MSE(θ^)=E[(θ^θ)2]M S E(\hat{\theta})=E\left[(\hat{\theta}-\theta)^{2}\right]

Starting from the definition of MSE, we can expand and contract the quadratic terms to derive a useful expression:

MSE(θ^)=(E[θ^2]E[θ^]2)+(E[θ^]θ)2=Var(θ^)+Bias(θ^)2\begin{aligned} & \operatorname{MSE}(\hat{\theta})=\left(E\left[\hat{\theta}^{2}\right]-E[\hat{\theta}]^{2}\right)+(E[\hat{\theta}]-\theta)^{2} \\ & =\operatorname{Var}(\hat{\theta})+\operatorname{Bias}(\hat{\theta})^{2} \end{aligned}

We can interpret each of the terms as follows:

Bias(θ^)=(E[θ^]θ)=0 if ’unbiased’ Var(θ^)= how sensitive an estimate is to randomness inherent in the data \begin{aligned} \operatorname{Bias}(\hat{\theta}) & =(E[\hat{\theta}]-\theta)=0 \text { if 'unbiased' } \\ \operatorname{Var}(\hat{\theta}) & =\text { how sensitive an estimate is to randomness inherent in the data } \end{aligned}

An estimator θ^\hat{\theta} of a parameter θ\theta is said to be consistent if

MSE(θ^)0 as nM S E(\hat{\theta}) \rightarrow 0 \text { as } n \rightarrow \infty

A consistent estimator converges to the parameter as the sample size increases.

Maximum-Likelihood Estimation (MLE)

Maximum-Likelihood Estimation, or 'MLE' for short, is an extremely important technique in probabilistic modelling as it provides a framework for estimating parameters for any model from a given sample DD. The main idea behind this approach is that even though we cannot estimate the true parameter of the population correctly (because we cannot sample the whole population), we can do no better than to find the parameter of the distribution that is most likely to have generated the sample. Given some sample dataset D={D1,D2,,Dn}D=\left\{D_{1}, D_{2}, \ldots, D_{n}\right\}, we can define a likelihood function L(θ)L(\theta) as the probability that the sample data DD was generated given some value of the model parameter θ\theta :

L(θ)=P(Dθ)L(\theta)=P(D \mid \theta)

Since we assume our samples DD are independent and identically distributed (i.i.d.), this greatly simplifies to:

L(θ)=P(Dθ)=i=1nfX(Diθ)L(\theta)=P(D \mid \theta)=\prod_{i=1}^{n} f_{X}\left(D_{i} \mid \theta\right)

We define the Maximum-Likelihood Estimate (MLE) of a parameter θ\theta to be θ^MLE\hat{\theta}_{\mathrm{MLE}} given by:

θ^MLE=argmaxθL(θ)\hat{\theta}_{\mathrm{MLE}}=\underset{\theta}{\arg \max } L(\theta)

Note: In order to be succinct, we will use θ^\hat{\theta} to refer to θ^MLE\hat{\theta}_{\mathrm{MLE}} throughout this section.

Obtaining θ^\hat{\theta} is often a straightforward process that involves writing down the likelihood function L(θ)L(\theta), and then finding the value for θ\theta that maximises it. Often it is also beneficial to verify that the estimate is indeed a maximum. In this course we will only be concerned with likelihood functions that can be directly maximised using methods from calculus, however, we note that more advanced techniques (e.g. nonlinear optimisation) may be required to obtain the MLE estimates in general.

Example: Bernoulli MLE

We will highlight the steps behind the process for obtaining a Maximum-Likelihood Estimate of θ\theta using the Bernoulli model of flipping a coin; here the model parameter we are estimating is θ=p\theta=p (i.e. the probability a coin flip is heads), as seen in Table 1.

  1. Writing Down the Likelihood Function Here we seek to estimate the probability that flipping a coin comes up heads (model parameter pp ). Let's say we toss the coin twenty times (n=20)(n=20) and produce the following sample DD :
D=(H,H,T,T,T,H,H,T,T,T,T,H,T,T,H,T,T,T,H,H)D=(H, H, T, T, T, H, H, T, T, T, T, H, T, T, H, T, T, T, H, H)

We know that each coin flip is a Bernoulli trial, with the probability of heads equal to θ=p\theta=p (we shall casually refer to this model parameter as θ\theta in the subsequent steps to illustrate the general process). Formally, we can express this as fX(Di=Hθ)=θf_{X}\left(D_{i}=H \mid \theta\right)=\theta, where Di=HD_{i}=H implies a 'heads' is observed in the ith i^{\text {th }} coin flip in the sequence.

It is often beneficial to apply zero/one encoding to our Bernoulli RV. That is use Di=1D_{i}=1 if the ith i^{\text {th }} coin flip was heads and 0 if it was tails. The complete probability mass function for the Bernoulli distribution can then be written as:

fX(Diθ)=θDi(1θ)1Dif_{X}\left(D_{i} \mid \theta\right)=\theta^{D_{i}}(1-\theta)^{1-D_{i}}

Since we perform each coin flip independently (i.e., i.i.d.), the total probability of observing DD (given the true parameter of a coin is θ\theta ) can be expressed as a product of each of the individual trials:

L(θ)=P(Dθ)=fX(D1θ)×fX(D2θ)×..×fX(Dnθ)=i=1nfX(Diθ)L(\theta)=P(D \mid \theta)=f_{X}\left(D_{1} \mid \theta\right) \times f_{X}\left(D_{2} \mid \theta\right) \times . . \times f_{X}\left(D_{n} \mid \theta\right)=\prod_{i=1}^{n} f_{X}\left(D_{i} \mid \theta\right)

Thus, the individual terms in likelihood function are simply the PMF or PDF fX(Diθ)f_{X}\left(D_{i} \mid \theta\right) under consideration evaluated at DiD_{i}. Note that this is always true for independent identically distributed (i.i.d.) experiments by definition and simplifies the overall calculations significantly. After we substitute in our expression for fX(Diθ)f_{X}\left(D_{i} \mid \theta\right) and re-arrange the equation, the expression for the likelihood of DD given θ\theta for this coin flip example becomes:

L(θ)=i=1nfX(Diθ)=i=1nθDi(1θ)1Di=θi=1nDi(1θ)i=1n(1Di)=θN(H)(1θ)N(T)\begin{aligned} L(\theta) & =\prod_{i=1}^{n} f_{X}\left(D_{i} \mid \theta\right)=\prod_{i=1}^{n} \theta^{D_{i}}(1-\theta)^{1-D_{i}} \\ & =\theta^{\sum_{i=1}^{n} D_{i}}(1-\theta)^{\sum_{i=1}^{n}\left(1-D_{i}\right)}=\theta^{N(H)}(1-\theta)^{N(T)} \end{aligned}

Where N(H)N(H) and N(T)N(T) are the total number of heads and tails observed in DD respectively, and n=n= N(H)+N(T)N(H)+N(T).

  1. Maximising the Likelihood Function We can now optimise the expression of L(θ)L(\theta) to obtain a MLE for θ\theta. In practice, however, it is advantageous to optimise the logarithm of this expression instead, i.e. the so-called log-likelihood function, L(θ)=logL(θ)\mathcal{L}(\theta)=\log L(\theta), as it transforms the series of multiplications into a summation, which results in a much easier function to optimise:
L(θ)=logL(θ)=N(H)log(θ)+N(T)log(1θ)\mathcal{L}(\theta)=\log L(\theta)=N(H) \log (\theta)+N(T) \log (1-\theta)

From calculus we know that a function is at a minimum, maximum or a saddle point if and only if it's derivative is zero. We can use this to find the maximum of the log-likelihood function L(θ)\mathcal{L}(\theta). However we need to note that our maximisation is constrained in this example by the fact that θ[0,1]\theta \in[0,1].

We can perform the maximisation to obtain the MLE in the coin flip case as follows:

dLdθ=0N(H)θN(T)1θ=0(1θ)N(H)θN(T)=0( assuming θ0,θ1)θ(N(H)+N(T))=N(H)\begin{array}{r} \frac{d \mathcal{L}}{d \theta}=0 \\ \frac{N(H)}{\theta}-\frac{N(T)}{1-\theta}=0 \\ (1-\theta) N(H)-\theta N(T)=0 \quad(\text { assuming } \theta \neq 0, \theta \neq 1) \\ \theta(N(H)+N(T))=N(H) \end{array}

Finally, we get that:

θ^=N(H)N(H)+N(T)=N(H)n=1niDi\hat{\theta}=\frac{N(H)}{N(H)+N(T)}=\frac{N(H)}{n}=\frac{1}{n} \sum_{i} D_{i}

That is, our maximum-likelihood estimate for the probability of the coin coming up heads is equal to the total number of heads observed in our sample data divided by the sample size nn, which is a relativelyintuitive way to estimate this probability. For the particular sample DD in this example, we find that θ^=820=0.4\hat{\theta}=\frac{8}{20}=0.4. We should also note that the last expression above is that of the sample mean, which makes sense since E[X]=p=θE[X]=p=\theta for the Bernoulli distribution, and we have just seen that this estimate improves with increasing sample size nn (see Figure 29).

  1. Verifying the Solution We can further use calculus to verify that the solution for number of heads we obtained is indeed the maximum by computing the second derivative of the function. If the parameter θ^\hat{\theta} is a local maximum then the second derivative of L\mathcal{L} at that point will be negative. We therefore want to verify:
L(θ=θ^)<0\mathcal{L}^{\prime \prime}(\theta=\hat{\theta})<0

Which is true in our case as L(θ^)=N(H)θ^2N(T)(1^θ)2\mathcal{L}^{\prime \prime}(\hat{\theta})=-\frac{N(H)}{\hat{\theta}^{2}}-\frac{N(T)}{(1 \hat{-} \theta)^{2}} is always negative for any θ^(0,1)\hat{\theta} \in(0,1).

Thus, the procedure for computing the maximum-likelihood estimate of a model parameter can be summarised as:

Maximum-Likelihood Estimation (MLE) procedure for an i.i.d. sample DD :

  1. Write down the likelihood function L(θ)=i=1nfX(Diθ)L(\theta)=\prod_{i=1}^{n} f_{X}\left(D_{i} \mid \theta\right), and take the logarithm of this function: L(θ)=logL(θ)\mathcal{L}(\theta)=\log L(\theta)
  2. Maximise the log-likelihood function L(θ)\mathcal{L}(\theta) with respect to θ\theta to obtain θ^\hat{\theta}
  3. Verify that the obtained θ^\hat{\theta} is indeed the maximum and within the correct range for θ\theta.

Let's see how this MLE procedure for estimating model parameters from sample data applies to another distribution from Table 1: The Poisson distribution.

Example: Maximum Likelihood Estimate for a Poisson Random Variable

Given a dataset D=(D1,D2,,Dn)D=\left(D_{1}, D_{2}, \ldots, D_{n}\right) of i.i.d. samples drawn from the Poisson distribution, derive the expression for the Maximum-Likelihood Estimate of λ\lambda.

Solution:

We approach this problem using the three-step procedure described above. The first step is to write down the likelihood function. By the definition of a Poisson random variable, each of the samples in the dataset have the probability:

fX(Diλ)=λDiDi!eλf_{X}\left(D_{i} \mid \lambda\right)=\frac{\lambda^{D_{i}}}{D_{i} !} e^{-\lambda}

The likelihood for the entire dataset DD is therefore:

L(λ)=i=1nfX(Diλ)=i=1nλDiDi!eλL(\lambda)=\prod_{i=1}^{n} f_{X}\left(D_{i} \mid \lambda\right)=\prod_{i=1}^{n} \frac{\lambda^{D_{i}}}{D_{i} !} e^{-\lambda}

We can factor and rearrange the likelihood above as follows:

L(λ)=i=1n1Di!i=1nλDieλ=(λi=1nDi)(enλ)i=1n1Di!\begin{aligned} L(\lambda) & =\prod_{i=1}^{n} \frac{1}{D_{i} !} \prod_{i=1}^{n} \lambda^{D_{i}} e^{-\lambda} \\ & =\left(\lambda^{\sum_{i=1}^{n} D_{i}}\right)\left(e^{-n \lambda}\right) \prod_{i=1}^{n} \frac{1}{D_{i} !} \end{aligned}

Taking the natural logarithm of the above, we the following expression for the log-likelihood:

L(λ)=lnL(λ)=ln(λ)[i=1nDi]nλ+ln[i=1n1Di!]\mathcal{L}(\lambda)=\ln L(\lambda)=\ln (\lambda)\left[\sum_{i=1}^{n} D_{i}\right]-n \lambda+\ln \left[\prod_{i=1}^{n} \frac{1}{D_{i} !}\right]

We can now directly maximise L\mathcal{L}, for λ0\lambda \geq 0 :

dLdλ=0i=1nDiλn=0( assuming λ0)\begin{aligned} \frac{d \mathcal{L}}{d \lambda} & =0 \\ \frac{\sum_{i=1}^{n} D_{i}}{\lambda}-n & =0 \quad(\text { assuming } \lambda \neq 0) \end{aligned} λ=θ^=i=1nDin\lambda=\hat{\theta}=\frac{\sum_{i=1}^{n} D_{i}}{n}

Therefore our MLE of λ\lambda is the sample mean once again!

We can verify that this is indeed the maximum by taking the second derivative of L\mathcal{L} and checking that it is negative at λ=θ^\lambda=\hat{\theta} :

L(λ=θ^)=i=1nDiλ2\mathcal{L}^{\prime \prime}(\lambda=\hat{\theta})=-\frac{\sum_{i=1}^{n} D_{i}}{\lambda^{2}}

Which is clearly negative for all values of θ^=λ\hat{\theta}=\lambda.

Remarks on MLE Maximum-likelihood estimation is a standard illustration of frequentist statistics. While the estimated parameter approaches the correct population parameter as the sample size nn approaches infinity, the estimates might deviate from the actual population parameter value for smaller sample sizes. None-the-less, an important advantage of maximum-likelihood estimation is that it produces consistent estimators (See Section 5.2.1; proof omitted here).

For instance, we estimated the θ^\hat{\theta} to be equal to 0.4 for the n=20n=20 coin-flip dataset used in this chapter, even though we used a fair coin to generate it. We were equally as likely to obtain the value 0.6 as well. In order to use statistics correctly, we need to be aware that parameter estimates are themselves stochastic, and be prepared to deal with the underlying uncertainty of these estimations. We therefore also need to consider interval estimation and statistical hypothesis testing as potential ways of dealing with this inherent randomness.