Justin Grimmer - stanford.edu

139
Math Camp Justin Grimmer Associate Professor Department of Political Science Stanford University September 9th, 2014 Justin Grimmer (Stanford University) Methodology I September 9th, 2014 1 / 49

Transcript of Justin Grimmer - stanford.edu

Page 1: Justin Grimmer - stanford.edu

Math Camp

Justin Grimmer

Associate ProfessorDepartment of Political Science

Stanford University

September 9th, 2014

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 1 / 49

Page 2: Justin Grimmer - stanford.edu

Multivariable Calculus

Functions of many variables:

1) Policies may be multidimensional (policy provision and pork buy off)

2) Countries may invest in offensive and defensive resources for fightingwars

3) Ethnicity and resources could affect investment

Today:

0) Determinant

1) Multivariate functions

2) Partial Derivatives, Gradients, Jacobians, and Hessians

3) Total Derivative, Implicit Differentiation, Implicit Function Theorem

4) Multivariate Integration

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 2 / 49

Page 3: Justin Grimmer - stanford.edu

Determinant

Suppose we have a square (n × n) matrix A

A =

(a11 a12a21 a22

)A determinant is a function that assigns a number to square matrices

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 3 / 49

Page 4: Justin Grimmer - stanford.edu

Determinant

Facts needed to define determinant :

Definition

A permutation of the set of integers {1, 2, . . . , J} is an arrangement ofthese integers in some order without omissions or repetition.

For example, consider {1, 2, 3, 4}{3, 2, 1, 4}{4, 3, 2, 1}

If we have J integers then there are J! permutations

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 4 / 49

Page 5: Justin Grimmer - stanford.edu

Determinant

Definition

An inversion occurs when a larger integer occurs before a smaller integerin a permutation

Even permutation: total inversions are even

Odd permutation: total inversions are odd

Count the inversions

{3, 2, 1}{1, 2, 3}{3, 1, 2}{2, 1, 3}{1, 3, 2}{2, 3, 1}

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 5 / 49

Page 6: Justin Grimmer - stanford.edu

Determinant

Definition

For a square nxn matrix A, we will call an elementary product an nelement long product, with no two components coming from the same rowor column. We will call a signed elementary product one that multipliesodd permutations of the column numbers by −1.

(a11 a12a21 a22

)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 6 / 49

Page 7: Justin Grimmer - stanford.edu

Determinant

Definition

For a square nxn matrix A, we will call an elementary product an nelement long product, with no two components coming from the same rowor column. We will call a signed elementary product one that multipliesodd permutations of the column numbers by −1.

(a11 a12a21 a22

)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 6 / 49

Page 8: Justin Grimmer - stanford.edu

Determinant

Definition

For a square nxn matrix A, we will call an elementary product an nelement long product, with no two components coming from the same rowor column. We will call a signed elementary product one that multipliesodd permutations of the column numbers by −1.

a11 a12 a13a21 a22 a23a31 a32 a33

There are n! elementary products

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 6 / 49

Page 9: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 2× 2 matrix

det(A) = det

(a11 a12a21 a22

)= a11a22 − a12a21

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 10: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 2× 2 matrix

det(A) = det

(a11 a12a21 a22

)= a11a22 − a12a21

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 11: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 2× 2 matrix

det(A) = det

(a11 a12a21 a22

)

= a11a22 − a12a21

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 12: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 2× 2 matrix

det(A) = det

(a11 a12a21 a22

)= a11a22 − a12a21

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 13: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 3× 3 matrix.

det(A) = det

a11 a12 a13a21 a22 a23a31 a32 a33

= a11a22a33 − a11a23a32 − a12a21a33

+a12a23a31 + a13a21a32 − a13a22a31

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 14: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 3× 3 matrix.

det(A) = det

a11 a12 a13a21 a22 a23a31 a32 a33

= a11a22a33 − a11a23a32 − a12a21a33

+a12a23a31 + a13a21a32 − a13a22a31

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 15: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 3× 3 matrix.

det(A) = det

a11 a12 a13a21 a22 a23a31 a32 a33

= a11a22a33 − a11a23a32 − a12a21a33

+a12a23a31 + a13a21a32 − a13a22a31

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 16: Justin Grimmer - stanford.edu

Determinant

Definition

Suppose A is an n × n matrix. Define the determinant function det(A) tobe the sum of signed elementary products from A. Call det(A) thedeterminant of A

Suppose A is a 3× 3 matrix.

det(A) = det

a11 a12 a13a21 a22 a23a31 a32 a33

= a11a22a33 − a11a23a32 − a12a21a33

+a12a23a31 + a13a21a32 − a13a22a31

R Code!

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 7 / 49

Page 17: Justin Grimmer - stanford.edu

Multivariate Functions

f (x1, x2) = x1 + x2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 8 / 49

