在stata中获取具有显着性水平的格式化相关系数

问题描述 投票:0回答:1

我在 STATA 中估计了一个相关 I 矩阵:

  estpost corr var1 var2 var3 var4, matrix listwise 

我想将输出输出到乳胶,同时仅显示小数点后 3 位和重要的星星。 我可以分别做这两件事,但不知何故无法同时完成。

 esttab using TABLE2B.tex, replace cells("rho(fmt(%9.3f))")  nonum  not unstack compress label  //version with correct formatting

 esttab using TABLE2Bstars.tex, replace   nonum  not unstack compress label //version with stars. 

我尝试更改变量的格式。它并没有改变结果。

stata correlation
1个回答
0
投票

试试这个:

. sysuse auto, clear
(1978 automobile data)

. estpost corr price mpg weight foreign, matrix listwise

             |      e(b)     e(rho)       e(p)   e(count) 
-------------+--------------------------------------------
price        |                                            
       price |         1          1                    74 
         mpg | -.4685967  -.4685967   .0000255         74 
      weight |  .5386115   .5386115   7.42e-07         74 
     foreign |  .0487195   .0487195   .6801851         74 
mpg          |                                            
         mpg |         1          1                    74 
      weight | -.8071749  -.8071749   3.80e-18         74 
     foreign |  .3933974   .3933974   .0005254         74 
weight       |                                            
      weight |         1          1                    74 
     foreign | -.5928299  -.5928299   2.62e-08         74 
foreign      |                                            
     foreign |         1          1                    74 

. esttab using TABLE2B.tex, replace cells("rho(fmt(%9.3f))") nonum not unstack compress label
(output written to TABLE2B.tex)

. type TABLE2B.tex
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{4}{c}}
\hline\hline
                &\multicolumn{4}{c}{}                   \\
                &    Price&Mileage (mpg)&Weight (lbs.)&Car origin\\
                &      rho&      rho&      rho&      rho\\
\hline
Price           &    1.000&         &         &         \\
Mileage (mpg)   &   -0.469&    1.000&         &         \\
Weight (lbs.)   &    0.539&   -0.807&    1.000&         \\
Car origin      &    0.049&    0.393&   -0.593&    1.000\\
\hline
Observations    &       74&         &         &         \\
\hline\hline
\end{tabular}
}

. esttab using TABLE2Bstars.tex, replace  cells(rho(fmt(%9.3f) star)) nonum not unstack compress label
(output written to TABLE2Bstars.tex)

. type TABLE2Bstars.tex
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{4}{c}}
\hline\hline
                &\multicolumn{4}{c}{}                                                       \\
                &    Price         &Mileage (mpg)         &Weight (lbs.)         &Car origin         \\
                &      rho         &      rho         &      rho         &      rho         \\
\hline
Price           &    1.000         &                  &                  &                  \\
Mileage (mpg)   &   -0.469\sym{***}&    1.000         &                  &                  \\
Weight (lbs.)   &    0.539\sym{***}&   -0.807\sym{***}&    1.000         &                  \\
Car origin      &    0.049         &    0.393\sym{***}&   -0.593\sym{***}&    1.000         \\
\hline
Observations    &       74         &                  &                  &                  \\
\hline\hline
\end{tabular}
}

esttab
estout
的包装。将
noisily
选项添加到
esttab
可以让您看到
estout
在幕后正在做什么。这通常可以帮助您找到此类问题的解决方案。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.