[R] Simulate dichotomous correlation matrix
Bliese, Paul D LTC USAMH
paul.bliese at us.army.mil
Wed Jun 28 13:31:55 CEST 2006
Newsgroup members,
Does anyone have a clever way to simulate a correlation matrix such that
each column contains dichotomous variables (0,1) and where each column
has different prevalence rates.
For instance, I would like to simulate the following correlation matrix:
> CORMAT[1:4,1:4]
PUREPT PTCUT2 PHQCUT2T ALCCUTT2
PUREPT 1.0000000 0.5141552 0.1913139 0.1917923
PTCUT2 0.5141552 1.0000000 0.2913552 0.2204097
PHQCUT2T 0.1913139 0.2913552 1.0000000 0.1803987
ALCCUTT2 0.1917923 0.2204097 0.1803987 1.0000000
Where the prevalence for each variable is:
> prevvals=c(0.26,0.10,0.09,0.10)
I can use the mvrnorm function in MASS to create a matrix containing
random normal variables and dichotomize these variables into 0,1;
however, this is a less than ideal solution as my observed correlation
matrix is downwardly biased and the amount of the bias is related to the
prevalence of each variable.
Thanks,
Paul D. Bliese
Heidelberg, Germany
COMM: +49-6221-172626
More information about the R-help
mailing list