193
Math Camp Justin Grimmer Associate Professor Department of Political Science Stanford University September 7th, 2016 Justin Grimmer (Stanford University) Methodology I September 7th, 2016 1/1

Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Math Camp

Justin Grimmer

Associate ProfessorDepartment of Political Science

Stanford University

September 7th, 2016

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 1 / 1

Page 2: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 3: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 4: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 5: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 6: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 7: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 8: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve

- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 9: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 10: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 11: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Political scientists are often concerned with finding extrema: maxima orminima

- Given data, most likely value of a parameter

- Game theory: given other player’s strategy, action that maximizesutility

- Across substantive areas: what is the optimal action, strategy,prediction?

How to Optimize

- When functions are well behaved and known analytic solutions

- Differentiate, set equal to zero, solve- Check end points and use second derivative test

- More difficult problems computational solutions

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 2 / 1

Page 12: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Intuition: Optimization with Derivatives, Known wellbehaved functions

−3 −2 −1 0 1 2 3

−4

−2

02

46

Rolle's Theorem

x

f(x)

f'(x) = 0

- Rolle’s theoremguarantee’s that, atsome point, f

′(x) = 0

- Intuition fromproof—what happens aswe approach from theleft?

- Intuition fromproof—what happens aswe approach from theright?

- critical intuition first,second derivatives

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 3 / 1

Page 13: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Intuition: Optimization with Derivatives, Known wellbehaved functions

−3 −2 −1 0 1 2 3

−4

−2

02

46

Rolle's Theorem

x

f(x)

f'(x) = 0

- Rolle’s theoremguarantee’s that, atsome point, f

′(x) = 0

- Intuition fromproof—what happens aswe approach from theleft?

- Intuition fromproof—what happens aswe approach from theright?

- critical intuition first,second derivatives

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 3 / 1

Page 14: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Intuition: Optimization with Derivatives, Known wellbehaved functions

−3 −2 −1 0 1 2 3

−4

−2

02

46

Rolle's Theorem

x

f(x)

f'(x) = 0

- Rolle’s theoremguarantee’s that, atsome point, f

′(x) = 0

- Intuition fromproof—what happens aswe approach from theleft?

- Intuition fromproof—what happens aswe approach from theright?

- critical intuition first,second derivatives

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 3 / 1

Page 15: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Intuition: Optimization with Derivatives, Known wellbehaved functions

−3 −2 −1 0 1 2 3

−4

−2

02

46

Rolle's Theorem

x

f(x)

f'(x) = 0

- Rolle’s theoremguarantee’s that, atsome point, f

′(x) = 0

- Intuition fromproof—what happens aswe approach from theleft?

- Intuition fromproof—what happens aswe approach from theright?

- critical intuition first,second derivatives

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 3 / 1

Page 16: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Intuition: Optimization with Derivatives, Known wellbehaved functions

−3 −2 −1 0 1 2 3

−4

−2

02

46

Rolle's Theorem

x

f(x)

f'(x) = 0

- Rolle’s theoremguarantee’s that, atsome point, f

′(x) = 0

- Intuition fromproof—what happens aswe approach from theleft?

- Intuition fromproof—what happens aswe approach from theright?

- critical intuition first,second derivatives

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 3 / 1

Page 17: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Second Derivatives

Definition

Suppose f : < → < is differentiable. Recall we write this as f′

andsuppose that f

′: < → <. Then if the limit,

limx→x0

R(x) =f′(x)− f

′(x0)

x − x0

exists, we call this the second derivative at x0, f′′

(x0).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 4 / 1

Page 18: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example of Second Derivatives

f (x) = x

f′(x) = 1

f′′

(x) = 0

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 5 / 1

Page 19: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example of Second Derivatives

f (x) = ex

f′(x) = ex

f′′

(x) = ex

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 5 / 1

Page 20: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example of Second Derivatives

f (x) = log(x)

f′(x) =

1

x

f′′

(x) =−1