Page 18: Justin Grimmer - stanford.edu

Multivariate Functions

f (x1, x2) = x21 + x22

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 8 / 49

Page 19: Justin Grimmer - stanford.edu

Multivariate Functions

f (x1, x2) = sin(x1) cos(x2)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 8 / 49

Page 20: Justin Grimmer - stanford.edu

Multivariate Functions

f (x1, x2) = −(x − 5)2 − (y − 2)2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 8 / 49

Page 21: Justin Grimmer - stanford.edu

Multivariate Functions

f (x1, x2, x3) = x1 + x2 + x3

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 8 / 49

Page 22: Justin Grimmer - stanford.edu

Multivariate Functions

f (x) = f (x1, x2, . . . , xN)

= x1 + x2 + . . .+ xN

=N∑i=1

xi

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 8 / 49

Page 23: Justin Grimmer - stanford.edu

Multivariate Functions

Definition

Suppose f : <n → <1. We will call f a multivariate function. We willcommonly write,

f (x) = f (x1, x2, x3, . . . , xn)

- <n = < ×︸︷︷︸cartesian

<× <× . . .<

- The function we consider will take n inputs and output a singlenumber (that lives in <1, or the real line)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 9 / 49

Page 24: Justin Grimmer - stanford.edu

Example 1

f (x1, x2, x3) = x1 + x2 + x3

Evaluate at x = (x1, x2, x3) = (2, 3, 2)

f (2, 3, 2) = 2 + 3 + 2

= 7

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 10 / 49

Page 25: Justin Grimmer - stanford.edu

Example 1

f (x1, x2) = x1 + x2 + x1x2

Evaluate at w = (w1,w2) = (1, 2)

f (w1,w2) = w1 + w2 + w1w2

= 1 + 2 + 1× 2

= 5

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 10 / 49

Page 26: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.

Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 27: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .

Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 28: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 29: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 30: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 31: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 32: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0).

Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 33: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 34: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 35: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 36: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1

= −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 37: Justin Grimmer - stanford.edu

Preferences for Multidimensional PolicyRecall that in the spatial model, we suppose policy and political actors arelocated in a space.Suppose that policy is N dimensional—or x ∈ <N .Suppose that legislator i ’s utility is a U : <N → <1 and is given by,

U(x) = U(x1, x2, . . . , xN)

= −(x1 − µ1)2 − (x2 − µ2)2 − . . .− (xN − µN)2

= −N∑j=1

(xj − µj)2

Suppose µ = (µ1, µ2, . . . , µN) = (0, 0, . . . , 0). Evaluate legislator’s utilityfor a policy proposal of m = (1, 1, . . . , 1).

U(m) = U(1, 1, . . . , 1)

= −(1− 0)2 − (1− 0)2 − . . .− (1− 0)2

= −N∑j=1

1 = −N

(0.1)Justin Grimmer (Stanford University) Methodology I September 9th, 2014 11 / 49

Page 38: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:

The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 39: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 40: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 41: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 42: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 43: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 44: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 45: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 46: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 47: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 48: Justin Grimmer - stanford.edu

Regression Models and Randomized TreatmentsOften we administer randomized experiments:The most recent wave of interest began with voter mobilization, andwonder if individual i turns out to vote, Votei

- T = 1 (treated): voter receives mobilization

- T = 0 (control): voter does not receive mobilization

Suppose we find the following regression model, where x2 is a participant’sage:

f (T , x2) = Pr(Votei = 1|T , x2)

= β0 + β1T + β2x2

We can calculate the effect of the experiment as:

f (T = 1, x2)− f (T = 0, x2) = β0 + β11 + β2x2 − (β0 + β10 + β2x2)

= β0 − β0 + β1(1− 0) + β2(x2 − x2)

= β1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 12 / 49

Page 49: Justin Grimmer - stanford.edu

Multivariate Derivative

Definition

Suppose f : X → <1, where X ⊂ <n. f (x) = f (x1, x2, . . . , xN). If thelimit,

∂xif (x0) =

∂xif (x01, x02, . . . , x0i , x0i+1, . . . , x0N)

= limh→0

f (x01, x02, . . . , x0i + h, . . . x0N)− f (x01, x02, . . . , x0i , . . . , x0N)

h

exists then we call this the partial derivative of f with respect to xi at the valuex0 = (x01, x02, . . . , x0N).

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 13 / 49

Page 50: Justin Grimmer - stanford.edu

Rules for Taking Partial Derivatives

Partial Derivative: ∂f (x)∂xi

- Treat each instance of xi as a variable that we would differentiatebefore

- Treat each instance of x−i = (x1, x2, x3, . . . , xi−1, xi+1, . . . , xn) as aconstant

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 14 / 49

Page 51: Justin Grimmer - stanford.edu

Example Partial Derivatives

f (x) = f (x1, x2)

