我需要一些帮助来在 Latex 中构建回归表。
我想要做的是在右侧创建三个新列,就像已经存在的三个列一样,其中包含“场景 2”的内容,就像您在表中看到的“场景 1”一样,具有相同的因变量,相同的规范和相同的协变量。
我发送了我一直在处理的表格的代码:
\documentclass{article}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand{\mc}[1]{\multicolumn{1}{c@{}}{#1}}
\begin{document}
\begin{table}[H]
\centering
\caption{}
\label{}
\smallskip
\begin{tabular}{@{} l *{3}{d{2.6}} @{}}
\toprule
& \multicolumn{3}{c@{}}{Scenario 1} \\
\cmidrule(l){2-4}
& \multicolumn{3}{c@{}}{\textit{test}} \\[1ex]
& \mc{only treat} & \mc{treat + coduf} & \mc{all covs} \\
\midrule
$treat$ & 0.023 & 0.027 & 0.046 \\
& (0.023) & (0.027) & (0.046) \\ [1ex]
$coduf$ & & 0.002 & 0.003 \\
& & (0.003) & (0.003) \\ [1ex]
$mat\_casa$ & & & 0.043^{**} \\
& & & (0.019) \\ [1ex]
$abast\_agua2$ & & & -0.004 \\
& & & (0.008) \\ [1ex]
$trat\_agua$ & & & -0.004 \\
& & & (0.012) \\ [1ex]
$esgoto$ & & & 0.015 \\
& & & (0.018) \\ [1ex]
$sexo$ & & & 0.193^{***} \\
& & & (0.042) \\ [1ex]
$idade$ & & & 0.006^{***} \\
& & & (0.001) \\ [1ex]
$cor\_raca$ & & & 0.037^{**} \\
& & & (0.015) \\ [1ex]
$escol$ & & & -0.009 \\
& & & (0.009) \\ [1ex]
$comodos$ & & & -0.008 \\
& & & (0.102) \\ [1ex]
\textit{constant} & 0.230^{***} & 0.174^{**} & -0.506^{***} \\
& (0.034) & (0.092) & (0.172) \\ [1ex]
\midrule
F-test & \multicolumn{1}{c}{0.2661} & \multicolumn{1}{c}{0.2122} & \multicolumn{1}{c}{$7.6729^{***}$} \\
AIC & \multicolumn{1}{c}{37{,}997.73} & \multicolumn{1}{c}{38{,}099.51} & \multicolumn{1}{c}{33{,}477.07} \\
N & \multicolumn{1}{c}{624} & \multicolumn{1}{c}{624} & \multicolumn{1}{c}{624} \\
\bottomrule
\multicolumn{3}{@{}l@{}}{\footnotesize Nota: $^{*}\, p<0.1$; $^{**}\, p<0.05$; $^{***}\, p<0.01$}
\end{tabular}
\end{table}
\end{document}
答案1
很可能我不明白这个问题,但是什么阻止你直接添加列?当然,我没有要填写的数据,所以我把它留空了。我还要指出的是,我不会用它$
来使文本变为斜体,而是使用它\textit{...}
。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand{\mc}[1]{\multicolumn{1}{c@{}}{#1}}
\begin{document}
\begin{table}[H]
\centering
\caption{}
\label{}
\smallskip
\begin{tabular}{@{} l *{6}{d{5.6}} @{}}
\toprule
& \multicolumn{3}{c@{}}{Scenario 1} & \multicolumn{3}{c@{}}{Scenario 2} \\
\cmidrule(l){2-7}
& \multicolumn{3}{c@{}}{\textit{test}} \\[1ex]
& \mc{only treat} & \mc{treat + coduf} & \mc{all covs}
& \mc{only treat} & \mc{treat + coduf} & \mc{all covs}\\
\midrule
$treat$ & 0.023 & 0.027 & 0.046 \\
& (0.023) & (0.027) & (0.046) \\ [1ex]
$coduf$ & & 0.002 & 0.003 \\
& & (0.003) & (0.003) \\ [1ex]
$mat\_casa$ & & & 0.043^{**} \\
& & & (0.019) \\ [1ex]
$abast\_agua2$ & & & -0.004 \\
& & & (0.008) \\ [1ex]
$trat\_agua$ & & & -0.004 \\
& & & (0.012) \\ [1ex]
$esgoto$ & & & 0.015 \\
& & & (0.018) \\ [1ex]
$sexo$ & & & 0.193^{***} \\
& & & (0.042) \\ [1ex]
$idade$ & & & 0.006^{***} \\
& & & (0.001) \\ [1ex]
$cor\_raca$ & & & 0.037^{**} \\
& & & (0.015) \\ [1ex]
$escol$ & & & -0.009 \\
& & & (0.009) \\ [1ex]
$comodos$ & & & -0.008 \\
& & & (0.102) \\ [1ex]
\textit{constant} & 0.230^{***} & 0.174^{**} & -0.506^{***} \\
& (0.034) & (0.092) & (0.172) \\ [1ex]
\midrule
F-test & \multicolumn{1}{c}{0.2661} & \multicolumn{1}{c}{0.2122} & \multicolumn{1}{c}{$7.6729^{***}$} \\
AIC & \multicolumn{1}{c}{37{,}997.73} & \multicolumn{1}{c}{38{,}099.51} & \multicolumn{1}{c}{33{,}477.07} \\
N & \multicolumn{1}{c}{624} & \multicolumn{1}{c}{624} & \multicolumn{1}{c}{624} \\
\bottomrule
\multicolumn{3}{@{}l@{}}{\footnotesize Nota: $^{*}\, p<0.1$; $^{**}\, p<0.05$; $^{***}\, p<0.01$}
\end{tabular}
\end{table}
\end{document}