# NOT RUN {
aq = airquality
aq$Month = factor(aq$Month)
est1 = feols(Ozone ~ Month / Wind + Temp, data = aq)
est2 = feols(Ozone ~ Wind + Temp | Month, data = aq)
# Displaying the two results in a single table
etable(est1, est2)
# keep/drop: keeping only interactions
etable(est1, est2, keep = ":")
# or using drop (see regexp help):
etable(est1, est2, drop = "^[[:alnum:]]+$")
# keep/drop: dropping interactions
etable(est1, est2, drop = ":")
# or using keep ("!" reverses the effect):
etable(est1, est2, keep = "!:")
# order: Wind variable first, intercept last
etable(est1, est2, order = c("Wind", "Month"))
etable(est1, est2, order = c("^Wind", "Wind", "Month"))
# Interactions, then Intercept, last ("!" reverses the effect)
etable(est1, est2, order = c("!Int", "!:"))
# dict + keep/drop/order: using "%" to match the original names
dict = c("Month5"="May", "Month6"="Jun", "Month7"="Jul",
"Month8"="Aug", "Month9"="Sep")
etable(est1, est2, tex = TRUE, dict = dict)
# keeping only June and July
etable(est1, est2, tex = TRUE, dict = dict, keep = c("%Month6", "Jul"))
# All months variabes first
etable(est1, est2, tex = TRUE, dict = dict, order = c("%Month"))
# signifCode
etable(est1, est2, signifCode = c(" A"=0.01, " B"=0.05, " C"=0.1,
" D"=0.15, " F"=1))
# fitstat
etable(est1, est2, fitstat = ~r2+ar2+apr2+war2)
# Adding a dictionnary (Tex only)
dict = c(Month5="May", Month6="Jun", Month7="Jul", Month8="Aug", Month9="Sep")
etable(est1, est2, dict = dict, tex = TRUE)
#
# Using the argument style to customize Latex exports
#
# If you don't like the default layout of the table, no worries!
# You can modify many parameters with the argument style
# To drop the headers before each section, use:
style_noHeaders = list(var="", fixef="suffix: FE", stats = "")
etable(est1, est2, dict = dict, tex = TRUE, style = style_noHeaders)
# To change the lines of the table
style_lines = list(lines = "top:\\toprule;bottom:\\bottomrule;sep:\\midrule;foot:\\midrule")
etable(est1, est2, dict = dict, tex = TRUE, style = style_lines)
#
# Group and extraline
#
# Sometimes it's useful to group control variables into a single line
# You can achieve that with the group argument
setFixest_fml(..ctrl = ~ poly(Wind, 2) + poly(Temp, 2))
est_c0 = feols(Ozone ~ Solar.R, data = aq)
est_c1 = feols(Ozone ~ Solar.R + ..ctrl, data = aq)
est_c2 = feols(Ozone ~ Solar.R + I(Solar.R**2) + ..ctrl, data = aq)
etable(est_c0, est_c1, est_c2, group = list(Controls = "poly"))
# 'group' here does the same as drop = "poly", but adds an extra line
# with TRUE/FALSE where the variables were found
# 'extraline' adds an extra line, where you can add the value for each model
est_all = feols(Ozone ~ Solar.R + Temp + Wind, data = aq)
est_sub1 = feols(Ozone ~ Solar.R + Temp + Wind, data = aq[aq$Month %in% 5:6, ])
est_sub2 = feols(Ozone ~ Solar.R + Temp + Wind, data = aq[aq$Month %in% 7:8, ])
est_sub3 = feols(Ozone ~ Solar.R + Temp + Wind, data = aq[aq$Month == 9, ])
etable(est_all, est_sub1, est_sub2, est_sub3,
extraline = list("Sub-sample" = c("All", "May-June", "Jul.-Aug.", "Sept.")))
# When exporting to Latex, you can add meta arguments to 'group' and 'extraline'
# Two keywords are allowed: 'title' and 'where'
# 'title' adds a line just before with the content of 'title' in the leftmost cell
# 'where' governs the location of the line. It can be equal to 'var', 'stats' or 'fixef'.
# The syntax is: {title:Controls; where:stats}Group name.
# Note that starting with curly braces is mandatory.
# Examples
etable(est_c0, est_c1, est_c2, tex = TRUE, group = list("{where:stats}Controls" = "poly"))
etable(est_all, est_sub1, est_sub2, est_sub3, tex = TRUE,
extraline = list("{title:\\midrule}Sub-sample" =
c("All", "May-June", "Jul.-Aug.", "Sept.")))
# }
Run the code above in your browser using DataLab