I will preface this by saying that I am not super familiar with matrices in Stata. That said, I am trying to use CORR2DATA to create a dataset that matches a correlation structure from a different dataset. I know I can manually enter the correlation structure into CORR2DATA, but it is rather large, so I would like to avoid that, if possible. I have run PWCORR on the existing dataset and saved the stored correlation matrix as a matrix, but I am getting an error when I try to use that matrix in CORR2DATA. I believe the problem here is that PWCORR gives the lower half of the correlation matrix, while CORR2DATA requires the upper half (I tried the 'cstorage(lower)' option and that didn't work). Here is the code I am using (variables changed for ease):
Code:
pwcorr var1-var3 matrix C_var1_3 = r(C) corr2data var1 var2 var3, n(100) means(10197.48 11269.10 490.71 80.84) sds(12380.57 15761.20 448.63 65.49) corr(C_var1_3) clear
corr() incorrectly specified
diagonal elements should be 1
When I add the cstorage(lower) option to the corr2data code, the error I get is:
invalid cstorage; matrix is found to be square
I'm not sure what is going on here. I tried transposing the correlation matrix, but when I list each one, I get the same exact looking matrix. The code I used looked like this:
Code:
matrix C_var1_3_Trans = C_var1_3'
0 Response to Use stored correlation matrix from PWCORR in CORR2DATA
Post a Comment