x2

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 5 / 1

Page 21: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example of Second Derivatives

f (x) =1

x

f′(x) =

−1

x2

f′′

(x) =2

x3

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 5 / 1

Page 22: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example of Second Derivatives

f (x) = −x2 + 20

f′(x) = −2x

f′′

(x) = −2

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 5 / 1

Page 23: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Approximating functions and second order conditions

Theorem

Taylor’s Theorem Suppose f : < → <, f (x) is infinitely differentiablefunction. Then, the taylor expansion of f (x) around a is given by

f (x) = f (a) +f′(a)

1!(x − a) +

f′′

(a)

2!(x − a)2 +

f′′′

(a)

3!(x − a)3 + . . .

f (x) =∞∑n=0

f n(a)

n!(x − a)n

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 6 / 1

Page 24: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

R Code!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 7 / 1

Page 25: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concavity, Convexity, Inflections

Second derivatives provide further information about functions

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

0 1 2 3 4 5

−5

−4

−3

−2

−1

01

Log(x)

Xf(

x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 8 / 1

Page 26: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concavity, Convexity, Inflections

Second derivatives provide further information about functions

1 2 3 4 5

0.5

1.0

1.5

2.0

1/X

X

f(x)

0 1 2 3 4 5

−5

05

1015

20

−x^2 + 20

Xf(

x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 8 / 1

Page 27: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up/ Convex

Definition

Suppose f : [a, b]→ < is a twice differentiable function. If, for allx ∈ [a, b] and y ∈ [a, b] and t ∈ (0, 1)

f ((1− t)x + ty) < (1− t)f (x) + tf (y)

We say that f is strictly concave up or convex. Equivalently if f′′

(x) > 0for all x ∈ [a, b], we say that f is strictly concave up.

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 9 / 1

Page 28: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 29: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

●(1, e^(1))

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 30: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

●(1, e^(1))

● (4, e^(4))

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 31: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

●(1, e^(1))

● (4, e^(4))

●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 32: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

●(1, e^(1))

● (4, e^(4))

●● ●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 33: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

●(1, e^(1))

● (4, e^(4))

●● ●

● ●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 34: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Graphical Testf (x) = ex , [1, 4]

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

●(1, e^(1))

● (4, e^(4))

●● ●

● ●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 10 / 1

Page 35: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Second Derivative

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x)

f (x) = ex

f′(x) = ex

f′′

(x) = ex

ex > 0 for all x ∈ [1, 4]

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 11 / 1

Page 36: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Second Derivative

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x) f (x) = ex

f′(x) = ex

f′′

(x) = ex

ex > 0 for all x ∈ [1, 4]

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 11 / 1

Page 37: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Second Derivative

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x) f (x) = ex

f′(x) = ex

f′′

(x) = ex

ex > 0 for all x ∈ [1, 4]

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 11 / 1

Page 38: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Second Derivative

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x) f (x) = ex

f′(x) = ex

f′′

(x) = ex

ex > 0 for all x ∈ [1, 4]

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 11 / 1

Page 39: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Up, Second Derivative

0 1 2 3 4 5

050

100

150

e^(x)

X

f(x) f (x) = ex

f′(x) = ex

f′′

(x) = ex

ex > 0 for all x ∈ [1, 4]

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 11 / 1

Page 40: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Down

Definition

Suppose f : [a, b]→ < is a twice differentiable function. If, for allx ∈ [a, b] and y ∈ [a, b] and t ∈ (0, 1)

f ((1− t)x + ty) > (1− t)f (x) + tf (y)

We say that f is strictly concave down. Equivalently if f′′

(x) < 0 for allx ∈ [a, b], we say that f is strictly concave down.

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 12 / 1

Page 41: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Concave Down

0 1 2 3 4 5

−5

−4

−3

−2

−1

01

Log(x)

X

f(x)

- Show Concave down with graph test for x ∈ [1, 4]

