Giter VIP home page Giter VIP logo

Comments (3)

jmbejara avatar jmbejara commented on July 18, 2024

The need the covariance matrix and mean array because we need to give the computer a specific distribution to generate data from. The exercise in class was to generate "synthetic data" from a known distribution. Then, we run our estimation procedure on that synthetic data and test how our estimator performs. These particular numbers were chosen arbitrarily. I just wanted numbers that would allow me to demonstrate omitted variable bias.

In the HW, I describe a probability distribution in which an instrument exists that will allow us to correct for this endogeneity. You'll need to write code to generate synthetic data from that probability distribution. This means that you'll need to generate data for epsilon, u, and z_1. You'll use that data to construct the data for x_1 and y.

Hope this answers your question! Lemme know if I can elaborate on anything further.

from comp-econ-sp19.

erineidschun avatar erineidschun commented on July 18, 2024

Not sure I understand how to construct the covariance matrix, as I am not sure the "order" to put the rows and columns in in the matrix in order to correctly place the covariance values given.

Currently I have this. I'm not sure if I got the covariance matrix right.

cov = np.array([[1,0, 0],
                [0,1,0.5],
                [0, 0.5, 1]])
mean = np.array([0, 0, 0])
beta0, beta1 , gamma0, gamma1 = 1, 1, 1, 1

Z = scipy.stats.multivariate_normal.rvs(mean=mean, cov=cov, size=N)
df = pd.DataFrame(Z, columns=['epsilon', 'u', 'z1'])
df['x1'] = gamma0 + gamma1 * df.z1 + df.u
df['y'] = beta0 + beta1 * df.x1 + df.epsilon
return df

from comp-econ-sp19.

jmbejara avatar jmbejara commented on July 18, 2024

The order doesn't really matter as long as you're consistent with it. The random number generator will give you an N x 3 matrix of random variables. Each row is a separate draw. The order of the variables in that row is the order that you chose when you defined the mean vector and the variance-covariance matrix.

Judging from the ordering of you columns columns=['epsilon', 'u', 'z1'], it looks like you might need to adjust your variance-covariance matrix. We should have covariance between $\epsilon$ and $u$ as 1/2.

from comp-econ-sp19.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.