问题
I am trying to export the Spearman correlation matrix into an rtf
or Excel file using estpost
and the community-contributed command esttab
.
However, I am getting the following error:
invalid subcommand
r(198);
Below is my code:
estpost spearman varlists, matrix stats(rho p) star(.05)
estimates store cl
esttab * using corrtable.rtf, b(%6.3f) label alignment(l) unstack not noobs compress replace
回答1:
The spearman
command does not work with estpost
, which is why Stata complains.
The following works for me:
sysuse auto, clear
spearman price mpg weight
matrix A = r(Rho)
esttab matrix(A, fmt(%5.2f)) using corrtable.rtf
---------------------------------------------------
A
price mpg weight
---------------------------------------------------
price 1.00 -0.54 0.49
mpg -0.54 1.00 -0.86
weight 0.49 -0.86 1.00
---------------------------------------------------
来源:https://stackoverflow.com/questions/57351327/how-to-export-spearman-correlations