- Show concave down with second derivative test for x ∈ [1, 4]

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 13 / 1

Page 42: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization

Theorem

Extreme Value Theorem Suppose f : [a, b]→ < and that f is continuous.Then f obtains its extreme value on [a, b].

Corollary

Suppose f : [a, b]→ <, that f is continuous and differentiable, and thatf (a) nor f (b) is the extreme value. Then f obtains its maximum on (a, b)and if f (x0) is the extreme value of f x0 ∈ (a, b) then, f

′(x0) = 0.

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 14 / 1

Page 43: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Extrema on End Points

0 1 2 3 4 5

01

23

45

f(x) = x

X

f(X

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 15 / 1

Page 44: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Maximum in Middle, Concave Down

f (x) = −x2 + 5.

−3 −2 −1 0 1 2 3

−4

−2

02

46

Rolle's Theorem

x

f(x)

f'(x) = 0

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 16 / 1

Page 45: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Minimum in Interior, Concave Upf (x) = x2 + 9x + 9

−10 −8 −6 −4 −2 0

−10

−5

05

1015

20

x

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 17 / 1

Page 46: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Local Optimaf (x) = sin(x)

−20 −10 0 10 20

−1.

0−

0.5

0.0

0.5

1.0

x

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 18 / 1

Page 47: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Inflection pointsf (x) = x3

−3 −2 −1 0 1 2 3

−20

−10

010

20

x

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 19 / 1

Page 48: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 49: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 50: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 51: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 52: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum

- If f′′

(x) < 0, Concave down, local maximum- If f

′′(x) = 0, No knowledge—local minimum, maximum, or inflection

point

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 53: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 54: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 55: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Framework for Optimization

Recipe for optimization

- Find f′(x).

- Set f′(x) = 0 and solve for x . Call all x0 such that f

′(x0) = 0 critical

values.

- Find f′′

(x). Evaluate at each x0.

- If f′′

(x) > 0, Concave up, local minimum- If f

′′(x) < 0, Concave down, local maximum

- If f′′

(x) = 0, No knowledge—local minimum, maximum, or inflectionpoint

- Check End Points!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 20 / 1

Page 56: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 1: f (x) = −x2, x ∈ [−3, 3]

−4 −2 0 2 4

−25

−20

−15

−10

−5

0

−x^2

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 21 / 1

Page 57: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 1: f (x) = −x2, x ∈ [−3, 3]

1) Critical Value:

f′(x) = −2x

0 = −2x∗

x∗ = 0

2) Second Derivative:

f′(x) = −2x

f′′

(x) = −2

f′′

(x) < 0, local maximum

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 21 / 1

Page 58: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 1: f (x) = −x2, x ∈ [−3, 3]

1) Critical Value:

f′(x) = −2x

0 = −2x∗

x∗ = 0

2) Second Derivative:

f′(x) = −2x

f′′

(x) = −2

f′′

(x) < 0, local maximum

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 21 / 1

Page 59: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 1: f (x) = −x2, x ∈ [−3, 3]

1) Critical Value:

f′(x) = −2x

0 = −2x∗

x∗ = 0

2) Second Derivative:

f′(x) = −2x

f′′

(x) = −2

f′′

(x) < 0, local maximum

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 21 / 1

Page 60: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 1: f (x) = −x2, x ∈ [−3, 3]

1) Critical Value:

f′(x) = −2x

0 = −2x∗

x∗ = 0

2) Second Derivative:

f′(x) = −2x

f′′

(x) = −2

f′′

(x) < 0, local maximum

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 21 / 1

Page 61: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 1: f (x) = −x2, x ∈ [−3, 3]

3) Check end points

f (0) = −02 = 0

f (−3) = −(−3)2 = −9

f (3) = −(3)2 = −9

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 22 / 1

Page 62: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 2: f (x) = x3, x ∈ [−3, 3]

−4 −2 0 2 4

−10

0−

500

5010

0

x^3

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 23 / 1

