回归表按小数对齐,同时以同行报告系数和 SE

回归表按小数对齐,同时以同行报告系数和 SE

我需要这个表格与系数值的小数点正确对齐。这里的减号也不好。我认为这可以通过实现,dcolumn但我显然无法实现,因为有两个小数点:一个用于系数值,另一个用于 SE 值。请帮忙!

\documentclass[12pt]{article}
\usepackage{stackengine}
\begin{document}
\begin{table}
\caption{Regression results I}
\begin{center}
\stackunder{
\begin{tabular}{llll} \hline
 & (1) & (2) & (3) \\
 & Low Value-added & High value-added & Total \\ \hline
RTA         & 0.718 (0.265)***  & -0.487 (0.544)    & 0.648 (0.286)** \\
RTA(t-3)    & 0.430 (0.208)**   & 0.419 (0.265)     & 0.425 (0.219)* \\
RTA(t-6)    & 0.047 (0.067)     & 0.540 (0.262)**   & 0.013 (0.070) \\
RTA(t-9)    & -0.074 (0.180)    & 0.353 (0.156)**   & -0.123 (0.186) \\
RTA(t-12)   & 0.553 (0.195)***  & 0.602 (0.328)*    & 0.494 (0.182)*** \\
GATT/WTO    & 0.277 (0.358)     & -0.527 (0.402)    & 0.085 (0.373) \\
Constant    & 8.081 (0.358)***  & 6.980 (0.763)***  & 8.606 (0.379)*** \\ 
Country/Time FE & Yes           & Yes               &Yes \\\hline
N           & 4,872             & 4,872             & 4,872 \\
R-squared   & 0.927             & 0.955             & 0.955 \\ \hline
\end{tabular}
}{\parbox{6in}{
\footnotesize Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.}
}
\end{center}
\end{table}
\end{document}

答案1

借助siunitx和分隔列来显示值及其标准误差。我还使用了tabular*和较小的字体大小,以确保表格适合文本宽度,并booktabs改善了水平线周围的间距:

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
\begin{table}
\caption{Regression results I}
%\setlength{\tabcolsep}{0pt} 
\small
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}*{3}{S[table-format=-1.3]@{\,}l}}
\toprule
                & \multicolumn{2}{c}{(1)}             & \multicolumn{2}{c}{(2)}              & \multicolumn{2}{c}{(3)}   \\
                & \multicolumn{2}{c}{Low Value-added} & \multicolumn{2}{c}{High value-added} & \multicolumn{2}{c}{Total} \\ 
\midrule
RTA             & 0.718  &(0.265)***                  & -0.487 &(0.544)                      & 0.648  &(0.286)**         \\
RTA(t-3)        & 0.430  &(0.208)**                   & 0.419  &(0.265)                      & 0.425  &(0.219)*          \\
RTA(t-6)        & 0.047  &(0.067)                     & 0.540  &(0.262)**                    & 0.013  &(0.070)           \\
RTA(t-9)        & -0.074 &(0.180)                     & 0.353  &(0.156)**                    & -0.123 & (0.186)          \\
RTA(t-12)       & 0.553  &(0.195)***                  & 0.602  &(0.328)*                     & 0.494  &(0.182)***        \\
GATT/WTO        & 0.277  &(0.358)                     & -0.527 &(0.402)                      & 0.085  &(0.373)           \\
Constant        & 8.081  &(0.358)***                  & 6.980  &(0.763)***                   & 8.606  &(0.379)***        \\ 
Country/Time FE & \multicolumn{2}{c}{Yes}             & \multicolumn{2}{c}{Yes}              & \multicolumn{2}{c}{Yes}   \\
\midrule
N               & \multicolumn{2}{c}{4,872}           & \multicolumn{2}{c}{4,872}            & \multicolumn{2}{c}{4,872} \\
R-squared       & \multicolumn{2}{c}{0.927}           & \multicolumn{2}{c}{0.955}            & \multicolumn{2}{c}{0.955} \\ 
\bottomrule
\multicolumn{7}{@{}p{\textwidth}@{}}{\footnotesize Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.}
\end{tabular*}

\end{table}
\end{document}

更新:

在评论中,原帖者说明了他们使用\usepackage[margin=1in]{geometry}什么来使表格适合文本宽度,而无需减小字体大小。我现在添加了两个不同的示例。在第一个示例中,我稍微拉伸了表格,使其与文本宽度完全一样宽,而在第二个示例中,表格的宽度与自然宽度一样宽,而下面的表格注释的宽度与表格的自然宽度一样宽。

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage{siunitx}
\usepackage{booktabs}

\usepackage{threeparttable} % only used for the second example

\usepackage[margin=1in]{geometry}

\begin{document}
\begin{table}
\caption{Regression results I --  as wide as the textwidth}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l *{3}{S[table-format=-1.3]@{}l}}
\toprule
                & \multicolumn{2}{c}{(1)}             & \multicolumn{2}{c}{(2)}              & \multicolumn{2}{c}{(3)}   \\
                & \multicolumn{2}{c}{Low Value-added} & \multicolumn{2}{c}{High value-added} & \multicolumn{2}{c}{Total} \\ 