= x1 + x2

Partial derivative, with respect to x1 at (x01, x02)

∂f (x1, x2)

∂x1|(x01,x02) = 1 + 0|x01,x02

= 1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 15 / 49

Page 52: Justin Grimmer - stanford.edu

Example Partial Derivatives

f (x) = f (x1, x2, x3)

= x21 log(x1) + x2x1x3 + x23

What is the partial derivative with respect to x1? x2? x3? Evaluated atx0 = (x01, x02, x03).

∂f (x)

∂x1|x0 = 2x1 log(x1) + x21

1

x1+ x2x3|x0

= 2x01 log(x01) + x01 + x02x03

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 16 / 49

Page 53: Justin Grimmer - stanford.edu

Example Partial Derivatives

f (x) = f (x1, x2, x3)

= x21 log(x1) + x2x1x3 + x23

What is the partial derivative with respect to x1?

x2? x3?

Evaluated atx0 = (x01, x02, x03).

∂f (x)

∂x1|x0 = 2x1 log(x1) + x21

1

x1+ x2x3|x0

= 2x01 log(x01) + x01 + x02x03

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 16 / 49

Page 54: Justin Grimmer - stanford.edu

Example Partial Derivatives

f (x) = f (x1, x2, x3)

= x21 log(x1) + x2x1x3 + x23

What is the partial derivative with respect to x1? x2?

x3?

Evaluated atx0 = (x01, x02, x03).

∂f (x)

∂x2|x0 = x1x3|x0

= x01x03

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 16 / 49

Page 55: Justin Grimmer - stanford.edu

Example Partial Derivatives

f (x) = f (x1, x2, x3)

= x21 log(x1) + x2x1x3 + x23

What is the partial derivative with respect to x1? x2? x3? Evaluated atx0 = (x01, x02, x03).

∂f (x)

∂x3|x0 = x1x2 + 2x3|x0

= x01x02 + 2x03

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 16 / 49

Page 56: Justin Grimmer - stanford.edu

Rate of Change, Linear Regression

Suppose we regress Approvali rate for Obama in month i on Employi andGasi . We obtain the following model:

Approvali = 0.8− 0.5Employi − 0.25Gasi

We are modeling Approvali = f (Employi ,Gasi ). What is partial derivativewith respect to employment?

∂f (Employi ,Gasi )

∂Employi= −0.5

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 17 / 49

Page 57: Justin Grimmer - stanford.edu

Gradient

Definition

Suppose f : X → <1 with X ⊂ <n is a differentiable function. Define thegradient vector of f at x0, ∇f (x0) as,

∇f (x0) =

(∂f (x0)

∂x1,∂f (x0)

∂x2,∂f (x0)

∂x3, . . . ,

∂f (x0)

∂xn

)

- The gradient points in the direction that the function is increasing inthe fastest direction

- We’ll use this to do optimization (both analytic and computational)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 18 / 49

Page 58: Justin Grimmer - stanford.edu

Example Gradient Calculation

Suppose

f (x) = f (x1, x2, . . . , xn)

= x21 + x22 + . . .+ x2n

=n∑

i=1

x2i

Then ∇f (x∗) is

∇f (x∗) = (2x∗1 , 2x∗2 , . . . , 2x

∗n )

So if x∗ = (3, 3, . . . , 3) then

∇f (x∗) = (2 ∗ 3, 2 ∗ 3, . . . , 2 ∗ 3)

= (6, 6, . . . , 6)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 19 / 49

Page 59: Justin Grimmer - stanford.edu

Second Partial Derivative

Definition

Suppose f : X → < where X ⊂ <n and suppose that ∂f (x1,x2,...,xn)∂xi

exists.Then we define,

∂2f (x)

∂xj∂xi≡ ∂

∂xj

(∂f (x)

∂xi

)

- Second derivative could be with respect to xi or with some othervariable xj

- Nagging question: does order matter?

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 20 / 49

Page 60: Justin Grimmer - stanford.edu

Second Partial Derivative: Order Doesn’t Matter

Theorem

Young’s Theorem Let f : X → < with X ⊂ <n be a twice differentiablefunction on all of X . Then for any i , j , at all x∗ ∈ X ,

∂2

∂xi∂xjf (x∗) =

∂2

∂xj∂xif (x∗)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 21 / 49

Page 61: Justin Grimmer - stanford.edu

Second Order Partial Derivates

f (x) = x21x22

Then,

∂2

∂x1∂x1f (x) = 2x22

∂2

∂x1∂x2f (x) = 4x1x2

∂2

∂x2∂x2f (x) = 2x21

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 22 / 49

Page 62: Justin Grimmer - stanford.edu

Hessians

Definition

Suppose f : X → <1 , X ⊂ <n, with f a twice differentiable function. Wewill define the Hessian matrix as the matrix of second derivatives atx∗ ∈ X ,

