jmbejara / comp-econ-sp19

Main Course Repository for Computational Methods in Economics (Econ 21410, Spring 2019)
48 stars 26 forks source link

Monte Carlo Data Generating #18

Closed jbendelac closed 5 years ago

jbendelac commented 5 years ago

Hello, I'm having lots of issues with the Monte Carlo data generating process!

Are we supposed to set up two separate variance covariance matrices for the conditions, or a single one? Also I'm currently generating u, z and epsilon separately as normally distributed variables, but I'm a bit confused about how to make jointly multivariate normal. Finally, how do we ensure that all pairwise combinations not specified have covariances of 0?

chonganong commented 5 years ago

I used np.random.multivariate_normal, but this from the lecture notebook should also work.

cov = np.array([[2,1],
                [1,2]])
mean = np.array([0, 0])
X = scipy.stats.multivariate_normal.rvs(mean=mean, cov=cov, size=N)
jmbejara commented 5 years ago

Hi @jbendelac . As suggested by @chonganong, use scipy.stats.multivariate_normal.rvs to generate draws from a vector of jointly normal random variables.. This allows you to specify the mean vector and the variance-covariance matrix. Hope that helps!