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

lfe-tidier: add argument robust to tidy #772

Closed
kuriwaki opened this issue Oct 21, 2019 · 0 comments
Closed

lfe-tidier: add argument robust to tidy #772

kuriwaki opened this issue Oct 21, 2019 · 0 comments

Comments

@kuriwaki
Copy link
Contributor

@kuriwaki kuriwaki commented Oct 21, 2019

lfe::felm objects can be printed showing robust/cluster SEs in the lfe:::summary.felm with the robust = TRUE option, but currently tidy.felm does not have that option. Could it be added as an argument so it simply passes through?

I've tested it on a fork that I can PR (https://github.com/kuriwaki/broom).

library(lfe)
#> Loading required package: Matrix
library(broom)

# example from lfe::felm help page -----
x <- rnorm(1000)
x2 <- rnorm(length(x))

## individual and firm
id <- factor(sample(20,length(x),replace=TRUE))
firm <- factor(sample(13,length(x),replace=TRUE))

## effects for them
id.eff <- rnorm(nlevels(id))
firm.eff <- rnorm(nlevels(firm))

## left hand side
u <- rnorm(length(x))
y <- x + 0.5*x2 + id.eff[id] + firm.eff[firm] + u

## estimate and print result
est1 <- felm(y ~ x+x2 | id + firm)  # no clusters
est2 <- felm(y ~ x+x2 | id + firm | 0 | id + firm) # cluster SEs


# PROPOSED behavior----
# different SEs depending on the robust option
tidy(est1, robust = FALSE)
#> # A tibble: 2 x 5
#>   term  estimate std.error statistic   p.value
#>   <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 x        1.00     0.0332      30.2 8.60e-142
#> 2 x2       0.525    0.0324      16.2 2.01e- 52
tidy(est1, robust = TRUE)
#> # A tibble: 2 x 5
#>   term  estimate std.error statistic   p.value
#>   <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 x        1.00     0.0329      30.5 8.87e-144
#> 2 x2       0.525    0.0325      16.1 4.94e- 52

# robust = TRUE turns on cluster SEs when those are specified
tidy(est2, robust = FALSE)
#> # A tibble: 2 x 5
#>   term  estimate std.error statistic   p.value
#>   <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 x        1.00     0.0332      30.2 8.60e-142
#> 2 x2       0.525    0.0324      16.2 2.01e- 52
tidy(est2, robust = TRUE)
#> # A tibble: 2 x 5
#>   term  estimate std.error statistic   p.value
#>   <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 x        1.00     0.0292      34.3 1.74e-169
#> 2 x2       0.525    0.0377      13.9 3.21e- 40

Created on 2019-10-21 by the reprex package (v0.3.0)

alexpghayes added a commit that referenced this issue Dec 13, 2019
* Add robust option to tidy.felm, to be passed to lfe::summary.felm

* use a042ea3 with multiple response options case as well

* tests for tidy.lfe robust = TRUE

* update news and contributor for #772, updated in PR #781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.