H(f )(x∗) =

∂2f

∂x1∂x1(x∗) ∂2f

∂x1∂x2(x∗) . . . ∂2f

∂x1∂xn(x∗)

∂2f∂x2∂x1

(x∗) ∂2f∂x2∂x2

(x∗) . . . ∂2f∂x2∂xn

(x∗)...

.... . .

...∂2f

∂xn∂x1(x∗) ∂2f

∂xn∂x2(x∗) . . . ∂2f

∂xn∂xn(x∗)

- Hessians are symmetric

- They describe curvature of a function (think, how bended)

- Will be the basis for second derivative test for multivariateoptimization

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 23 / 49

Page 63: Justin Grimmer - stanford.edu

An Example

Suppose f : <3 → <, with

f (x1, x2, x3) = x21x22x

23

∇f (x) = (2x1x22x

23 , 2x

21x2x

23 , 2x

21x

22 , x3)

H(f )(x) =

2x22x23 4x1x2x

23 4x1x

22x3

4x1x2x23 2x21x

23 4x21x2x3

4x1x22x3 4x21x2x3 2x21x

22

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 24 / 49

Page 64: Justin Grimmer - stanford.edu

An Example

Suppose f : <3 → <, with

f (x1, x2, x3) = x21x22x

23

∇f (x) = (2x1x22x

23 , 2x

21x2x

23 , 2x

21x

22 , x3)

H(f )(x) =

2x22x23 4x1x2x

23 4x1x

22x3

4x1x2x23 2x21x

23 4x21x2x3

4x1x22x3 4x21x2x3 2x21x

22

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 24 / 49

Page 65: Justin Grimmer - stanford.edu

An Example

Suppose f : <3 → <, with

f (x1, x2, x3) = x21x22x

23

∇f (x) = (2x1x22x

23 , 2x

21x2x

23 , 2x

21x

22 , x3)

H(f )(x) =

2x22x23 4x1x2x

23 4x1x

22x3

4x1x2x23 2x21x

23 4x21x2x3

4x1x22x3 4x21x2x3 2x21x

22

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 24 / 49

Page 66: Justin Grimmer - stanford.edu

An Example

Suppose f : <3 → <, with

f (x1, x2, x3) = x21x22x

23

∇f (x) = (2x1x22x

23 , 2x

21x2x

23 , 2x

21x

22 , x3)

H(f )(x) =

2x22x23 4x1x2x

23 4x1x

22x3

4x1x2x23 2x21x

23 4x21x2x3

4x1x22x3 4x21x2x3 2x21x

22

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 24 / 49

Page 67: Justin Grimmer - stanford.edu

An Example

Suppose f : <3 → <, with

f (x1, x2, x3) = x21x22x

23

∇f (x) = (2x1x22x

23 , 2x

21x2x

23 , 2x

21x

22 , x3)

H(f )(x) =

2x22x23 4x1x2x

23 4x1x

22x3

4x1x2x23 2x21x

23 4x21x2x3

4x1x22x3 4x21x2x3 2x21x

22

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 24 / 49

Page 68: Justin Grimmer - stanford.edu

Functions with Multidimensional Codomains

Definition

Suppose f : <m → <n. We will call f a multivariate function. We willcommonly write,

f (x) =

f1(x)f2(x)

...fn(x)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 25 / 49

Page 69: Justin Grimmer - stanford.edu

Example Functions

Suppose f : < → <2,

f (t) = (t2,√

(t))

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 26 / 49

Page 70: Justin Grimmer - stanford.edu

Example Functions

Suppose f : <2 → <2 defined as

f (r , θ) =

(r cos θr sin θ

)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 26 / 49

Page 71: Justin Grimmer - stanford.edu

Example Functions

Suppose we have some policy x ∈ <M . Suppose we have N legislatorswhere legislator i has utility

Ui (x) =M∑j=1

−(xj − µij)2

We can describe the utility of all legislators to the proposal as

f (x) =

∑M

j=1−(xj − µ1j)2∑Mj=1−(xj − µ2j)2

...∑Mj=1−(xj − µNj)2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 26 / 49

Page 72: Justin Grimmer - stanford.edu

Jacobian

Definition

Suppose f : X → <n, where X ⊂ <m, with f a differentiable function.Define the Jacobian of f at x as

J(f )(x) =

∂f1∂x1

∂f1∂x2

. . . ∂f1∂xm

∂f2∂x1

∂f2∂x2

. . . ∂f2∂xm

......

. . ....

∂fnx1

∂fnx2

. . . ∂fnxm

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 27 / 49

Page 73: Justin Grimmer - stanford.edu

Example of Jacobian

f (r , θ) =

(r cos θr sin θ

)

J(f )(r , θ) =

(cos θ −r sin θsin θ r cos θ

)

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 28 / 49

