Click on links to quickly browse to sections on this page

Default table of correlations


By default, asdocx writes the column header as (1), (2), … (n) while creating a table of correlations. Option nonum will force asdocx to write variable names as column headers.

asdocx can create tables almost for all Stata commands related to correlations such as simple correlations, pairwise and partial correlations, interclass correlation, and tetrachoric correlation. The following syntax is used for asdocx cor command:

Syntax

asdocx cor [varlist] [if] [in], [nonum label dec(#) asdocx_options]

To make a table of correlation for all numeric variables in the dataset, use asdocx cor
command

* Load Example dataset
sysuse auto, clear

* Table of correlations
asdocx cor, replace
Table: Matrix of correlations
Variables (1) (2) (3) (4) (5) (6) (7) (8) (9)
(1) price 1.000
(2) mpg -0.456 1.000
(3) rep78 0.007 0.402 1.000
(4) headroom 0.111 -0.400 -0.148 1.000
(5) trunk 0.323 -0.580 -0.157 0.661 1.000
(6) weight 0.548 -0.806 -0.400 0.479 0.669 1.000
(7) length 0.442 -0.804 -0.361 0.524 0.733 0.948 1.000
(8) turn 0.330 -0.735 -0.496 0.435 0.601 0.861 0.863 1.000
(9) displacement 0.548 -0.743 -0.412 0.476 0.629 0.932 0.862 0.812 1.000

Correlations among selected variables


To report correlations among selected variables, the list the variable names after the word
cor. So we were to report correlations among the variables price,
mpg, trunk, turn, and weight, our code would be:


* Table of correlations among selected variables
asdocx cor price mpg trunk turn weight, replace
Table: Matrix of correlations
Variables (1) (2) (3) (4) (5)
(1) price 1.000
(2) mpg -0.469 1.000
(3) trunk 0.314 -0.582 1.000
(4) turn 0.310 -0.719 0.601 1.000
(5) weight 0.539 -0.807 0.672 0.857 1.000

Report variable labels


* Variable labels instead of names 

asdocx cor price mpg trunk length weight, label replace
Matrix of correlations
Variables (1) (2) (3) (4)
(1) Price 1.000
(2) Trunk spa.. ft.) 0.314 1.000
(3) Length (in.) 0.432 0.727 1.000
(4) Weight (lbs.) 0.539 0.672 0.946 1.000

Add stars to show significance


* Variable labels instead of names 

asdocx pwcorr price trunk length weight rep78 turn mpg, star(all) replace
Pairwise correlations
Variables (1) (2) (3) (4) (5) (6)
(1) price 1.000
(2) trunk 0.314*** 1.000
(3) length 0.432*** 0.727*** 1.000
(4) weight 0.539*** 0.672*** 0.946*** 1.000
(5) rep78 0.007 -0.157 -0.361*** -0.400*** 1.000
(6) turn 0.310*** 0.601*** 0.864*** 0.857*** -0.496*** 1.000

Notes:  *** p<.01, ** p<.05, * p<.1