Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalized Method of Moments (GMM) estimation #22

Open
rickecon opened this issue Nov 27, 2017 · 0 comments
Open

Generalized Method of Moments (GMM) estimation #22

rickecon opened this issue Nov 27, 2017 · 0 comments

Comments

@rickecon
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant