For creating a high-quality publication-ready table of correlations from Stata output, we need to install asdoc program from SSC first.
ssc install asdoc, update
Once the installation is complete, we shall add the word asdoc
to the cor
command of Stata. Since we estimate correlations among all numeric variables of a dataset by typing cor
in Stata, we shall add asdoc as a prefix to the cor command. Let us load the auto.dta data from the Stata example files.
Example 1: Make a table of correlation for all variables.
sysuse auto, clear asdoc cor
Example 2: We can report variable labels instead of variable names
asdoc cor, label replace
Further, it is possible to write names of the variables in the column headings instead of sequential numbers. For this, we shall invoke the option nonum. Therefore, see example 3.
Example 3: Write variable names in column headers
sysuse auto, clear asdoc pwcorr, nonum replace
Read also :
Generate a correlation table with significance/stars
Generate a table of descriptive statistics
Generate a table of customized descriptive statistics
Hello,
Is it possible to added star (0.01 0.05 0.10) respectively to asdoc cor?
This is possible with
pwcorr
command. Use thesetstars()
option. The default significance levels for reporting stars are set at : *** for p-values <=0.01; ** for p-values <=0 .05, and * for p-values <=0.1. However, now we can set our own levels for statistical significance using option setstars. An example of setstars option looks like:As we can see from the above line, setstars separates each argument by a comma. Each argument has three components. The first component is the symbol (in our case it is *) which will be reported for the given significance elve. The second component is the @ sign that connects the significance level with the symbol. And the third component is the value at which the significance level is set. So if we want to report stars such that
We shall write the option setstars as
Does this mean that the stars to indicate significance are not possible for other correlation methods, such as Spearman?
Yes, you are right.
Dr. Shah,
Is there a way to bold the correlation result with the one they are significant at 5% below?
If we have many variables and they can not fit in one table, is there a way to break the correlation results into two panels (one on the top and another on the bottom).
Thank you.
HP