Page 74: Justin Grimmer - stanford.edu

Implicit Functions and DifferentiationWe have defined functions explicitly

Y = f (x)

We might also have an implicit function:

1 = x2 + y2

−1.0 −0.5 0.0 0.5 1.0

−1.

0−

0.5

0.0

0.5

1.0

X

Y

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 29 / 49

Page 75: Justin Grimmer - stanford.edu

Implicit Function Theorem (From Avi Acharya’s Notes)

Definition

Suppose X ⊂ <m and Y ⊂ <. Let f : X ∪ Y → < be a differentiablefunction (with continuous partial derivatives). Let (x∗, y∗) ∈ X ∪ Y suchthat

∂f (x∗, y∗)

∂y6= 0

f (x∗, y∗) = 0

Then there exists B ⊂ <n such that there is a differentiable functiong : B → < such that x∗ ∈ B then g(x∗) = y∗ and f (x , g(x)) = 0. Thederivative of g for x ∈ B is given by

∂g

∂xj= −

∂f∂xj∂f∂y

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 30 / 49

Page 76: Justin Grimmer - stanford.edu

Implicit Function Theorem (From Avi Acharya’s Notes)

Definition

Suppose X ⊂ <m and Y ⊂ <. Let f : X ∪ Y → < be a differentiablefunction (with continuous partial derivatives). Let (x∗, y∗) ∈ X ∪ Y suchthat

∂f (x∗, y∗)

∂y6= 0

f (x∗, y∗) = 0

Then there exists B ⊂ <n such that there is a differentiable functiong : B → < such that x∗ ∈ B then g(x∗) = y∗ and f (x , g(x)) = 0. Thederivative of g for x ∈ B is given by

∂g

∂xj= −

∂f∂xj∂f∂y

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 30 / 49

Page 77: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

Suppose that the equation is

1 = x2 + y2

0 = x2 + y2 − 1

y =√

1− x2 if y>0

y = −√

1− x2 if y< 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 31 / 49

Page 78: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

Suppose that the equation is

1 = x2 + y2

0 = x2 + y2 − 1

y =√

1− x2 if y>0

y = −√

1− x2 if y< 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 31 / 49

Page 79: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

Suppose that the equation is

1 = x2 + y2

0 = x2 + y2 − 1

y =√

1− x2 if y>0

y = −√

1− x2 if y< 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 31 / 49

Page 80: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

∂f

∂x= 2x

∂f

∂y= 2y = 2

√1− x2 if y > 0

∂f

∂y= 2y = −2

√1− x2 if y < 0

∂g(x)

∂x|x0 = −∂f /∂x

∂f /∂y

= −2x02y

= − x0√1− x20

if y > 0

= −2x02y

=x0√

1− x20

if y < 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 32 / 49

Page 81: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

∂f

∂x= 2x

∂f

∂y= 2y = 2

√1− x2 if y > 0

∂f

∂y= 2y = −2

√1− x2 if y < 0

∂g(x)

∂x|x0 = −∂f /∂x

∂f /∂y

= −2x02y

= − x0√1− x20

if y > 0

= −2x02y

=x0√

1− x20

if y < 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 32 / 49

Page 82: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

∂f

∂x= 2x

∂f

∂y= 2y = 2

√1− x2 if y > 0

∂f

∂y= 2y = −2

√1− x2 if y < 0

∂g(x)

∂x|x0 = −∂f /∂x

∂f /∂y

= −2x02y

= − x0√1− x20

if y > 0

= −2x02y

=x0√

1− x20

if y < 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 32 / 49

Page 83: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

∂f

∂x= 2x

∂f

∂y= 2y = 2

√1− x2 if y > 0

∂f

∂y= 2y = −2

√1− x2 if y < 0

∂g(x)

∂x|x0 = −∂f /∂x

∂f /∂y

= −2x02y

= − x0√1− x20

if y > 0

= −2x02y

=x0√

1− x20

if y < 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 32 / 49

Page 84: Justin Grimmer - stanford.edu

Example 1: Implicit Function Theorem

∂f

∂x= 2x

∂f

∂y= 2y = 2

√1− x2 if y > 0

∂f

∂y= 2y = −2

√1− x2 if y < 0

∂g(x)

∂x|x0 = −∂f /∂x

∂f /∂y

= −2x02y

= − x0√1− x20

if y > 0

= −2x02y

=x0√

1− x20

if y < 0

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 32 / 49

Page 85: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

Suppose there n individuals, each individual i earns pre-tax income yi > 0.

Total income Y =∑n

i=1 yiPer capita income: y = Y /nIndividuals pay a proportional tax t ∈ (0, 1)Suppose:

Ui (t, yi ) = yi (1− t2) + ty

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 33 / 49

Page 86: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

Suppose there n individuals, each individual i earns pre-tax income yi > 0.Total income Y =

