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

Strange group columns with subset and data.table in feols() #591

Closed
adamaltmejd opened this issue Dec 27, 2022 · 1 comment
Closed

Strange group columns with subset and data.table in feols() #591

adamaltmejd opened this issue Dec 27, 2022 · 1 comment

Comments

@adamaltmejd
Copy link

adamaltmejd commented Dec 27, 2022

No idea whats going on here....

> modelsummary(feols(c(mpg, disp) ~ hp + drat + qsec, data = mtcars, subset = mtcars$gear > 3), output = "markdown")


|            |   mpg    |   disp    |
|:-----------|:--------:|:---------:|
|(Intercept) |  19.649  | -123.965  |
|            | (23.205) | (205.069) |
|hp          |  -0.053  |   1.021   |
|            | (0.022)  |  (0.195)  |
|drat        |  3.263   |  20.100   |
|            | (3.535)  | (31.242)  |
|qsec        |  -0.152  |   3.705   |
|            | (0.717)  |  (6.334)  |
|Num.Obs.    |    17    |    17     |
|R2          |  0.566   |   0.810   |
|R2 Adj.     |  0.466   |   0.766   |
|AIC         |  100.1   |   174.2   |
|BIC         |  103.5   |   177.6   |
|RMSE        |   3.64   |   32.14   |
|Std.Errors  |   IID    |    IID    |

> modelsummary(feols(c(mpg, disp) ~ hp + drat + qsec, data = dt, subset = dt[, gear > 3]), output = "markdown")


|            | group.x |   mpg    | group.y |   disp    |
|:-----------|:-------:|:--------:|:-------:|:---------:|
|(Intercept) |         |  19.649  |         | -123.965  |
|            |         | (23.205) |         | (205.069) |
|hp          |         |  -0.053  |         |   1.021   |
|            |         | (0.022)  |         |  (0.195)  |
|drat        |         |  3.263   |         |  20.100   |
|            |         | (3.535)  |         | (31.242)  |
|qsec        |         |  -0.152  |         |   3.705   |
|            |         | (0.717)  |         |  (6.334)  |
|Num.Obs.    |         |    17    |         |    17     |
|R2          |         |  0.566   |         |   0.810   |
|R2 Adj.     |         |  0.466   |         |   0.766   |
|AIC         |         |  100.1   |         |   174.2   |
|BIC         |         |  103.5   |         |   177.6   |
|RMSE        |         |   3.64   |         |   32.14   |
|Std.Errors  |         |   IID    |         |    IID    |

Especially since

> identical(mtcars$gear > 3, dt[, gear > 3])
[1] TRUE

Maybe its a fixest bug because:

> identical(
          feols(c(mpg, disp) ~ hp + drat + qsec, data = mtcars, subset = mtcars$gear > 3),
          feols(c(mpg, disp) ~ hp + drat + qsec, data = dt, subset = dt[, gear > 3])
      )
[1] FALSE
``
vincentarelbundock added a commit that referenced this issue Dec 28, 2022
@vincentarelbundock
Copy link
Owner

Thanks a lot for the useful report. This should now be fixed on Github.

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