如何导出Spearman相关

时间:2019-08-05 01:32:24

标签: stata

我正在尝试使用rtf community-contributed 命令estpost将Spearman相关矩阵导出到esttab或Excel文件中。

但是,出现以下错误:

invalid subcommand
r(198);

下面是我的代码:

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 个答案:

答案 0 :(得分:3)

spearman命令不能与estpost一起使用,这就是Stata抱怨的原因。

以下对我有用:

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
---------------------------------------------------