여러 패널이 있는 세 부분으로 구성된 테이블

여러 패널이 있는 세 부분으로 구성된 테이블

threeparttableStata로부터 입력을 받는 데 문제가 있습니다 . 예전에 일했는데 완벽하게 작동했어요. 하지만 테이블을 조금 비틀었더니 오류가 발생했습니다.

패널이 있는 테이블을 갖고 싶습니다. 각 패널에는 2개의 하위 열이 있고 각 하위 열에는 4개의 하위 열이 있습니다. 따라서 총 9개의 열이 있는데 그 중 하나는 변수 이름이고 나머지는 모델 이름입니다. 코드는 아래와 같습니다:

\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}

위 코드에서 \input{tabfig_MP/model1_5_dd_am12.tex}와 는 \input{tabfig_MP/model1_6_dd_am12.tex}Stata의 입력 파일입니다. 계수를 제외하면 문자 그대로 동일합니다. 아래에서는 해당 입력 파일 중 하나를 제공합니다.

&\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 \\

라이브러리와 필요한 패키지가 포함된 기본 파일을 실행하면 extra alignment tab has been changed to cr.. 다른 컨텍스트에서 작동하므로 문제가 내 입력 파일에 있는 것이 아니라고 확신합니다. 누구든지 이 문제를 파악하는 데 도움을 주시면 감사하겠습니다.

답변1

문제를 해결하는 @Mico 주석을 고려하는 것 외에도 동일한 이름의 패키지에 정의된 명령을 S사용하여 열을 사용하고 열 헤더를 작성합니다 .makecell

\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}

여기에 이미지 설명을 입력하세요

답변2

다음은 매우 유사한 솔루션입니다.@Zarko의 솔루션, 다음과 같은 주요 차이점이 있습니다. 지시문을 사용하지 않으므로 환경 \tnote을 사용할 tablenotes필요가 없습니다. 즉, threeparttable래퍼는 유용한 작업을 수행하지 않으므로 생략됩니다.

이 솔루션에는 이전에 게시한 의견도 포함되어 있습니다.

여기에 이미지 설명을 입력하세요

\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}

답변3

귀하의 답변은 매우 도움이 되었습니다. 나는 내 질문에 대답하기 위해 수동으로 편집한 회귀 파일을 생성하기 위해 stata에서 esttab을 사용하고 있습니다. 회귀표가 여러 개 있고 변경사항이 자주 발생하기 때문에 편집에 따라 아래 회귀표의 일부만 출력하도록 Stata에 지시할 수 있는 방법이 있는지 궁금합니다.

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}    \\

관련 정보