OGcourse_F17 icon indicating copy to clipboard operation
OGcourse_F17 copied to clipboard

Generalized Method of Moments (GMM) estimation

Open rickecon opened this issue 7 years ago • 0 comments

In order to estimate the parameters to fit the tax functions in Problem Set 9 and to do weighted least squares, you will need to use generalized method of moments. I have a notebook for doing GMM in Python.

Let your error vector be eps_i and let your vector of population weights be w_i, and let theta be your vector of parameters to estimate. The GMM estimation problem, stated as a minimization problem is the following. Choose the vector of parameters to minimize the weighted sum of squared errors.

sum_i [ w_i *(eps_i ** 2) ]

You can substitute in the expression for eps_i in terms of paramters theta and data TotInc. In the linear case in Exercise 1a, the objective function being minimized is:

sum_i [ w_i * ( {ETR_i - beta_0 - beta_1 * TotInc_i} ** 2)]

You can write a criterion function that takes as arguments the values of the parameters and the data and returns the value of the criterion function at those values.

def criterion_lin(beta_vec, *args):
    '''
    --------------------------------------------------------
    Criterion function as a function of parameters and data
    --------------------------------------------------------
    INPUTS:
    beta_vec = (2,) vector, parameters to be estimated
    args     = length 3 tuple, (ETR, TotInc, weights)

    OBJECTS CREATED IN THIS FUNCTION:
    beta_0   = scalar, intercept value of linear function
    beta_1   = scalar, slope value of linear function
    ETR      = (N,) vector, effective tax rate data vector
    TotInc   = (N,) vector, total income data vector
    weights  = (N,) vector, population weights vector
    err_vec  = (N,) vector, epsilon errors vector
    crit_val = scalar, criterion value

    RETURNS: crit_val
    '''
    beta_0, beta_1 = beta_vec
    ETR, TotInc, weights = args
    err_vec = ETR - beta_0 - beta_1 * TotInc
    crit_val = (weights * (err_vec ** 2)).sum()

    return crit_val

You can then use scipy.optimize.minimize() to choose values of beta_0 and beta_1 that minimize that criterion function. @SophiaMo @jfan3

rickecon avatar Nov 27 '17 22:11 rickecon