[R] simulate correlated binary, categorical and continuous variable

Burak Aydin burak235813 at hotmail.com
Mon Apr 2 03:00:43 CEST 2012


Hello Greg,
Sorry for the confusion.
Lets say, I have a population.  I have 6 variables. They are correlated to
each other. I can get you pearson correlation, tetrachoric or polychoric
correlation coefficients.
2 of them continuous, 2 binary, 2 categorical.
Lets assume following conditions;
Co1 and Co2 are normally distributed continuous random variables. Co1-- N
(0,1), Co2--N(100,15)
Ca1 and Ca2 are categorical variables. Ca1 probabilities
=c(.02,.18,.28,.22,.30), Ca2 probs =c(.06,.18,.76)
Bi1 and Bi2 are binaries, Marginal probabilities Bi1 p= 0.4,  Bi2 p=0.5.
And , again, I have the correlations.

When I try to simulate this population I fail. If I keep the means and
probabilities same I lost the correct correlations. When I keep
correlations, I loose precision on means and frequencies/probabilities.
See these links please
http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/copulademo.html
http://stats.stackexchange.com/questions/22856/how-to-generate-correlated-test-data-that-has-bernoulli-categorical-and-contin
http://www.springerlink.com/content/011x633m554u843g/

  

--
View this message in context: http://r.789695.n4.nabble.com/simulate-correlated-binary-categorical-and-continuous-variable-tp4516433p4524863.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list