Page 63: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 2: f (x) = x3, x ∈ [−3, 3]

1) Critical Values:

f′(x) = 3x2

0 = 3(x∗)2

x∗ = 0

2) Second Derivative:

f′′

(x) = 6x

f′′

(0) = 0

No information

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 23 / 1

Page 64: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 2: f (x) = x3, x ∈ [−3, 3]

1) Critical Values:

f′(x) = 3x2

0 = 3(x∗)2

x∗ = 0

2) Second Derivative:

f′′

(x) = 6x

f′′

(0) = 0

No information

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 23 / 1

Page 65: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 2: f (x) = x3, x ∈ [−3, 3]

3) Check End Points:

f (0) = 03 = 0

f (−3) = −33 = −27

f (3) = 33 = 27

Neither maximum nor minimum, saddle point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 24 / 1

Page 66: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy space

Suppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 67: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.

Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 68: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 69: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 70: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 71: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 72: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 73: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 74: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 75: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 76: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal point

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 77: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial ModelA large literature in Congress supposes legislators and policies can besituated in policy spaceSuppose legislator i and policies x , i ∈ <.Define legislator i ’s utility as, U : < → <,

Ui (x) = −(x − µ)2

Ui (x) = −x2 + 2xµ− µ2

What is i ’s optimal policy over the range x ∈ [µ− 2, µ+ 2]?

U′i (x) = −2(x − µ)

0 = −2x∗ + 2µ

x∗ = µ

Second Derivative Test

U′′i (x) = −2 < 0→ Concave Down

We call µ legislator i ’s ideal pointJustin Grimmer (Stanford University) Methodology I September 7th, 2016 25 / 1

Page 78: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 3: Spatial Model

Ui (µ) = −(µ− µ)2 = 0

Ui (µ− 2) = −(µ− 2− µ)2 = −4

Ui (µ+ 2) = −(µ+ 2− µ)2 = −4

Maximize utility at µ

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 26 / 1

Page 79: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

In 350a, we’ll learn about parameters from data.

Here is an example likelihood function: We want to find the Maximumlikelihood estimate

f (µ) =N∏i=1

exp(−(Yi − µ)2

2)

= exp(−(Y1 − µ)2

2)× . . .× exp(−(YN − µ)2

2)

= exp(−∑N

i=1(Yi − µ)2

2)

Theorem

Suppose f : < → (0,∞). If x0 maximizes f , then x0 maximizes log(f (x)).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 27 / 1

Page 80: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

In 350a, we’ll learn about parameters from data.Here is an example likelihood function: We want to find the Maximumlikelihood estimate

f (µ) =N∏i=1

exp(−(Yi − µ)2

2)

= exp(−(Y1 − µ)2

2)× . . .× exp(−(YN − µ)2

2)

= exp(−∑N

i=1(Yi − µ)2

2)

Theorem

Suppose f : < → (0,∞). If x0 maximizes f , then x0 maximizes log(f (x)).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 27 / 1

Page 81: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

In 350a, we’ll learn about parameters from data.Here is an example likelihood function: We want to find the Maximumlikelihood estimate

f (µ) =N∏i=1

exp(−(Yi − µ)2

2)

= exp(−(Y1 − µ)2

2)× . . .× exp(−(YN − µ)2

2)

= exp(−∑N

i=1(Yi − µ)2

2)

Theorem

Suppose f : < → (0,∞). If x0 maximizes f , then x0 maximizes log(f (x)).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 27 / 1

Page 82: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

In 350a, we’ll learn about parameters from data.Here is an example likelihood function: We want to find the Maximumlikelihood estimate

f (µ) =N∏i=1

exp(−(Yi − µ)2

2)

= exp(−(Y1 − µ)2

2)× . . .× exp(−(YN − µ)2

2)

= exp(−∑N

i=1(Yi − µ)2

2)

Theorem

Suppose f : < → (0,∞). If x0 maximizes f , then x0 maximizes log(f (x)).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 27 / 1

