how to generate a dataset of correlated variables with different distributions?

╄→гoц情女王★ 提交于 2019-12-24 04:12:38

问题


For teaching purposes, I need to generate random datasets of correlated random variables with different distributions. I have tried corr2data in Stata but it will not allow me to specify max and min values of the variables to be generated, just means, sd's and the covariance matrix. Therefore, I need to do messy adjustments after generation of the data. Various other details annoy me with corr2data. Is there a simpler way of doing this with MATLAB? I am not as familiar with this software as I am with Stata.


回答1:


If you have access to Statistics Toolbox as well as MATLAB, you can use the copula functionality to do this fairly easily. Using a copula, you can specify the marginal distributions of each variable, and a correlation structure between the variables.

You can then generate random numbers from the copula, fit it to data etc. as well.

See in the MATLAB documentation:

Copulas: Generate Correlated Samples



来源:https://stackoverflow.com/questions/21532856/how-to-generate-a-dataset-of-correlated-variables-with-different-distributions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!