If have not already done so, you can install the estout package to your Stata through the following command ssc install estoutįor this article, we once again make use of the Stata’s 1978 Automobile dataset. To output the correlation table we need to follow two steps: #Sas geodist example install# Run estpost to estimate the correlation matrix.Output the correlation table in a presentable way.ġ.Run estpost to estimate the correlation matrix correlate price mpg rep78 The command above displays a simple correlation table for the specified variables. The table includes correlations of each of the three variables with each other, i.e. ‘price’ with ‘mpg’, ‘price’ with ‘rep78’, and ‘mpg’ with ‘rep78’. estpost correlate price mpg rep78Īdding estpostat the start of our previous commands returns us a different table with two rows and four columns. This command creates a table that shows the correlation between only the first two variables in the command. So in this case, it will report the correlation between ‘price’ and ‘mpg’. estpost correlate price mpg rep78, matrix To include correlations between all three variables (or any number of variables), we add the option of matrixto our command. We now get a table with correlations between all three variables reported. The matrixoption helps report correlations of all possible pairwise combinations of the variables in our command. The reason we still see a difference between the correlation values in this table and the one reported by correlate is because the estpostcommand does not omit missing values when calculating correlations. In Stata, the command geodist can also measure the linear and curved (because the earth is spherical) distance between points. However, not all variables that we calculate correlations of have an equal number of observations. In our example, ‘price’ and ‘mpg’ have 74 observations, while ‘rep78’ has 69 (5 missing values).
0 Comments
Leave a Reply. |