\midrule
RTA             & 0.718  &(0.265)***                  & -0.487 &(0.544)                      & 0.648  &(0.286)**         \\
RTA(t--3)       & 0.430  &(0.208)**                   & 0.419  &(0.265)                      & 0.425  &(0.219)*          \\
RTA(t--6)       & 0.047  &(0.067)                     & 0.540  &(0.262)**                    & 0.013  &(0.070)           \\
RTA(t--9)       & -0.074 &(0.180)                     & 0.353  &(0.156)**                    & -0.123 & (0.186)          \\
RTA(t--12)      & 0.553  &(0.195)***                  & 0.602  &(0.328)*                     & 0.494  &(0.182)***        \\
GATT/WTO        & 0.277  &(0.358)                     & -0.527 &(0.402)                      & 0.085  &(0.373)           \\
Constant        & 8.081  &(0.358)***                  & 6.980  &(0.763)***                   & 8.606  &(0.379)***        \\ 
Country/Time FE & \multicolumn{2}{c}{Yes}             & \multicolumn{2}{c}{Yes}              & \multicolumn{2}{c}{Yes}   \\
\midrule
N               & \multicolumn{2}{c}{4,872}           & \multicolumn{2}{c}{4,872}            & \multicolumn{2}{c}{4,872} \\
R-squared       & \multicolumn{2}{c}{0.927}           & \multicolumn{2}{c}{0.955}            & \multicolumn{2}{c}{0.955} \\ 
\midrule
\end{tabular*}
\footnotesize Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.

\end{table}




\begin{table}
\centering
\begin{threeparttable}
\caption{Regression results I --  as wide as the table naturally is}
\begin{tabular}{l *{3}{S[table-format=-1.3]@{\enspace}l}}
\toprule
                & \multicolumn{2}{c}{(1)}             & \multicolumn{2}{c}{(2)}              & \multicolumn{2}{c}{(3)}   \\
                & \multicolumn{2}{c}{Low Value-added} & \multicolumn{2}{c}{High value-added} & \multicolumn{2}{c}{Total} \\ 
\midrule
RTA             & 0.718  &(0.265)***                  & -0.487 &(0.544)                      & 0.648  &(0.286)**         \\
RTA(t--3)       & 0.430  &(0.208)**                   & 0.419  &(0.265)                      & 0.425  &(0.219)*          \\
RTA(t--6)       & 0.047  &(0.067)                     & 0.540  &(0.262)**                    & 0.013  &(0.070)           \\
RTA(t--9)       & -0.074 &(0.180)                     & 0.353  &(0.156)**                    & -0.123 & (0.186)          \\
RTA(t--12)      & 0.553  &(0.195)***                  & 0.602  &(0.328)*                     & 0.494  &(0.182)***        \\
GATT/WTO        & 0.277  &(0.358)                     & -0.527 &(0.402)                      & 0.085  &(0.373)           \\
Constant        & 8.081  &(0.358)***                  & 6.980  &(0.763)***                   & 8.606  &(0.379)***        \\ 
Country/Time FE & \multicolumn{2}{c}{Yes}             & \multicolumn{2}{c}{Yes}              & \multicolumn{2}{c}{Yes}   \\
\midrule
N               & \multicolumn{2}{c}{4,872}           & \multicolumn{2}{c}{4,872}            & \multicolumn{2}{c}{4,872} \\
R-squared       & \multicolumn{2}{c}{0.927}           & \multicolumn{2}{c}{0.955}            & \multicolumn{2}{c}{0.955} \\ 
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\setlength\labelsep{0pt}
\footnotesize 
\item Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

在这两个表中,我都使用了包S中的类型列siunitx,以确保值与小数点分隔符对齐。为此,我使用了S[table-format=-1.3].,-因为有负数,1因为最多有一个整数数字,3因为最多有 3 位小数。对于标准错误的对齐,我使用了一个l类型列,但是,也可以使用S具有适当选项的类型列来完成此任务。由于所有三个列块都可以使用相同的table-format选项,我过去常常*{3}{...}重复第二组括号的内容三次。

为了确保第一个表格与文本宽度一样宽,我使用了tabular*而不是tabular并添加了@{\etracolsep{\fill}}。这确保了额外的宽度均匀分布在相邻列之间的所有空间之间。为了现在减少包含值的列与包含相应标准错误的列之间的距离,我@{}在列说明符之间添加了 。为了在表格下方显示表格注释,我只需将它们放在\end{tabular}和之间即可\end{table}。(\multicolum我原来的解决方案中的命令导致了您在评论中提到的列移位。对此深表歉意。)

在第二个示例中,我使用了常规tabular环境来确保表格保持其自然宽度。为了稍微减少值列和错误列之间的距离,我使用了@{\enspace}。如果您想要更小/更大的水平空间,您可能需要查看有哪些命令可以控制水平间距?对于其他一些命令,您可以使用 而不是\enspace。为了确保表格注释现在与表格一样宽,而不是与文本宽度一样宽(如第一个示例所示),我在这里使用了包threeparttable及其tablenotes环境来确保这一点。[flushleft] \setlength\labelsep{0pt} \footnotesize另外,使用 I 调整了文本的字体大小和对齐方式。

相关内容