Search code examples
matrixlatexstata

Eliminate matrix header in esttab (latex) or outtable output


I have a matrix of values (very non-standard summary statistics) that I want to pass from Stata to LaTeX. The command:

esttab matrix(matname) using $myfilename.tex, replace booktabs f

gives the matrix in LaTeX form but also gives the title of the matrix within the fragment. The same is true for:

outtable using myfilename, mat(matname) replace nobox

Currently, every time I rerun my Stata do file I have to go and edit myfilename.tex by hand.

Is there any way to non-manually remove the matrix name from the Stata to LaTeX output?

I tried using the option noheader, which works here:

matrix list matname, noheader 

but doesn't seem to be active in esttab or outtable. It also occurred to me that if I could find a way to ask LaTex to just \input PART of the fragment file (lines 2 onward) that would work...


Solution

  • I think the nomtitles option will work. Here's reproducible example:

    sysuse auto
    reg price trunk headroom
    matrix myMat = e(V)
    
    esttab matrix(myMat) using temp.tex, replace booktabs f nomtitles
    

    This produces the text (.tex) file below:

                &       trunk&    headroom&       \_cons\\
    \midrule
    trunk       &    10557.96&   -35339.31&   -39464.18\\
    headroom    &   -35339.31&    269901.5&   -321726.7\\
    \_cons      &   -39464.18&   -321726.7&     1612951\\
    

    Also, I used the following outtable command

    outtable using "./temp", mat(myMat) replace center f(%9.2f) nobox
    

    to produce this output:

    % matrix: myMat file: ./temp.tex  10 Jun 2016 12:55:35
    \begin{table}[htbp]
    \begin{tabular}{lccc} \hline \hline
     & trunk  & headroom  & cons  \\  \hline 
    trunk &  10557.96 \\  
    headroom & -35339.31 & 269901.52 \\  
    cons & -39464.18 & -3.22e+05 &  1.61e+06 \\  
    \hline \hline \end{tabular}
    \end{table}
    

    While the matrix name is present in the output, it is commented out and so will not appear in the latex document.