Page 83: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

In 350a, we’ll learn about parameters from data.Here is an example likelihood function: We want to find the Maximumlikelihood estimate

f (µ) =N∏i=1

exp(−(Yi − µ)2

2)

= exp(−(Y1 − µ)2

2)× . . .× exp(−(YN − µ)2

2)

= exp(−∑N

i=1(Yi − µ)2

2)

Theorem

Suppose f : < → (0,∞). If x0 maximizes f , then x0 maximizes log(f (x)).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 27 / 1

Page 84: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

In 350a, we’ll learn about parameters from data.Here is an example likelihood function: We want to find the Maximumlikelihood estimate

f (µ) =N∏i=1

exp(−(Yi − µ)2

2)

= exp(−(Y1 − µ)2

2)× . . .× exp(−(YN − µ)2

2)

= exp(−∑N

i=1(Yi − µ)2

2)

Theorem

Suppose f : < → (0,∞). If x0 maximizes f , then x0 maximizes log(f (x)).

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 27 / 1

Page 85: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum LIkelihood Estimation

log f (µ) = log

(exp(−

∑Ni=1(Yi − µ)2

2)

)

= −∑N

i=1(Yi − µ)2

2)

= −1

2

(N∑i=1

Y 2i − 2µ

N∑i=1

Yi + N × µ2

)∂ log f (µ)

∂µ= −1

2

(−2

N∑i=1

Yi + 2Nµ

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 28 / 1

Page 86: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum LIkelihood Estimation

log f (µ) = log

(exp(−

∑Ni=1(Yi − µ)2

2)

)

= −∑N

i=1(Yi − µ)2

2)

= −1

2

(N∑i=1

Y 2i − 2µ

N∑i=1

Yi + N × µ2

)∂ log f (µ)

∂µ= −1

2

(−2

N∑i=1

Yi + 2Nµ

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 28 / 1

Page 87: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum LIkelihood Estimation

log f (µ) = log

(exp(−

∑Ni=1(Yi − µ)2

2)

)

= −∑N

i=1(Yi − µ)2

2)

= −1

2

(N∑i=1

Y 2i − 2µ

N∑i=1

Yi + N × µ2

)∂ log f (µ)

∂µ= −1

2

(−2

N∑i=1

Yi + 2Nµ

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 28 / 1

Page 88: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum LIkelihood Estimation

log f (µ) = log

(exp(−

∑Ni=1(Yi − µ)2

2)

)

= −∑N

i=1(Yi − µ)2

2)

= −1

2

(N∑i=1

Y 2i − 2µ

N∑i=1

Yi + N × µ2

)

∂ log f (µ)

∂µ= −1

2

(−2

N∑i=1

Yi + 2Nµ

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 28 / 1

Page 89: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum LIkelihood Estimation

log f (µ) = log

(exp(−

∑Ni=1(Yi − µ)2

2)

)

= −∑N

i=1(Yi − µ)2

2)

= −1

2

(N∑i=1

Y 2i − 2µ

N∑i=1

Yi + N × µ2

)∂ log f (µ)

∂µ= −1

2

(−2

N∑i=1

Yi + 2Nµ

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 28 / 1

Page 90: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 91: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 92: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 93: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 94: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 95: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 96: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)

f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 97: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 4: Maximum Likelihood Estimation

0 = −1

2

(−

N∑i=1

Yi + 2Nµ∗

)

2N∑i=1

Yi = 2Nµ∗

∑Ni=1 Yi

N= µ∗

Y = µ∗

Second Derivative Test

f′(µ) = −1

2

(−2

N∑i=1

Yi + 2Nµ

)f′′

(µ) = −N

−N < 0, concave down, maximum(!!)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 29 / 1

Page 98: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 99: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 100: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 101: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 102: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 103: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 104: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 105: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)Countries fight wars, usually to get stuff.

- Suppose two countries 1, 2 are fighting for something they value at v .

