This function describes the style of Latex tables to be exported with the function etable
.
Usage
style.tex(
main = "base",
depvar.title,
model.title,
model.format,
line.top,
line.bottom,
var.title,
fixef.title,
fixef.prefix,
fixef.suffix,
fixef.where,
slopes.title,
slopes.format,
fixef_sizes.prefix,
fixef_sizes.suffix,
stats.title,
notes.intro,
notes.tpt.intro,
tablefoot,
tablefoot.value,
yesNo,
tabular = "normal",
depvar.style,
no_border,
caption.after,
rules_width,
signif.code,
tpt,
arraystretch,
adjustbox = NULL,
fontsize,
interaction.combine = " $\\times$ ",
i.equal = " $=$ "
)
Arguments
- main
Either "base", "aer" or "qje". Defines the basic style to start from. The styles "aer" and "qje" are almost identical and only differ on the top/bottom lines.
- depvar.title
A character scalar. The title of the line of the dependent variables (defaults to
"Dependent variable(s):"
ifmain = "base"
(the 's' appears only if just one variable) and to""
ifmain = "aer"
).- model.title
A character scalar. The title of the line of the models (defaults to
"Model:"
ifmain = "base"
and to""
ifmain = "aer"
).- model.format
A character scalar. The value to appear on top of each column. It defaults to
"(1)"
. Note that 1, i, I, a and A are special characters: if found, their values will be automatically incremented across columns.- line.top
A character scalar equal to
"simple"
,"double"
, or anything else. The line at the top of the table (defaults to"double"
ifmain = "base"
and to"simple"
ifmain = "aer"
)."simple"
is equivalent to"\\toprule"
, and"double"
to"\\tabularnewline \\midrule \\midrule"
.- line.bottom
A character scalar equal to
"simple"
,"double"
, or anything else. The line at the bottom of the table (defaults to"double"
ifmain = "base"
and to"simple"
ifmain = "aer"
)."simple"
is equivalent to"\\bottomrule"
, and"double"
to"\\midrule \\midrule & \\tabularnewline"
.- var.title
A character scalar. The title line appearing before the variables (defaults to
"\\midrule \\emph{Variables}"
ifmain = "base"
and to"\\midrule"
ifmain = "aer"
). Note that the behavior ofvar.title = " "
(a space) is different fromvar.title = ""
(the empty string): in the first case you will get an empty row, while in the second case you get no empty row. To get a line without an empty row, use"\\midrule"
(and not"\\midrule "
!--the space!).- fixef.title
A character scalar. The title line appearing before the fixed-effects (defaults to
"\\midrule \\emph{Fixed-effects}"
ifmain = "base"
and to" "
ifmain = "aer"
). Note that the behavior offixef.title = " "
(a space) is different fromfixef.title = ""
(the empty string): in the first case you will get an empty row, while in the second case you get no empty row. To get a line without an empty row, use"\\midrule"
(and not"\\midrule "
!--the space!).- fixef.prefix
A prefix to add to the fixed-effects names. Defaults to
""
(i.e. no prefix).- fixef.suffix
A suffix to add to the fixed-effects names. Defaults to
""
ifmain = "base"
) and to"fixed-effects"
ifmain = "aer"
).- fixef.where
Either "var" or "stats". Where to place the fixed-effects lines? Defaults to
"var"
, i.e. just after the variables, ifmain = "base"
) and to"stats"
, i.e. just after the statistics, ifmain = "aer"
).- slopes.title
A character scalar. The title line appearing before the variables with varying slopes (defaults to
"\\midrule \\emph{Varying Slopes}"
ifmain = "base"
and to""
ifmain = "aer"
). Note that the behavior ofslopes.title = " "
(a space) is different fromslopes.title = ""
(the empty string): in the first case you will get an empty row, while in the second case you get no empty row. To get a line without an empty row, use"\\midrule"
(and not"\\midrule "
!--the space!).- slopes.format
Character scalar representing the format of the slope variable name. There are two special characters: "var" and "slope", placeholers for the variable and slope names. Defaults to
"__var__ (__slope__)"
ifmain = "base"
) and to"__var__ $\\times $ __slope__"
ifmain = "aer"
).- fixef_sizes.prefix
A prefix to add to the fixed-effects names. Defaults to
"# "
.- fixef_sizes.suffix
A suffix to add to the fixed-effects names. Defaults to
""
(i.e. no suffix).- stats.title
A character scalar. The title line appearing before the statistics (defaults to
"\\midrule \\emph{Fit statistics"}
ifmain = "base"
and to" "
ifmain = "aer"
). Note that the behavior ofstats.title = " "
(a space) is different fromstats.title = ""
(the empty string): in the first case you will get an empty row, while in the second case you get no empty row. To get a line without an empty row, use"\\midrule"
(and not"\\midrule "
!--the space!).- notes.intro
A character scalar. Some tex code appearing just before the notes, defaults to
"\\par \\raggedright \n"
.- notes.tpt.intro
Character scalar. Only used if
tpt = TRUE
, it is some tex code that is passed before anythreeparttable
item (can be used for, typically, the font size). Default is the empty string.- tablefoot
A logical scalar. Whether or not to display a footer within the table. Defaults to
TRUE
ifmain = "base"
) andFALSE
ifmain = "aer"
).- tablefoot.value
A character scalar. The notes to be displayed in the footer. Defaults to
"default"
ifmain = "base"
, which leads to custom footers informing on the type of standard-error and significance codes, depending on the estimations.- yesNo
A character vector of length 1 or 2. Defaults to
"Yes"
ifmain = "base"
and to"$\\checkmark$"
ifmain = "aer"
(from packageamssymb
). This is the message displayed when a given fixed-effect is (or is not) included in a regression. IfyesNo
is of length 1, then the second element is the empty string.- tabular
(Tex only.) Character scalar equal to "normal" (default),
"*"
or"X"
. Represents the type of tabular environment to use: eithertabular
,tabular*
ortabularx
.- depvar.style
Character scalar equal to either
" "
(default),"*"
(italic),"**"
(bold),"***"
(italic-bold). How the name of the dependent variable should be displayed.- no_border
Logical, default is
FALSE
. Whether to remove any side border to the table (typically adds@\{\
to the sides of the tabular).- caption.after
Character scalar. Tex code that will be placed right after the caption. Defaults to
""
formain = "base"
and"\\medskip"
formain = "aer"
.- rules_width
Character vector of length 1 or 2. This vector gives the width of the
booktabs
rules: the first element the heavy-width, the second element the light-width. NA values mean no modification. If of length 1, only the heavy rules are modified. The width are in Latex units (ex:"0.1 em"
, etc).- signif.code
Named numeric vector, used to provide the significance codes with respect to the p-value of the coefficients. Default is
c("***"=0.01, "**"=0.05, "*"=0.10)
. To suppress the significance codes, usesignif.code=NA
orsignif.code=NULL
. Can also be equal to"letters"
, then the default becomesc("a"=0.01, "b"=0.05, "c"=0.10)
.- tpt
(Tex only.) Logical scalar, default is FALSE. Whether to use the
threeparttable
environment. If so, thenotes
will be integrated into thetablenotes
environment.- arraystretch
(Tex only.) A numeric scalar, default is
NULL
. If provided, the command\\renewcommand*{\\arraystretch{x}}
is inserted, replacingx
by the value ofarraystretch
. The changes are specific to the current table and do not affect the rest of the document.- adjustbox
(Tex only.) A logical, numeric or character scalar, default is
NULL
. If notNULL
, the table is inserted within theadjustbox
environment. By default the options arewidth = 1\\textwidth, center
(ifTRUE
). A numeric value changes the value before\\textwidth
. You can also add a character of the form"x tw"
or"x th"
withx
a number and where tw (th) stands for text-width (text-height). Finally any other character value is passed verbatim as anadjustbox
option.- fontsize
(Tex only.) A character scalar, default is
NULL
. Can be equal totiny
,scriptsize
,footnotesize
,small
,normalsize
,large
, orLarge
. The change affect the table only (and not the rest of the document).- interaction.combine
Character scalar, defaults to
" $\\times$ "
. When the estimation contains interactions, then the variables names (after aliasing) are combined with this argument. For example: ifdict = c(x1="Wind", x2="Rain")
and you have the following interactionx1:x2
, then it will be renamed (by default)Wind $\\times$ Rain
-- usinginteraction.combine = "*"
would lead toWind*Rain
.- i.equal
Character scalar, defaults to
" $=$ "
. Only affects factor variables created with the functioni
, tells how the variable should be linked to its value. For example if you have the Species factor from the iris data set, by default the display of the variable isSpecies $=$ Setosa
, etc. Ifi.equal = ": "
the display becomesSpecies: Setosa
.
Details
The \\checkmark
command, used in the "aer" style (in argument yesNo
), is in the
amssymb
package.
The commands \\toprule
, \\midrule
and \\bottomrule
are in the booktabs
package.
You can set the width of the top/bottom rules with \\setlength\\heavyrulewidth\{wd\}
,
and of the midrule with \\setlength\\lightrulewidth\{wd\}
.
Note that all titles (depvar.title
, depvar.title
, etc) are not escaped, so they
must be valid Latex expressions.
Examples
# Multiple estimations => see details in feols
aq = airquality
est = feols(c(Ozone, Solar.R) ~
Wind + csw(Temp, Temp^2, Temp^3) | Month + Day,
data = aq)
# Playing a bit with the styles
etable(est, tex = TRUE)
#> \begingroup
#> \centering
#> \begin{tabular}{lcccccc}
#> \tabularnewline \midrule \midrule
#> Dependent Variables: & \multicolumn{3}{c}{Ozone} & \multicolumn{3}{c}{Solar.R}\\
#> Model: & (1) & (2) & (3) & (4) & (5) & (6)\\
#> \midrule
#> \emph{Variables}\\
#> Wind & -2.693$^{**}$ & -2.630$^{**}$ & -2.850$^{**}$ & 3.031 & 3.181 & 3.943\\
#> & (0.8549) & (0.8632) & (0.8235) & (1.840) & (1.921) & (2.466)\\
#> Temp & 2.373$^{***}$ & -4.009 & -63.53$^{*}$ & 4.787$^{*}$ & 17.80$^{*}$ & 234.4\\
#> & (0.2334) & (3.422) & (27.70) & (2.086) & (7.057) & (152.4)\\
#> Temp square & & 0.0407 & 0.8215$^{*}$ & & -0.0824 & -2.933\\
#> & & (0.0213) & (0.3757) & & (0.0443) & (1.969)\\
#> Temp cube & & & -0.0034 & & & 0.0124\\
#> & & & (0.0017) & & & (0.0084)\\
#> \midrule
#> \emph{Fixed-effects}\\
#> Month & Yes & Yes & Yes & Yes & Yes & Yes\\
#> Day & Yes & Yes & Yes & Yes & Yes & Yes\\
#> \midrule
#> \emph{Fit statistics}\\
#> Observations & 116 & 116 & 116 & 146 & 146 & 146\\
#> R$^2$ & 0.78671 & 0.79718 & 0.80469 & 0.30641 & 0.31252 & 0.32651\\
#> Within R$^2$ & 0.55271 & 0.57466 & 0.59040 & 0.08937 & 0.09740 & 0.11577\\
#> \midrule \midrule
#> \multicolumn{7}{l}{\emph{Clustered (Month) standard-errors in parentheses}}\\
#> \multicolumn{7}{l}{\emph{Signif. Codes: ***: 0.01, **: 0.05, *: 0.1}}\\
#> \end{tabular}
#> \par\endgroup
etable(est, tex = TRUE, style.tex = style.tex("aer"))
#> \begingroup
#> \centering
#> \begin{tabular}{lcccccc}
#> \toprule
#> & \multicolumn{3}{c}{Ozone} & \multicolumn{3}{c}{Solar.R}\\
#> & (1) & (2) & (3) & (4) & (5) & (6)\\
#> \midrule
#> Wind & -2.693$^{**}$ & -2.630$^{**}$ & -2.850$^{**}$ & 3.031 & 3.181 & 3.943\\
#> & (0.8549) & (0.8632) & (0.8235) & (1.840) & (1.921) & (2.466)\\
#> Temp & 2.373$^{***}$ & -4.009 & -63.53$^{*}$ & 4.787$^{*}$ & 17.80$^{*}$ & 234.4\\
#> & (0.2334) & (3.422) & (27.70) & (2.086) & (7.057) & (152.4)\\
#> Temp square & & 0.0407 & 0.8215$^{*}$ & & -0.0824 & -2.933\\
#> & & (0.0213) & (0.3757) & & (0.0443) & (1.969)\\
#> Temp cube & & & -0.0034 & & & 0.0124\\
#> & & & (0.0017) & & & (0.0084)\\
#> \\
#> Observations & 116 & 116 & 116 & 146 & 146 & 146\\
#> R$^2$ & 0.78671 & 0.79718 & 0.80469 & 0.30641 & 0.31252 & 0.32651\\
#> Within R$^2$ & 0.55271 & 0.57466 & 0.59040 & 0.08937 & 0.09740 & 0.11577\\
#> \\
#> Month fixed effects & $\checkmark$ & $\checkmark$ & $\checkmark$ & $\checkmark$ & $\checkmark$ & $\checkmark$\\
#> Day fixed effects & $\checkmark$ & $\checkmark$ & $\checkmark$ & $\checkmark$ & $\checkmark$ & $\checkmark$\\
#> \bottomrule
#> \end{tabular}
#> \par\endgroup
etable(est, tex = TRUE, style.tex = style.tex("aer",
var.title = "\\emph{Expl. Vars.}",
model.format = "[i]",
yesNo = "x",
tabular = "*"))
#> \begingroup
#> \centering
#> \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccccc}
#> \toprule
#> & \multicolumn{3}{c}{Ozone} & \multicolumn{3}{c}{Solar.R}\\
#> & [i] & [ii] & [iii] & [iv] & [v] & [vi]\\
#> \emph{Expl. Vars.}\\
#> Wind & -2.693$^{**}$ & -2.630$^{**}$ & -2.850$^{**}$ & 3.031 & 3.181 & 3.943\\
#> & (0.8549) & (0.8632) & (0.8235) & (1.840) & (1.921) & (2.466)\\
#> Temp & 2.373$^{***}$ & -4.009 & -63.53$^{*}$ & 4.787$^{*}$ & 17.80$^{*}$ & 234.4\\
#> & (0.2334) & (3.422) & (27.70) & (2.086) & (7.057) & (152.4)\\
#> Temp square & & 0.0407 & 0.8215$^{*}$ & & -0.0824 & -2.933\\
#> & & (0.0213) & (0.3757) & & (0.0443) & (1.969)\\
#> Temp cube & & & -0.0034 & & & 0.0124\\
#> & & & (0.0017) & & & (0.0084)\\
#> \\
#> Observations & 116 & 116 & 116 & 146 & 146 & 146\\
#> R$^2$ & 0.78671 & 0.79718 & 0.80469 & 0.30641 & 0.31252 & 0.32651\\
#> Within R$^2$ & 0.55271 & 0.57466 & 0.59040 & 0.08937 & 0.09740 & 0.11577\\
#> \\
#> Month fixed effects & x & x & x & x & x & x\\
#> Day fixed effects & x & x & x & x & x & x\\
#> \bottomrule
#> \end{tabular*}
#> \par\endgroup