Stata Correlate

The correlate command calculates correlations.


Usage

To calculate the correlation matrix for some varlist, try:

corr varlist
matrix cor = r(C)

To calculate the covariance matrix, try:

corr varlist, covariance
matrix cov = r(C)

To calculate the precision matrix, follow-up the above with:

matrix invcov = invsym(cov)  //note that invsym() is preferred over inv()

Note that this command does not support weighting, as it is not an estimation command. To calculate the covariance matrix of survey estimates, for example, try using proportion:

svy: prop A B C D
estat vce
mata: st_matrix("cov", st_matrix("e(V)")[(1,3,5,7), (1,3,5,7)]) // select only every other row


CategoryRicottone