∑ni=1 yi

Per capita income: y = Y /nIndividuals pay a proportional tax t ∈ (0, 1)Suppose:

Ui (t, yi ) = yi (1− t2) + ty

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 33 / 49

Page 87: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

Suppose there n individuals, each individual i earns pre-tax income yi > 0.Total income Y =

∑ni=1 yi

Per capita income: y = Y /n

Individuals pay a proportional tax t ∈ (0, 1)Suppose:

Ui (t, yi ) = yi (1− t2) + ty

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 33 / 49

Page 88: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

Suppose there n individuals, each individual i earns pre-tax income yi > 0.Total income Y =

∑ni=1 yi

Per capita income: y = Y /nIndividuals pay a proportional tax t ∈ (0, 1)

Suppose:

Ui (t, yi ) = yi (1− t2) + ty

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 33 / 49

Page 89: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

Suppose there n individuals, each individual i earns pre-tax income yi > 0.Total income Y =

∑ni=1 yi

Per capita income: y = Y /nIndividuals pay a proportional tax t ∈ (0, 1)Suppose:

Ui (t, yi ) = yi (1− t2) + ty

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 33 / 49

Page 90: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

Suppose there n individuals, each individual i earns pre-tax income yi > 0.Total income Y =

∑ni=1 yi

Per capita income: y = Y /nIndividuals pay a proportional tax t ∈ (0, 1)Suppose:

Ui (t, yi ) = yi (1− t2) + ty

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 33 / 49

Page 91: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

An individual’s optimal tax rate is:

∂Ui (t, yi )

∂t= −2yi t + y

0 = −2yi t∗ + y

y

2yi= t∗i

Checking the second derivative:

∂Ui (t, yi )

∂2t= −2yi

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 34 / 49

Page 92: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

If we set utility equal to some constant a, it defines an implicit function

Define Marginal rate of Substitution as

MRS = −∂U(t, yi )/∂t

∂U(t, yi/∂yi=∂Y (t)

∂t

∂U(t, yi )/∂t = −2yi t + y

∂U(t, yi/∂yi = (1− t2)

MRS =2yi t − y

1− t2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 35 / 49

Page 93: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

If we set utility equal to some constant a, it defines an implicit functionDefine Marginal rate of Substitution as

MRS = −∂U(t, yi )/∂t

∂U(t, yi/∂yi=∂Y (t)

∂t

∂U(t, yi )/∂t = −2yi t + y

∂U(t, yi/∂yi = (1− t2)

MRS =2yi t − y

1− t2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 35 / 49

Page 94: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

If we set utility equal to some constant a, it defines an implicit functionDefine Marginal rate of Substitution as

MRS = −∂U(t, yi )/∂t

∂U(t, yi/∂yi=∂Y (t)

∂t

∂U(t, yi )/∂t = −2yi t + y

∂U(t, yi/∂yi = (1− t2)

MRS =2yi t − y

1− t2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 35 / 49

Page 95: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

If we set utility equal to some constant a, it defines an implicit functionDefine Marginal rate of Substitution as

MRS = −∂U(t, yi )/∂t

∂U(t, yi/∂yi=∂Y (t)

∂t

∂U(t, yi )/∂t = −2yi t + y

∂U(t, yi/∂yi = (1− t2)

MRS =2yi t − y

1− t2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 35 / 49

Page 96: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

If we set utility equal to some constant a, it defines an implicit functionDefine Marginal rate of Substitution as

MRS = −∂U(t, yi )/∂t

∂U(t, yi/∂yi=∂Y (t)

∂t

∂U(t, yi )/∂t = −2yi t + y

∂U(t, yi/∂yi = (1− t2)

MRS =2yi t − y

1− t2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 35 / 49

Page 97: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

If we set utility equal to some constant a, it defines an implicit functionDefine Marginal rate of Substitution as

MRS = −∂U(t, yi )/∂t

∂U(t, yi/∂yi=∂Y (t)

∂t

∂U(t, yi )/∂t = −2yi t + y

∂U(t, yi/∂yi = (1− t2)

MRS =2yi t − y

1− t2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 35 / 49

Page 98: Justin Grimmer - stanford.edu

Example 2: Implicit Function Theorem (From Jim Fearon)

0.2 0.4 0.6 0.8

01

23

45

6

Tax

Inco

me

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 36 / 49

Page 99: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.

We will integrate a function over an area.Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)}

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 100: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.

Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)}

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 101: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.Area under function.

Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)}

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 102: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)}

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 103: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}

- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)}

−1.0 −0.5 0.0 0.5 1.0−1.

0−

0.5

0.0

0.5

1.0

X

Y

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 104: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}

- A = {x , y : x < y , x , y ∈ (0, 2)}

−1.0 −0.5 0.0 0.5 1.0−1.