- Each country decides to invest a1 ∈ [0, 1] and a2 ∈ [0, 1].

- The probability of country 1 winning the war is

p(a1, a2) =an1

an1 + an2

- Country 1’s utility is given by

U1(a1) = 1− a1︸ ︷︷ ︸cost

+ p(a1, a2)v︸ ︷︷ ︸Expected Benefit

= 1− a1 +an1

an1 + an2v

- Suppose country 2 selected value x . What should country 1 invest tomaximize utility?

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 30 / 1

Page 106: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)

0.0 0.2 0.4 0.6 0.8 1.0

0.4

0.5

0.6

0.7

0.8

0.9

1.0

n = 1,v = 0.5

a1

Util

ity

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 31 / 1

Page 107: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR War (from Jim Fearon, Part 1)

∂U1(a1)

∂a1= −1 +

nan−11 (an1 + xn)− (nan−1

1 an1)

(an1 + xn)2v

= −1 +nan−1

1 xn

(an1 + xn)2v

Set n = 1 (for simplicity)

0 = −1 +x

(a1 + x)2v

a∗1 =√v√x − x

(0.1)

Second derivative!

U′′1 (a1) =

−2vx

(a1 + x)3

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 32 / 1

Page 108: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example 5: IR Bargaining (from Jim Fearon, Part 1)

One more—check endpoints

a∗1 = 0, if√v√x − x < 0

a∗1 = 0, if√v <√x

a∗1 =√v√x − x otherwise

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 33 / 1

Page 109: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Optimization Challenge Problem- Suppose a candidate is attempting to mobilize voters. Suppose that

for each investment of x ∈ [0,∞) the candidate receives return ofx1/2, but incurs cost of ax . So, candidate utility is,

Ui = x1/2 − ax

What is the optimal investment x∗?

0.0 0.1 0.2 0.3 0.4 0.5

−1.

0−

0.5

0.0

0.5

1.0

x

Util

ity

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 34 / 1

Page 110: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailable

Computational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 111: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational

iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 112: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 113: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 114: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods

- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 115: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)

- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 116: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization

- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 117: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization

- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 118: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Computational Optimization Approaches

Analytic (Closed form) Often difficult, impractical, or unavailableComputational iterative algorithm that converges to a solution(hopefully the right one!)

- Methods for optimization:

- Newton’s method and related methods- Gradient descent (ascent)- Expectation Maximization- Genetic Optimization- Branch and Bound ...

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 35 / 1

Page 119: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Iterative procedure to find a root

Often solving for x when f (x) = 0 is hard complicated functionSolving for x when f (x) is linear easyApproximate with tangent line, iteratively update

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 36 / 1

Page 120: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Iterative procedure to find a rootOften solving for x when f (x) = 0 is hard complicated function

Solving for x when f (x) is linear easyApproximate with tangent line, iteratively update

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 36 / 1

Page 121: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Iterative procedure to find a rootOften solving for x when f (x) = 0 is hard complicated functionSolving for x when f (x) is linear easy

Approximate with tangent line, iteratively update

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 36 / 1

Page 122: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Iterative procedure to find a rootOften solving for x when f (x) = 0 is hard complicated functionSolving for x when f (x) is linear easyApproximate with tangent line, iteratively update

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 36 / 1

Page 123: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 124: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 125: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 126: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 127: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 128: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 129: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 130: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 131: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 132: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 133: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 134: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 135: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 136: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 137: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 138: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 139: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 140: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 141: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 142: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 143: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 144: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 145: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 146: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 147: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 148: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

2 4 6 8 10

0.0

0.5

1.0

1.5

2.0

X

F(x

)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 37 / 1

Page 149: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

Formula for Tangent line at x0:

g(x) = f′(x0)(x − x0) + f (x0)

We’ll use formula for tangent line to generate updates

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 38 / 1

Page 150: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

Formula for Tangent line at x0:

