Accessible version · How to use this site with a screen reader · Course home
Day 4 Morning · Accessible lecture notes

Maximum likelihood

A screen-reader-friendly transcript of the lecture slides: all slide text, tables, figure descriptions, and speaker notes.

About these notes

Each section is one slide. Figures carry text descriptions where available. For the concepts with worked examples, also read the plain-language summary and lab for this session.

Slide 1

Speaker notes for this slide

a

Slide 2

What is Maximum Likelihood-I?

Slide 3: What is Maximum Likelihood-II?

L(p|x) = Prob(x|p)

Slide 4: What is Maximum Likelihood-II?

Parameters, data and error distributions:

Data

Parameter

Error

What are the data, parameters, and incorporation of error?

La = ℓ∞(1 − e−κa) + ε

ε ~ N(0, σ2)

Slide 5: What is Maximum Likelihood-III?

Figure 5.1. Four panels, each Age in years (x, 5 to 25) versus Length in cm (y, 0 to 120), showing candidate von Bertalanffy growth curves that rise then plateau.

5

Slide 6: Basics of Likelihood

The likelihood of the data is the product of the likelihoods of each data point

Notation often inconsistent, but better to put parameters conditional on data

The set of data Xi

Product of the PDF/Likelihood across all data points

L˜(p | {Xi}) = ∏i=1n f(Xi | p)

Slide 7: Further Likelihood Considerations-I

To compute the likelihood for a given set of parameters we need:

Model prediction

Data

f(x) = 1 / (σ √(2π)) · exp( −½ ((x − μ)/σ)2 )

L(a) = ℓ∞(1 − e−κa)

L = 1 / (√(2π) σ) · exp( −(L(a) − La)2 / (2σ2) )

Slide 8: Further Likelihood Considerations-II

dnorm(observed, expected, sigma)

In R, the term:

is evaluated using the expression

or in R:

The full likelihood is the product over all the data points:

prod(dnorm(observed_vector, expected_vector, sigma))

Note: The function dnorm returns the value of the normal distribution PDF given x, μ, and σ.

L = 1 / (√(2π) σ) · exp( −(L(a) − La)2 / (2σ2) )

L = ∏a 1 / (√(2π) σ) · exp( −(L(a) − La)2 / (2σ2) )

Slide 9: Back to our original problem

We can compare the four parameters choices using the following code (open R code):

Figure 9.1. Four panels, Age in years (x, 5 to 25) versus Length in cm (y, 0 to 120), each a von Bertalanffy growth curve for a different candidate parameter set.

Slide 10: Overview

Slide 11

Slide 12

We refer to the value for p that maximizes the likelihood function as the maximum likelihood estimate and denote it as p̂.

Is something missing? Why is this ok?

L(p) = p30 (1 − p)20

Slide 13

Figure 13.1. Line plot, probability p (x, 0.2 to 0.8) versus Likelihood (y, 0 to about 2e-15). The binomial likelihood peaks near p = 0.6, the maximum likelihood estimate.

See why normalizing constant doesn’t matter here?

Slide 14: Negative log-likelihoods

Rather than working with likelihoods we often work with negative log-likelihoods. Therefore, rather than maximizing the likelihood, we minimize the negative log-likelihood – this leads to same point estimates.

Figure 14.1. Line plot, probability p (x, 0.2 to 0.8) versus Negative log-Likelihood (y, 0 to 120). A U-shaped valley with minimum near p = 0.6, the estimate.

The estimate of p, p̂, is again 0.6.

Logs help with the tiny number problem, and negative works for numerical optimizers

−ln L = −30 ln p − 20 ln(1 − p)

Slide 15: A Poisson mixture problem

The blow rate for a given whale species is Poisson-distributed and it is “known” that the average number of blows in an interval for males and females is different. We monitor a population and find the following distribution of blow times.

Figure 15.1. Histogram of whale blow counts, Blows (x, 0 to 50) versus density (y, 0.00 to 0.04). Bimodal, consistent with a mixture of two Poisson components.

15

Slide 16

The Poisson distribution is:

16

Figure 16.1. Histogram of whale blow counts, Blows (x, 0 to 50) versus density (y, 0.00 to 0.04), bimodal, suggesting two overlapping Poisson blow-rate distributions.

How would you do this with linear models?

P(x | λ) = λx exp(−λ) / x!

P(x | p, λ1, λ2) = p λ1x exp(−λ1) / x! + (1 − p) λ2x exp(−λ2) / x!

Slide 17

17

Slide 18

The likelihood function is then:

18

P(x | p, λ1, λ2) = ∏i ( p λ1xᵢ exp(−λ1) / xi! + (1 − p) λ2xᵢ exp(−λ2) / xi! )

P(x | λ) = λx exp(−λ) / x!

Slide 19: Start by assuming we know Propn We now have a three dimensional likelihood surface

19

Slide 20

20

Slide 21

Figure 21.1. Three-dimensional perspective mesh of the negative log-likelihood surface over the two mean blow rates, axes Blow1 and Blow2 with height Likes; a single minimum.

This is a plot of the negative log-likelihood surface

21

Slide 22

22

Figure 22.1. Three-dimensional perspective wireframe of the negative log-likelihood, axes Blow1 (0 to 40) and Blow2 (0 to 60), vertical Likes axis, showing a curved valley.

Notice anything interesting about this likelihood surface?

Slide 23: The Optim/MLE routines

Function to be minimized

23

Slide 24: Some options for MLE-I

24

Note, “L-BFGS-B” allows you to bound the parameters

Slide 25: Question-1

Slide 26: Example 1 - revisited

Negative log-likelihood

26

Slide 27: Example 2 - revisited

The blow rate for a given whale species is Poisson-distributed and it is “known” that the average number of blows in an interval for males and females is different. We monitor a population and find the following distribution of blow times.

27

Slide 28

The Poisson distribution is:

28

Example 2 - revisited

The likelihood function is then:

P(x | λ) = λx exp(−λ) / x!

P(x | p, λ1, λ2) = p λ1x exp(−λ1) / x! + (1 − p) λ2x exp(−λ2) / x!

P(x | p, λ1, λ2) = ∏i ( p λ1xᵢ exp(−λ1) / xi! + (1 − p) λ2xᵢ exp(−λ2) / xi! )

Slide 29

29

Example 2 - revisited

The likelihood function is then:

Question: What are we solving for here with optimization?

P(x | p, λ1, λ2) = ∏i ( p λ1xᵢ exp(−λ1) / xi! + (1 − p) λ2xᵢ exp(−λ2) / xi! )

Slide 30: Example 2 - revisited

30

Slide 31: Dissecting Example 2-I

Parameters

The data

31

Slide 32: Dissecting Example 2-II

32

Slide 33: Hints for optimization

33

Slide 34: Question 3

The length of a fish is related to its age according to the von Bertalanffy growth curve:

La = ℓ∞(1 − e−κa) + ε

ε ~ N(0, σ2)

Slide 35: Example 3-I

35

Slide 36: Likelihood Profile

Parameter of Interest

MLE

36

Slide 37: Confidence Interval

Figure 37.1. Line plot, asymptotic length Linf (x, 75 to 90) versus Negative Log-likelihood (y, 0 to 8). U-shaped profile; a line 1.92 above the minimum marks the 95% confidence interval.

1.92

37

The mle() function in R does this for you, but you can pretty easily do it by hand.