Personalisieren von esttab-Ergebnissen - Stata und LaTeX

Personalisieren von esttab-Ergebnissen - Stata und LaTeX

Ich verwende Benn Jans esttab-Befehl für Stata und kombiniere die Ergebnisse mit meinem LaTeX-Entwurfsdokument, wobei ich die nützlichen Tipps von Jörg Weber verwende. Ich möchte einige nicht standardmäßige Ergebnisse in meine Regressionstabelle aufnehmen, sie aber durch eine Zeile trennen und ihnen eventuell einen Untertitel zuordnen. Die Do-Datei in Stata würde etwa so aussehen:

sysuse auto, clear
reg mpg weight length i.foreign, robust 
test weight+length=0 
estadd scalar f_test=r(F)
estadd scalar ppdiff=r(p)
lincom weight+length
estadd scalar marginal=r(estimate)

est store A

esttab A using auto.tex, replace nonotes nomtitles f ///
    label booktabs b(3) alignment(S) eqlabels(none) ///
    drop(0.foreign) star(* 0.10 ** 0.05 *** 0.01) stats(marginal f_test ppdiff N r2, ///
    fmt(3 3 3 %9.0gc 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") ///
    labels(`"Hypothesis test"' `"F-test"' `"p-value"' `"Observations"' `"\(R^{2}\)"'))

Und der zugehörige LaTeX-Code:

\documentclass[12pt,A4,fleqn]{article}           % fleqn: align equations left

% Document:
\usepackage{geometry}                                     % Custom margins for single page, etc.
\usepackage{fullpage}                                     % Use the full page
\usepackage{setspace}                                     % Enables custom margins, doublespacing, etc.
\usepackage{pdflscape}                                    % Use: \begin{landscape} ... \end{landscape}
\usepackage{bm}

\usepackage{setspace}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{datetime}
\usepackage{longtable}
\usepackage{lscape} % To create a table in a landscape environment
\usepackage{rotating} % To use sideways table
\usepackage{rotfloat} % Use H with a sideways table
\usepackage{mathtools}
\usepackage{bibentry}
\usepackage{graphics}
\usepackage{threeparttable}
\usepackage{siunitx}
\usepackage{booktabs,dcolumn}
\usepackage{array}
\usepackage{hyperref}


% Font/text:
\usepackage[latin9]{inputenc}                             % Font definition and input type
\usepackage[T1]{fontenc}                                  % Font output type 
\usepackage{lmodern}                                      % Latin Modern fonts
\usepackage{textcomp}                                     % Supports many additional symbols
\usepackage{amsmath}                                      % Math equations, etc.
\usepackage{amsthm}                                       % Math theorems, etc.
\usepackage{amsfonts}                                     % Math fonts (e.g. script fonts)
\usepackage{amssymb}                                      % Math symbols such as infinity
\DeclareMathOperator*{\Max}{Max}                          % Better looking max function
\DeclareMathOperator*{\Min}{Min}                          % Better looking min function
\usepackage{color}                                        % Enables colored text
\definecolor{darkblue}{rgb}{0.0,0.0,0.66}                 % Custom color: dark blue
\usepackage[hyperfootnotes=false,bookmarksopen]{hyperref} % Enable hyperlinks, expand menu subtree
\hypersetup{                                              % Custom hyperlink settings
    pdffitwindow=false,                                   % true: window fit to page when opened
    pdfstartview={XYZ null null 1.00},                    % Fits the default zoom of the page to 100%
    pdfnewwindow=true,                                    % Links in new window
    colorlinks=true,                                      % false: boxed links; true: colored links
    linkcolor=darkblue,                                   % Color of internal links
    citecolor=darkblue,                                   % Color of links to bibliography
    urlcolor=darkblue  }                                  % Color of external links
%\usepackage{kpfonts}    % for nice fonts

% Images:
\usepackage{graphicx}                                     % Allows more types of images to be included
\usepackage[position=bottom]{subfig}                      % Enables arrayed images
\usepackage[section]{placeins}                            % Forces floats to stay in section
\usepackage{float}                                        % Used with restylefloat
\restylefloat{figure}                                     % "H" forces a figure to be "exactly here"
\usepackage[justification=centering]{caption}             % Center captions

% Tables/arrays:
\usepackage{booktabs}                                    % Table format - increases table spacing
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}    % Spacing for tables increased
\renewcommand{\arraystretch}{1}                          % Spaces arrays at 1x
\usepackage{dcolumn}                                     % Align decimals in tables (as option)
%\newcolumntype{.}{D{.}{.}{-1}}                           % Align decimals e.g. \begin{tabular}{c...}

% Miscellaneous:
\interfootnotelinepenalty=10000                           % Footnotes won't break across pages
\usepackage[semicolon]{natbib}                            % Bibliography and citation formating
\usepackage{datetime}                                     % Custom date format for date field
\newdateformat{mydate}{\monthname[\THEMONTH] \THEYEAR}    % Defining month year date format
%\usepackage{tikz}                                        % Timelines and other drawings
%\usetikzlibrary{decorations}                             % Formating for Tikz
% *****************************************************************
% Estout related things
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}}% Thanks to David Carlisle

\let\estinput=\input% define a new input command so that we can still flatten the document

\newcommand{\estwide}[3]{
        \vspace{.75ex}{
            \begin{tabular*}
            {\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
            \toprule
            \estinput{#1}
            \bottomrule
            \addlinespace[.75ex]
            \end{tabular*}
            }
        }   

\newcommand{\estauto}[3]{
        \centering{
        \vspace{.75ex}{
            \begin{tabular}{l*{#2}{#3}}
            \toprule
            \estinput{#1}
            \bottomrule
            \addlinespace[.75ex]
            \end{tabular}
            }
        }
        }

% Allow line breaks with \\ in specialcells
    \newcommand{\specialcell}[2][c]{%
    \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
    \vspace{-0.4ex}
    \captionsetup{justification=justified,font=footnotesize}
    \caption*{\hspace{6pt}\hangindent=1.5em #1}
    }
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}

\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}

% Add significance note with \starnote
\newcommand{\starnote}{\figtext{* p<0.1, ** p<0.05, *** p<0.01. Clustered standard errors in parentheses.}}

% *****************************************************************
% siunitx
% *****************************************************************
\usepackage{siunitx} % centering in tables
    \sisetup{
        detect-mode,
        tight-spacing       = true,
        group-digits        = false ,
        input-signs     = ,
        input-symbols       = ( ) [ ] - + *,
        input-open-uncertainty  = ,
        input-close-uncertainty = ,
        table-align-text-post   = false
        }
% *****************************************************************
% *****************************************************************
% *****************************************************************
% DOCUMENT BEGINS HERE
% *****************************************************************
% *****************************************************************
% *****************************************************************

\begin{document}

\begin{table}[h]
    \caption{Auto example} 
    \estauto{auto}{3}{S[table-format=3.4]}
    \starnote
    \label{tab2}
\end{table}

\end{document}

Wie kann ich in diesem Beispiel eine Zeile zwischen beispielsweise „p-Wert“ und „Beobachtungen“ einfügen (indem ich nur die Do-Datei ändere)? Und wenn ich eine Art Kennung für diesen Teil der Tabelle einfügen möchte, wie kann ich das tun? Jeder Vorschlag ist sehr willkommen.

verwandte Informationen