
Ich habe ein Problem mit meinem threeparttable
s, das Eingaben von Stata empfängt. Früher habe ich damit gearbeitet und es hat perfekt funktioniert. Aber ich habe meine Tabellen ein wenig verdreht und es tritt ein Fehler auf.
Ich möchte eine Tabelle mit Feldern haben. Jedes Feld hat zwei Unterspalten und jede Unterspalte hat vier Unter-Unterspalten. Insgesamt habe ich also 9 Spalten, von denen eine der Variablenname und der Rest Modellnamen sind. Der Code ist unten angegeben:
\begin{sidewaystable}[htbp!]
\begin{threeparttable}[b]
\setlength{\tabcolsep}{0pt}
\small
\caption{Generalized DD Models}\label{Tab: Results1}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccccccc@{}}
\toprule\toprule
\multicolumn{1}{l}{} &
\multicolumn{9}{c}{Panel A - Without Controls} \addlinespace
\cmidrule{2-9}
\multicolumn{1}{l}{} &
\multicolumn{4}{c}{Simple DD} &
\multicolumn{4}{c}{PSM + DD} \\
\cmidrule{2-5}
\cmidrule{6-9}
\input{tabfig_MP/model1_5_dd_am12.tex}
\multicolumn{1}{l}{} &
\multicolumn{9}{c}{Panel B - With Controls} \addlinespace
\cmidrule{2-9}
\multicolumn{1}{l}{} &
\multicolumn{4}{c}{Simple DD} &
\multicolumn{4}{c}{PSM + DD} \\
\cmidrule{2-5}
\cmidrule{6-9}
\input{tabfig_MP/model1_6_dd_am12.tex} \\ \hline
\hline\hline
\end{tabular*}
\begin{tablenotes}[flushleft]
\footnotesize
\item \textit{Notes:}[1] Values in the brackets represent the standard errors. Standard errors is clustered at the school level. */**/*** denotes significance at the 10/5/1 percent.
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
Im obigen Code sind \input{tabfig_MP/model1_5_dd_am12.tex}
und \input{tabfig_MP/model1_6_dd_am12.tex}
Eingabedateien von Stata. Sie sind bis auf die Koeffizienten buchstäblich gleich. Im Folgenden stelle ich eine dieser Eingabedateien zur Verfügung:
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)} &\multicolumn{1}{c}{(7)} &\multicolumn{1}{c}{(8)} \\
& Test Score &Passing Rate &Top University &Participation Rate & Test Score &Passing Rate &Top University &Participation Rate \\
\hline
Treated & -5.74 & -0.34 & -0.09 & -4.63 & -18.88 & -5.62 & -3.04 & -5.31 \\
& (7.53) & (2.66) & (1.16) & (4.78) & (12.10) & (4.15) & (1.93) & (6.98) \\
Post & 55.99***& 18.53***& 2.10***& 28.91***& 57.74***& 18.50***& 1.10 & 31.72***\\
& (3.72) & (1.28) & (0.57) & (2.52) & (10.57) & (3.71) & (1.64) & (5.17) \\
Treated X Post & 41.54***& 13.88***& 6.04***& 12.39** & 39.40***& 14.32***& 7.27***& 8.09 \\
& (9.20) & (3.33) & (1.65) & (5.36) & (14.47) & (5.12) & (2.47) & (6.96) \\
Boys School & 35.74***& 9.46***& 2.69***& 27.22***& 28.66***& 8.06** & 2.36 & 25.36***\\
& (4.60) & (1.61) & (0.93) & (3.64) & (9.61) & (3.31) & (1.70) & (6.14) \\
Treated X Post X Boys school & -16.32* & -4.59 & 1.00 & -4.93 & -9.70 & -3.57 & 1.41 & -3.89 \\
& (9.55) & (3.71) & (2.38) & (8.02) & (13.15) & (4.97) & (2.85) & (9.50) \\
Girls School & -0.62 & -5.35***& -3.08***& 1.75 & 2.44 & -7.05* & -5.67***& 3.58 \\
& (4.96) & (1.69) & (0.72) & (3.49) & (13.46) & (4.25) & (1.70) & (6.56) \\
Treated X Post X Girls School & -48.05***& -14.79***& -6.01***& -21.05** & -50.81** & -13.06* & -3.47 & -22.11** \\
& (17.17) & (5.69) & (2.16) & (9.29) & (21.54) & (6.95) & (2.67) & (11.01) \\
Constant & 76.84***& 25.10***& 8.16***& 19.35***& 90.08***& 29.93***& 10.93***& 20.76***\\
& (4.14) & (1.40) & (0.63) & (3.14) & (11.16) & (3.73) & (1.58) & (6.10) \\
\hline
R-squared & 0.27 & 0.26 & 0.10 & 0.16 & 0.32 & 0.31 & 0.15 & 0.22 \\
Total Obs & 1158 & 1158 & 1158 & 1052 & 421 & 421 & 421 & 401 \\
Wenn ich meine Hauptdatei ausführe, die die Bibliotheken und erforderlichen Pakete enthält, wird angezeigt extra alignment tab has been changed to cr.
. Ich bin sicher, dass das Problem nicht an meinen Eingabedateien liegt, da es in anderen Kontexten funktioniert. Ich wäre dankbar, wenn mir jemand dabei helfen könnte, das herauszufinden.
Antwort1
Neben der Berücksichtigung von @Mico-Kommentaren (die Ihr Problem lösen) würde ich S
Spalten verwenden und Spaltenüberschriften mit makecell
dem im gleichnamigen Paket definierten Befehl schreiben:
\documentclass{article}
\usepackage{rotating}
\usepackage{booktabs, makecell, threeparttable}
\usepackage{siunitx}
\begin{document}
\begin{sidewaystable}
\begin{threeparttable}[b]
\setlength{\tabcolsep}{0pt}
\small
\caption{Generalized DD Models}
\label{Tab: Results1}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}l
*{8}{S[table-format=-2.2,
table-space-text-post={$^{***})},
input-symbols={( )}] }}
\toprule
\multicolumn{1}{l}{} &
\multicolumn{8}{c}{Panel A - Without Controls} \\
\addlinespace
\cmidrule{2-9}
& \multicolumn{4}{c}{Simple DD} & \multicolumn{4}{c}{PSM + DD} \\
\cmidrule{2-5}
\cmidrule{6-9}
%\input{tabfig_MP/model1_5_dd_am12.tex}
& \multicolumn{8}{c}{Panel B - With Controls} \\
% \addlinespace
\cmidrule{2-9}
& \multicolumn{4}{c}{Simple DD} & \multicolumn{4}{c}{PSM + DD} \\
\cmidrule{2-5}
\cmidrule{6-9}
%\input{tabfig_MP/model1_6_dd_am12.tex} \\ \hline
& {\makecell{(1)\\Test\\ Score}}
& {\makecell{(2)\\Passing\\ Rate}}
& {\makecell{(3)\\Top\\ University}}
& {\makecell{(4)\\Participation\\ Rate}}
& {\makecell{(5)\\Test\\ Score}}
& {\makecell{(6)\\Passing\\ Rate}}
& {\makecell{(7)\\Top\\ University}}
& {\makecell{(8)\\Participation\\ Rate}} \\
\midrule
Treated & -5.74 & -0.34 & -0.09 & -4.63
& -18.88 & -5.62 & -3.04 & -5.31 \\
& (7.53) & (2.66) & (1.16) & (4.78)
& (12.10) & (4.15) & (1.93) & (6.98) \\
Treated X Post
& 41.54\tnote{***} & 13.88\tnote{***} & 6.04\tnote{***} & 12.39\tnote{**}
& 39.40\tnote{***} & 14.32\tnote{***} & 7.27\tnote{***} & 8.09 \\
& (9.20) & (3.33) & (1.65) & (5.36)
& (14.47) & (5.12) & (2.47) & (6.96) \\
\midrule
\end{tabular*}
\begin{tablenotes}[flushleft]
\footnotesize
\item \textit{Notes:}[1] Values in the brackets represent the standard errors. Standard errors is clustered at the school level. */**/*** denotes significance at the 10/5/1 percent.
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document}
Antwort2
Hier ist eine Lösung, die sehr ähnlich ist@Zarkos Lösung, mit folgendem Hauptunterschied: Da Sie keine \tnote
Anweisungen verwenden, tablenotes
ist die Verwendung einer Umgebung nicht erforderlich. Kurz gesagt, der threeparttable
Wrapper wird weggelassen, da er nichts Nützliches tut.
Diese Lösung beinhaltet auch die Kommentare, die ich zuvor gepostet habe.
\documentclass{article}
\usepackage{rotating,booktabs,makecell,siunitx}
\sisetup{table-space-text-post = ***,
table-align-text-post = false,
input-symbols={()} }
\begin{document}
\begin{sidewaystable}
\setlength{\tabcolsep}{0pt}
\small
\caption{Generalized DD Models\strut}
\label{Tab:Results1}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l *{8}{S[table-format=-2.2]} }
\toprule
% & \multicolumn{8}{c}{Panel A --- Without Controls}\\
% \cmidrule{2-9}
% & \multicolumn{4}{c}{Simple DD} & \multicolumn{4}{c}{PSM + DD} \\
% \cmidrule{2-5} \cmidrule{6-9}
% %\input{tabfig_MP/model1_5_dd_am12.tex}
% \\
& \multicolumn{8}{c}{Panel B --- With Controls}\\
\cmidrule{2-9}
& \multicolumn{4}{c}{Simple DD} & \multicolumn{4}{c}{PSM + DD} \\
\cmidrule{2-5} \cmidrule{6-9}
%\input{tabfig_MP/model1_6_dd_am12.tex} \\
& {(1)} & {(2)} & {(3)} & {(4)}
& {(5)} & {(6)} & {(7)} & {(8)} \\
& {\makecell{Test\\ Score}} & {\makecell{Passing\\ Rate}}
& {\makecell{Top\\University}} & {\makecell{Participation\\Rate}}
& {\makecell{Test\\ Score}} & {\makecell{Passing\\ Rate}}
& {\makecell{Top\\University}} & {\makecell{Participation\\Rate}}
\\
\midrule
Treated & -5.74 & -0.34 & -0.09 & -4.63 & -18.88 & -5.62 & -3.04 & -5.31 \\
& (7.53) & (2.66) & (1.16) & (4.78) & (12.10) & (4.15) & (1.93) & (6.98) \\
Post & 55.99***& 18.53***& 2.10***& 28.91***& 57.74***& 18.50***& 1.10 & 31.72***\\
& (3.72) & (1.28) & (0.57) & (2.52) &(10.57) & (3.71) & (1.64) & (5.17) \\
Treated $\times$ Post & 41.54***& 13.88***& 6.04***& 12.39** & 39.40***& 14.32***& 7.27***& 8.09 \\
& (9.20) & (3.33) & (1.65) & (5.36) &(14.47) & (5.12) & (2.47) & (6.96) \\
Boys School & 35.74***& 9.46***& 2.69***& 27.22***& 28.66***& 8.06** & 2.36 & 25.36***\\
& (4.60) & (1.61) & (0.93) & (3.64) & (9.61) & (3.31) & (1.70) & (6.14) \\
Treated $\times$ Post $\times$ Boys school & -16.32* & -4.59 & 1.00 & -4.93 & -9.70 & -3.57 & 1.41 & -3.89 \\
& (9.55) & (3.71) & (2.38) & (8.02) &(13.15) & (4.97) & (2.85) & (9.50) \\
Girls School & -0.62 & -5.35***& -3.08***& 1.75 & 2.44 & -7.05* & -5.67***& 3.58 \\
& (4.96) & (1.69) & (0.72) & (3.49) &(13.46) & (4.25) & (1.70) & (6.56) \\
Treated $\times$ Post $\times$ Girls School & -48.05***& -14.79***& -6.01***& -21.05** & -50.81** & -13.06* & -3.47 & -22.11** \\
&(17.17) & (5.69) & (2.16) & (9.29) &(21.54) & (6.95) & (2.67) &(11.01) \\
Constant & 76.84***& 25.10***& 8.16***& 19.35***& 90.08***& 29.93***& 10.93***& 20.76***\\
& (4.14) & (1.40) & (0.63) & (3.14) &(11.16) & (3.73) & (1.58) & (6.10) \\
\midrule
R-squared & 0.27 & 0.26 & 0.10 & 0.16 & 0.32 & 0.31 & 0.15 & 0.22 \\
Total Obs & {1158} & {1158} & {1158} & {1052} & {421} & {421} & {421} & {401} \\
\bottomrule
\end{tabular*}
\medskip
\textit{Notes}: Values in parentheses represent standard errors.
Standard errors are clustered at the school level.
*/**/*** denote statistical significance at the 10/5/1 percent levels.
\end{sidewaystable}
\end{document}
Antwort3
Ihre Antworten waren sehr hilfreich. Ich verwende esttab in Stata, um die Regressionsdatei zu erstellen, die Sie manuell bearbeitet haben, um meine Frage zu beantworten. Da ich mehrere Regressionstabellen habe und diese häufig geändert werden, frage ich mich, ob es eine Möglichkeit gibt, Stata anzuweisen, nur den Teil der Regressionstabelle unten gemäß Ihren Änderungen auszugeben.
Treated & -5.74 & -0.34 & -0.09 & -4.63 & -18.88 & -5.62 & -3.04 & -5.31 \\
& (7.53) & (2.66) & (1.16) & (4.78) & (12.10) & (4.15) & (1.93) & (6.98) \\
Post & 55.99***& 18.53***& 2.10***& 28.91***& 57.74***& 18.50***& 1.10 & 31.72***\\
& (3.72) & (1.28) & (0.57) & (2.52) &(10.57) & (3.71) & (1.64) & (5.17) \\
Treated $\times$ Post & 41.54***& 13.88***& 6.04***& 12.39** & 39.40***& 14.32***& 7.27***& 8.09 \\
& (9.20) & (3.33) & (1.65) & (5.36) &(14.47) & (5.12) & (2.47) & (6.96) \\
Boys School & 35.74***& 9.46***& 2.69***& 27.22***& 28.66***& 8.06** & 2.36 & 25.36***\\
& (4.60) & (1.61) & (0.93) & (3.64) & (9.61) & (3.31) & (1.70) & (6.14) \\
Treated $\times$ Post $\times$ Boys school & -16.32* & -4.59 & 1.00 & -4.93 & -9.70 & -3.57 & 1.41 & -3.89 \\
& (9.55) & (3.71) & (2.38) & (8.02) &(13.15) & (4.97) & (2.85) & (9.50) \\
Girls School & -0.62 & -5.35***& -3.08***& 1.75 & 2.44 & -7.05* & -5.67***& 3.58 \\
& (4.96) & (1.69) & (0.72) & (3.49) &(13.46) & (4.25) & (1.70) & (6.56) \\
Treated $\times$ Post $\times$ Girls School & -48.05***& -14.79***& -6.01***& -21.05** & -50.81** & -13.06* & -3.47 & -22.11** \\
&(17.17) & (5.69) & (2.16) & (9.29) &(21.54) & (6.95) & (2.67) &(11.01) \\
Constant & 76.84***& 25.10***& 8.16***& 19.35***& 90.08***& 29.93***& 10.93***& 20.76***\\
& (4.14) & (1.40) & (0.63) & (3.14) &(11.16) & (3.73) & (1.58) & (6.10) \\
\midrule
R-squared & 0.27 & 0.26 & 0.10 & 0.16 & 0.32 & 0.31 & 0.15 & 0.22 \\
Total Obs & {1158} & {1158} & {1158} & {1052} & {421} & {421} & {421} & {401} \\