Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get esttex to respect common dict aliases #12

Closed
grantmcdermott opened this issue Dec 29, 2019 · 2 comments
Closed

Get esttex to respect common dict aliases #12

grantmcdermott opened this issue Dec 29, 2019 · 2 comments

Comments

@grantmcdermott
Copy link
Contributor

grantmcdermott commented Dec 29, 2019

As promised, a second esttex issue...

Is it possible for esttex output to respect common (i.e. unique) dictionary aliases?

I often want to output similar variables on the same row in a regression table. For instance, to make them immediately comparable even if they are named differently in my actual R model calls. The way this works for other regression outputting packages in R (e.g. huxtable or stargazer) is to give them the same alias. However, that strategy does not appear to work here.

Consider the following example, where I want to compare full vs partial marginal effects, using different model syntax. The coefficient on Wind in mod_2 is actually the same as Month5:Wind in mod_1. Yet, even if I explicitly give it the same alias, the two coefficients are still printed on separate rows.

library(fixest)

aq = airquality
aq$Month = factor(aq$Month)

## Full marginal effects
mod_1 = feols(Ozone ~ Month / Wind, data = aq)
#> NOTE: 37 observations removed because of NA values (Breakup: LHS: 37, RHS: 0).

## Partial marginal effects
mod_2 = feols(Ozone ~ Month * Wind, data = aq)
#> NOTE: 37 observations removed because of NA values (Breakup: LHS: 37, RHS: 0).

## "Wind" in mod_2 is actual "Month5:Wind"...
myDict = c("Wind" = "Month5:Wind")

## Doesn't work as expected: Get separate "Month5:Wind" rows instead of one.
esttex(
  mod_1, mod_2, titles  = c("Full MEs", "Partial MEs"),
  dict = myDict,
  drop = c("Int", paste0("Month", 6:9)) ## Optional: Just to highlight rows of interest 
)
#> \begin{table}[htbp]\centering
#> \caption{no title}
#> \begin{tabular}{lcc}
#>  & & \tabularnewline
#> \hline
#> \hline
#> Dependent Variable:&\multicolumn{2}{c}{Ozone}\\
#> Model:&(1)&(2)\\
#> \hline
#> \emph{Variables}\tabularnewline
#> Month5:Wind&-2.3681$^{*}$&  \\
#>   &(1.3162)&  \\
#> Month5:Wind&  &-2.3681$^{*}$\\
#>   &  &(1.3162)\\
#> \hline
#> \emph{Fit statistics}&  & \\
#> Observations& 116&116\\
#> R$^2$ & 0.54732&0.54732\\
#> Adjusted R$^2$ & 0.50889&0.50889\\
#> \hline
#> \hline
#> \multicolumn{3}{l}{\emph{Normal standard-errors in parentheses. Signif Codes: ***: 0.01, **: 0.05, *: 0.1}}\\
#> \end{tabular}
#> \end{table}

Created on 2019-12-29 by the reprex package (v0.3.0)

@lrberge
Copy link
Owner

lrberge commented Jan 4, 2020

Hi again,

The issue you mention is a big problem indeed--the output is really not appropriate. I'll correct it next week.

Thanks for raising it!

lrberge added a commit that referenced this issue Jan 18, 2020
Changes include:
 - new function etable
 - update of esttable and esttex
 - minor improvements in arguments handling
 - update of help pages

Fixes: #11 and #12
@lrberge
Copy link
Owner

lrberge commented Jan 21, 2020

I'm closing it, I've updated the package accordingly.

@lrberge lrberge closed this as completed Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants