formatting - 如何在 Stata esttab 的 LaTeX 输出表中按模型对回归进行分组
问题描述
我正在尝试拥有它,所以我有 3 个不同的模型,每个模型下面都有两个回归。理想情况下,我希望表格列的组织方式如下
Group 1 Group 2 Group 3
Reg1 Reg2 Reg3 Reg4 Reg5 Reg6
我尝试从这个链接中获取代码,但收到一条错误消息
0.0179 & -0.0149\sym {**} & 0.0320 & 0.00967 & 0.0320 & 0.00967 \\ & \ETC.
! File ended while scanning use of \@@@cmidrule.
<inserted text>
\par
<*> test.tex
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
我正在使用的所有软件包的代码是
\documentclass[AER,reviewmode]{AEA}
\usepackage{natbib}
\usepackage{subfiles}
\usepackage{graphicx}
\graphicspath{{images/}{../images/}}
\usepackage{amsmath,amsfonts}
\usepackage{mathptmx}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{dcolumn}
\begin{document}
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{IV Regression Results, 1990\label{tab2}}
\begin{tabular}{l*{6}{D{.}{.}{-1}}}
\toprule
&\multicolumn{2}{c}{OLS} &\multicolumn{2}{c}{First Stage} &\multicolumn{2}{c}{Second Stage} \\\cmidrule(lr){@spam}\cmidrule(lr){@spam}\cmidrule(lr){@spam}
&\multicolumn{1}{c}{Isolation, 1990}&\multicolumn{1}{c}{Dissimilarity, 1990}&\multicolumn{1}{c}{Isolation, 1990}&\multicolumn{1}{c}{Dissimilarity, 1990}&\multicolumn{1}{c}{Isolation, 1990}&\multicolumn{1}{c}{Dissimilarity, 1990}\\
\midrule
Housing Supply Elasticity& -0.0179 & -0.0149\sym{**} & 0.0320 & 0.00967 & 0.0320 & 0.00967 \\
& (0.0116) & (0.00642) & (0.0373) & (0.0244) & (0.0373) & (0.0244) \\
\addlinespace
Population & 5.69e-08\sym{***}& 2.83e-08\sym{***}& 5.58e-08\sym{***}& 2.78e-08\sym{***}& 5.58e-08\sym{***}& 2.78e-08\sym{***}\\
& (1.26e-08) & (6.56e-09) & (1.05e-08) & (6.84e-09) & (1.05e-08) & (6.84e-09) \\
\addlinespace
WRLURI & -0.0757\sym{***}& -0.0503\sym{***}& 0.0742 & 0.0235 & 0.0742 & 0.0235 \\
& (0.0203) & (0.0126) & (0.109) & (0.0710) & (0.109) & (0.0710) \\
\addlinespace
Constant & 0.269\sym{***}& 0.580\sym{***}& 0.167\sym{**} & 0.530\sym{***}& 0.167\sym{**} & 0.530\sym{***}\\
& (0.0346) & (0.0198) & (0.0801) & (0.0524) & (0.0801) & (0.0524) \\
\midrule
Observations & 228 & 228 & 228 & 228 & 228 & 228 \\
\(R^{2}\) & 0.188 & 0.130 & . & 0.017 & . & 0.017 \\
Adjusted \(R^{2}\) & 0.177 & 0.119 & . & 0.004 & . & 0.004 \\
\bottomrule
\multicolumn{7}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{7}{l}{\footnotesize \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\
\end{tabular}
\end{table}
\end{document}
解决方案
看起来您的 esttab 命令中有错字,但我无法确定,因为您尚未发布该代码。您需要\cmidrule
语句中的列范围,例如\cmidrule(lr){2-3}
. 您发布的乳胶代码有\cmidrule(lr){@spam}
。
请注意明显的拼写错误(@spam 代表 @span)。根据estout 文档,使用@span
withinerepeat
应该返回您正在寻找的列范围。所以修复错字应该可以做到。
推荐阅读
- amazon-web-services - AWS API Gateway GET 方法失败
- elasticsearch - 优化将数据导入弹性搜索
- azure-ad-b2c - 依赖方策略中的 Azure AD B2C 扩展属性
- security - Docker 容器通信
- firefox - 如何使用 fetch API 获取本地文件信息以获取 firefox 扩展
- dependency-injection - Ninject访问实例解析路径
- qt - 查找 Qt QML 文本元素的绘制 X 和 Y 位置(例如左上角)
- azure - 用于连接到 AzureRM 订阅上的 Azure 云服务实例的 Powershell 会话
- django - Python + Django + Celery 的发布速度非常低
- javascript - 来自 HTML 的“添加到阅读列表”