0−

0.5

0.0

0.5

1.0

X

Y

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 105: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)} −1.0 0.0 1.0 2.0−

1.0

0.0

1.0

2.0

X

Y

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 106: Justin Grimmer - stanford.edu

Multivariate Integration

Suppose we have a function f : X → <1,with X ⊂ <2.We will integrate a function over an area.Area under function.Suppose that area, A, is in 2-dimensions

- A = {x , y : x ∈ [0, 1], y ∈ [0, 1]}- A = {x , y : x2 + y2 ≤ 1}- A = {x , y : x < y , x , y ∈ (0, 2)}

How do calculate the area under the function over these regions?

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 37 / 49

Page 107: Justin Grimmer - stanford.edu

Multivariate Integration

Definition

Suppose f : X → < where X ⊂ <n. We will say that f is integrable overA ⊂ X if we are able to calculate its area with refined partitions of A andwe will write the integral I =

∫A f (x)dA

That’s horribly abstract. There is an extremely helpful theorem that makesthis manageable.

Theorem

Fubini’s Theorem Suppose A = [a1, b1]× [a2, b2]× . . .× [an, bn] and thatf : A→ < is integrable. Then∫

Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 38 / 49

Page 108: Justin Grimmer - stanford.edu

Multivariate Integration

Definition

Suppose f : X → < where X ⊂ <n. We will say that f is integrable overA ⊂ X if we are able to calculate its area with refined partitions of A andwe will write the integral I =

∫A f (x)dA

That’s horribly abstract. There is an extremely helpful theorem that makesthis manageable.

Theorem

Fubini’s Theorem Suppose A = [a1, b1]× [a2, b2]× . . .× [an, bn] and thatf : A→ < is integrable. Then∫

Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 38 / 49

Page 109: Justin Grimmer - stanford.edu

Multivariate Integration

Definition

Suppose f : X → < where X ⊂ <n. We will say that f is integrable overA ⊂ X if we are able to calculate its area with refined partitions of A andwe will write the integral I =

∫A f (x)dA

That’s horribly abstract. There is an extremely helpful theorem that makesthis manageable.

Theorem

Fubini’s Theorem Suppose A = [a1, b1]× [a2, b2]× . . .× [an, bn] and thatf : A→ < is integrable. Then∫

Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 38 / 49

Page 110: Justin Grimmer - stanford.edu

Multivariate Integration Recipe

∫Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

1) Start with the inside integral x1 is the variable, everything else aconstant

2) Work inside to out, iterating

3) At the last step, we should arrive at a number

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 39 / 49

Page 111: Justin Grimmer - stanford.edu

Multivariate Integration Recipe

∫Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

1) Start with the inside integral x1 is the variable, everything else aconstant

2) Work inside to out, iterating

3) At the last step, we should arrive at a number

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 39 / 49

Page 112: Justin Grimmer - stanford.edu

Multivariate Integration Recipe

∫Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

1) Start with the inside integral x1 is the variable, everything else aconstant

2) Work inside to out, iterating

3) At the last step, we should arrive at a number

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 39 / 49

Page 113: Justin Grimmer - stanford.edu

Multivariate Integration Recipe

∫Af (x)dA =

∫ bn

an

∫ bn−1

an−1

. . .

∫ b2

a2

∫ b1

a1

f (x)dx1dx2 . . . dxn−1dxn

1) Start with the inside integral x1 is the variable, everything else aconstant

2) Work inside to out, iterating

3) At the last step, we should arrive at a number

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 39 / 49

Page 114: Justin Grimmer - stanford.edu

Intuition: Three Dimensional Jello Molds, a discussion

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 40 / 49

Page 115: Justin Grimmer - stanford.edu

Multivariate Uniform Distribution

Suppose f : [0, 1]× [0, 1]→ < and f (x1, x2) = 1 for all

x1, x2 ∈ [0, 1]× [0, 1]. What is∫ 10

∫ 10 f (x)dx1dx2?

∫ 1

0

∫ 1

0f (x)dx1dx2 =

∫ 1

0

∫ 1

01dx1dx2

=

∫ 1

0x1|10dx2

=

∫ 1

0(1− 0)dx2

=

∫ 1

01dx2

= x2|10= 1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 41 / 49

Page 116: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)=

b21 − a212

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 117: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)=

b21 − a212

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 118: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)=

b21 − a212

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 119: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)=

b21 − a212

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 120: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)=

b21 − a212

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 121: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)

=b21 − a21

2

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 122: Justin Grimmer - stanford.edu

Example 2Suppose f : [a1, b1]× [a2, b2]→ < is given by

f (x1, x2) = x1x2

Find∫ b2a2

∫ b1a1

f (x1, x2)dx1dx2

∫ b2

a2

∫ b1

a1

f (x1, x2)dx1dx2 =

∫ b2

a2