g(x) = f′(x0)(x − x0) + f (x0)

We’ll use formula for tangent line to generate updates

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 38 / 1

Page 151: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

Formula for Tangent line at x0:

g(x) = f′(x0)(x − x0) + f (x0)

We’ll use formula for tangent line to generate updates

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 38 / 1

Page 152: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

Formula for Tangent line at x0:

g(x) = f′(x0)(x − x0) + f (x0)

We’ll use formula for tangent line to generate updates

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 38 / 1

Page 153: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Tangent Line

Formula for Tangent line at x0:

g(x) = f′(x0)(x − x0) + f (x0)

We’ll use formula for tangent line to generate updates

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 38 / 1

Page 154: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Suppose we have some initial guess x0. We’re going to approximate f′(x)

with the tangent line to generate a new guess

g(x) = f′′

(x0)(x − x0) + f′(x0)

0 = f′′

(x0)(x1 − x0) + f′(x0)

x1 = x0 −f′(x0)

f ′′(x0)

Perform iteratively until change in |xt+1 − xt | < threshold

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 39 / 1

Page 155: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Suppose we have some initial guess x0. We’re going to approximate f′(x)

with the tangent line to generate a new guess

g(x) = f′′

(x0)(x − x0) + f′(x0)

0 = f′′

(x0)(x1 − x0) + f′(x0)

x1 = x0 −f′(x0)

f ′′(x0)

Perform iteratively until change in |xt+1 − xt | < threshold

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 39 / 1

Page 156: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Suppose we have some initial guess x0. We’re going to approximate f′(x)

with the tangent line to generate a new guess

g(x) = f′′

(x0)(x − x0) + f′(x0)

0 = f′′

(x0)(x1 − x0) + f′(x0)

x1 = x0 −f′(x0)

f ′′(x0)

Perform iteratively until change in |xt+1 − xt | < threshold

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 39 / 1

Page 157: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Newton-Raphson Method

Suppose we have some initial guess x0. We’re going to approximate f′(x)

with the tangent line to generate a new guess

g(x) = f′′

(x0)(x − x0) + f′(x0)

0 = f′′

(x0)(x1 − x0) + f′(x0)

x1 = x0 −f′(x0)

f ′′(x0)

Perform iteratively until change in |xt+1 − xt | < threshold

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 39 / 1

Page 158: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Example Functionf (x) = x3 + 2x2 − 1 find x that maximizes f (x) with x ∈ [−3, 0]

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 40 / 1

Page 159: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

f′(x) = 3x2 + 4x

f′′

(x) = 6x + 4

Suppose we have guess xt then the next step is:

xt+1 = xt −3x2

t + 4xt6xt + 4

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 41 / 1

Page 160: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 161: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 162: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 163: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 164: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 165: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 166: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

x∗ = −1.3333

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 42 / 1

Page 167: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 168: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 169: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 170: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 171: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 172: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 173: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 174: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 175: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 176: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 177: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 178: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 179: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

What is Happening with the Roots

−3 −2 −1 0 1 2 3

010

2030

40

3x^2 + 4x

X

f'(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 43 / 1

Page 180: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 181: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 182: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●● ●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 183: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●● ●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 184: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●● ●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 185: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●● ●●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 186: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 187: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 188: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 189: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 190: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 191: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

−3 −2 −1 0 1 2 3

−10

010

2030

40

x^3 + 2 x^2 − 1

X

f(x)

●●●●●

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 192: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

To the R Code!

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 44 / 1

Page 193: Justin Grimmer - Stanford Universitystanford.edu/~jgrimmer/Math16/mc3_16.pdfPolitical scientists are often concerned with ndingextrema:maximaor minima-Given data,mostlikely value of

Today/Tomorrow

- A Framework for optimization

- Analytic: pencil and paper math- Computational: iterative algorithm that aids in solution

- Integration: antidifferentation/area finding

Justin Grimmer (Stanford University) Methodology I September 7th, 2016 45 / 1