0

I have long used esttab to output regression tables from stata into LaTeX. Now I'm trying to line up the columns by decimal place. The issue I'm having is that the coefficient labels on the left have "." in them (they are variable names). As such, they also get lined up by the ".", which I don't like. I can go in and put "$" around the variable names, but this is a lot of manual effort, and I'm trying to minimize that after the esttab output. Is there some way to use dcolumn such that the variable names with the "." in them won't be subject to the dcolumn rules?

%% PAPER FORMATTING STUFF%{{*{
% DOCUMENT SETTINGS%{{*{
\documentclass[12pt,letter]{article}\usepackage{titling}
\newcommand{\subtitle}[1]{%
  \posttitle{%
    \par\end{center}
    \begin{center}\large#1\end{center}
    \vskip0.5em}%
}

% In your .tex file
% !TEX program = pdflatex 


%% % School color found from university's graphic identity site:
%% % http://isites.harvard.edu/icb/icb.do?keyword=k75408&pageid=icb.page392732
%% \definecolor{SchoolColor}{rgb}{0.6471, 0.1098, 0.1882} % Crimson
%% \definecolor{chaptergrey}{rgb}{0.6471, 0.1098, 0.1882} % for chapter numbers


% keep exhibits in their section%{{*{
\usepackage[section]{placeins}
% fix the floats for the tables
\usepackage{float}
\usepackage{subcaption} 
% keep exhibits in their section%}*}}

%\renewcommand*{\familydefault}{\ttdefault}


%\parindent0pt  % to stop indenting paragraphs
%\usepackage{helvet}
%\usepackage{hyperref}



%\hypersetup{
%    colorlinks,
%    citecolor=blue,
%    filecolor=black,
%    linkcolor=black,
%    urlcolor=blue,
%}

\usepackage{fullpage}
\usepackage{tabularx}
 \usepackage{graphicx}
\usepackage{dcolumn}
 \usepackage{lscape} 
    % for landscape orientation of reg tables.  must be after the graphx?
%\usepackage[top=1cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{geometry}
%}*}}



\begin{document}

%\newcolumntype{.}{D{.}{.}{5.5}}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{table}[htbp]\centering
        \footnotesize
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Estimation of Differential Effects: Measurement of Scandal Using Media Attention \label{tab:misconduct_t4.tex}} 
                \begin{tabular}{d{-1}d{-1}d{-1}d{-1}d{-1}{c}}
                      % exlstop still working on figuring out dcolumn
\hline\hline
                &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}\\
                &\multicolumn{1}{c}{Scandal}&\multicolumn{1}{c}{Departure Timing}&\multicolumn{1}{c}{Recency}&\multicolumn{1}{c}{Function}&\multicolumn{1}{c}{Seniority}\\
\hline
scandal.continuous&   -0.090\sym{***}&   -0.101\sym{**} &   -0.077         &   -0.082\sym{**} &   -0.131\sym{***}\\
                &  (0.021)         &  (0.032)         &  (0.044)         &  (0.023)         &  (0.034)         \\
departed.recent x scandal.continuous&                  &    0.026         &                  &                  &                  \\
                &                  &  (0.037)         &                  &                  &                  \\
scandal.recent x scandal.continuous&                  &                  &   -0.026         &                  &                  \\
                &                  &                  &  (0.060)         &                  &                  \\
finance         &                  &                  &                  &    0.000         &                  \\
                &                  &                  &                  &  (0.016)         &                  \\
finance x scandal.continuous&                  &                  &                  &   -0.153\sym{***}&                  \\
                &                  &                  &                  &  (0.028)         &                  \\
junior.placement&                  &                  &                  &                  &   -0.121\sym{***}\\
                &                  &                  &                  &      \            &  (0.028)         \\
junior.placement x scandal.continuous&                  &                  &                  &                  &    0.117\sym{**} \\
                &                  &                  &                  &                  &  (0.035)         \\
log(total.prior.comp)&    0.366\sym{***}&    0.366\sym{***}&    0.366\sym{***}&    0.385\sym{***}&    0.365\sym{***}\\
                &  (0.036)         &  (0.029)         &  (0.029)         &  (0.037)         &  (0.031)         \\
perform.comp    &    1.230\sym{***}&    1.230\sym{***}&    1.230\sym{***}&    1.246\sym{***}&    1.232\sym{***}\\
                &  (0.112)         &  (0.119)         &  (0.119)         &  (0.113)         &  (0.115)         \\
job.rank        &   -0.115\sym{***}&   -0.115\sym{***}&   -0.115\sym{***}&   -0.116\sym{***}&                  \\
                &  (0.014)         &  (0.021)         &  (0.021)         &  (0.012)         &                  \\
total.experience&    0.005\sym{**} &    0.005\sym{***}&    0.005\sym{***}&    0.005\sym{**} &    0.005\sym{***}\\
                &  (0.001)         &  (0.001)         &  (0.001)         &  (0.001)         &  (0.001)         \\
gender          &   -0.020         &   -0.020         &   -0.020         &   -0.032         &   -0.020         \\
                &  (0.021)         &  (0.018)         &  (0.018)         &  (0.019)         &  (0.018)         \\
mba             &    0.026         &    0.026         &    0.025         &    0.025         &    0.026         \\
                &  (0.023)         &  (0.028)         &  (0.028)         &  (0.025)         &  (0.026)         \\
ivy.league      &    0.071\sym{***}&    0.070\sym{**} &    0.071\sym{**} &    0.078\sym{***}&    0.077\sym{**} \\
                &  (0.011)         &  (0.021)         &  (0.021)         &  (0.013)         &  (0.022)         \\
highest.deg     &   -0.003         &   -0.003         &   -0.003         &   -0.000         &   -0.002         \\
                &  (0.015)         &  (0.020)         &  (0.020)         &  (0.016)         &  (0.019)         \\
size1           &   -0.025         &   -0.025         &   -0.025         &   -0.040         &   -0.024         \\
                &  (0.056)         &  (0.066)         &  (0.066)         &  (0.049)         &  (0.069)         \\
size2           &   -0.015         &   -0.014         &   -0.015         &   -0.042         &   -0.010         \\
                &  (0.067)         &  (0.064)         &  (0.064)         &  (0.057)         &  (0.065)         \\
size3           &    0.077         &    0.077         &    0.077         &    0.053         &    0.079         \\
                &  (0.056)         &  (0.049)         &  (0.048)         &  (0.047)         &  (0.051)         \\
size4           &    0.037         &    0.037         &    0.037         &    0.012         &    0.038         \\
                &  (0.065)         &  (0.050)         &  (0.050)         &  (0.055)         &  (0.052)         \\
size5           &    0.062         &    0.062         &    0.062         &    0.029         &    0.063         \\
                &  (0.073)         &  (0.058)         &  (0.057)         &  (0.062)         &  (0.060)         \\
public          &    0.041         &    0.041\sym{*}  &    0.040\sym{*}  &    0.034         &    0.039         \\
                &  (0.020)         &  (0.019)         &  (0.019)         &  (0.020)         &  (0.019)         \\
Constant        &    8.006\sym{***}&    8.006\sym{***}&    8.006\sym{***}&    7.828\sym{***}&    7.966\sym{***}\\
                &  (0.569)         &  (0.407)         &  (0.406)         &  (0.552)         &  (0.428)         \\
job.funct       & in model         & in model         & in model         &not in model         & in model         \\
industry        & in model         & in model         & in model         & in model         & in model         \\
region          & in model         & in model         & in model         & in model         & in model         \\
year            & in model         & in model         & in model         & in model         & in model         \\
\hline
Observations    &     1970         &     1970         &     1970         &     1970         &     1970         \\
\(R^{2}\)       &     0.66         &     0.66         &     0.66         &     0.65         &     0.66         \\
Adjusted \(R^{2}\)&    0.647         &    0.647         &    0.647         &    0.636         &    0.646         \\
\hline\hline
\multicolumn{6}{l}{\footnotesize Standard errors in parentheses}\\
\multicolumn{6}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular}
\end{table}


\end{document}

here

  • 2
    And why not just change the first column header to l instead of d{-1}? – AboAmmar Dec 27 '18 at 19:43
  • 2
    as @AboAmmar said, just change the first d{-1} to l – David Carlisle Dec 27 '18 at 22:18
0

Looking at the first two responses (thanks!), the first d{-1} is for the first column of numbers, not the variable names. So, changing the first one to "l" doesn't work. But I did try to add (prepend) the "l" column before the the first d{-1}, and this seemed to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.