∫ b1

a1

x2x1dx1dx2

=

∫ b2

a2

x212x2|b1a1dx2

=b21 − a21

2

∫ b2

a2

x2dx2

=b21 − a21

2

(x222|b2a2

)=

b21 − a212

b22 − a222

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 42 / 49

Page 123: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2)

=

2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

=

2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

=

2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

=

2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]

=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 124: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:

∫ ∞

0

∫ ∞

0

f (x1, x2)

=

2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

=

2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

=

2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

=

2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]

=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 125: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) =

2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

=

2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

=

2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

=

2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]

=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 126: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

=

2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

=

2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

=

2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]

=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 127: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

= 2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

=

2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

=

2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]

=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 128: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

= 2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

= 2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

=

2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]

=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 129: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

= 2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

= 2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

= 2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]=

2[1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 130: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

= 2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

= 2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

= 2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]= 2[

1

2]

=

1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 131: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

= 2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

= 2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

= 2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]= 2[

1

2]

= 1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 132: Justin Grimmer - stanford.edu

Example 3: Exponential DistributionsSuppose f : <2

+ → < and that

f (x1, x2) = 2 exp(−x1) exp(−2x2)

Find:∫ ∞

0

∫ ∞

0

f (x1, x2) = 2

∫ ∞

0

∫ ∞

0

exp(−x1) exp(−2x2)dx1dx2

= 2

∫ ∞

0

exp(−x1)dx1

∫ ∞

0

exp(−2x2)dx2

= 2(− exp(−x)|∞0 )(−1

2exp(−2x2)|∞0 )

= 2

[(− lim

x1→∞exp(−x1) + 1)(−1

2lim

x2→∞exp(−2x2) +

1

2)

]= 2[

1

2]

= 1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 43 / 49

Page 133: Justin Grimmer - stanford.edu

Challenge Problems

1) Find∫ 10

∫ 10 x1 + x2dx1dx2

2) Demonstrate that

∫ b

0

∫ a

0x1 − 3x2dx1dx2 =

∫ a

0

∫ b

0x1 − 3x2dx2dx1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 44 / 49

Page 134: Justin Grimmer - stanford.edu

More Complicated Bounds of Integration

So far, we have integrated over rectangles. But often, we are interested inmore complicated regions

−1.0 0.0 1.0 2.0−1.

00.

01.

02.

0

X

Y

How do we do this?

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 45 / 49

Page 135: Justin Grimmer - stanford.edu

More Complicated Bounds of Integration

So far, we have integrated over rectangles. But often, we are interested inmore complicated regions

−1.0 0.0 1.0 2.0−1.

00.

01.

02.

0

X

Y

How do we do this?

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 45 / 49

Page 136: Justin Grimmer - stanford.edu

Example 4: More Complicated RegionsSuppose f : [0, 1]× [0, 1]→ <, f (x1, x2) = x1 + x2. Find area of functionwhere x1 < x2.Trick: we need to determine bound. If x1 < x2, x1 can take on any valuefrom 0 to x2

∫∫x1<x2

f (x) =

∫ 1

0

∫ x2

0

x1 + x2dx1dx2

=

∫ 1

0

x2x1|x20 dx2 +

∫ 1

0

x212|x20

=

∫ 1

0

x22dx2 +

∫ 1

0

x222

=x323|10 +

x326|10

=1

3+

1

6

=3

6=

1

2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 46 / 49

Page 137: Justin Grimmer - stanford.edu

Consider the same function and let’s switch the bounds.∫∫x1<x2

f (x) =

∫ 1

0

∫ 1

x1

x1 + x2dx2dx1

=

∫ 1

0x1x2|1x1 +

∫ 1

0

x222|1x1dx1

=

∫ 1

0x1 − x21 +

∫ 1

0

1

2− x21

2dx1

=x212|10 −

x313|10 +

x12|10 −

x316|10

=1

2− 1

3+

1

2− 1

6

= 1− 3

6

=1

2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 47 / 49

Page 138: Justin Grimmer - stanford.edu

Example 5: More Complicated RegionsSuppose f [0, 1]× [0, 1]→ <, f (x1, x2) = 1. What is the area ofx1 + x2 < 1? Where is x1 + x2 < 1? Where, x1 < 1− x2

∫∫x1+x2<1

f (x)dx =

∫ 1

0

∫ 1−x2

01dx1x2

=

∫ 1

0x1|1−x2

0 dx2

=

∫ 1

0(1− x2)dx2

= x2|10 −x222|10

= 1− (1

2)

=1

2

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 48 / 49

Page 139: Justin Grimmer - stanford.edu

Where we’re going

Tomorrow: Multivariate Optimization + Review of Mathematical ConceptsThursday: Probability Theory, Day 1

Justin Grimmer (Stanford University) Methodology I September 9th, 2014 49 / 49