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

Suggestion: make fixef.rm = 'both' the default #496

Open
statzhero opened this issue May 7, 2024 · 0 comments
Open

Suggestion: make fixef.rm = 'both' the default #496

statzhero opened this issue May 7, 2024 · 0 comments

Comments

@statzhero
Copy link

I saw this other issue on singletons where the suggestion is to replicate Stata's reghdfe recursive singleton deletion.

As I understand it, there are good reasons to remove singletons by default. For example, see the justification why reghdfe's default is to remove them here: https://scorreia.com/research/singletons.pdf

Below is an example of what can happen to the standard errors and R2. (The difference in the example is small, though.)

library(dplyr)
library(fixest)

set.seed(56)

n <- 1000

# Create a data frame with multiple columns
df <- tibble(
  id = c(rep(1:500, each = 1), rep(501:600, each = 5)),
  x1 = rnorm(n),
  error = rnorm(n, mean = 0, sd = 1)
)

beta_1 <- 1  

df <- df |>
  mutate(y = beta_1 * x1 + error)

est <- feols(y ~ x1 | id, df)
est_sing <- feols(y ~ x1 | id, df, fixef.rm = 'both')
#NOTE: 500 fixed-effect singleton was removed (500 observations, breakup: 500).

etable(est, est_sing)
#                               est           est_sing
#Dependent Var.:                  y                  y
#                                                     
#x1              0.9065*** (0.0489) 0.9065*** (0.0491)
#Fixed-Effects:  ------------------ ------------------
#id                             Yes                Yes
#_______________ __________________ __________________
#S.E.: Clustered             by: id             by: id
#Observations                 1,000                500
#R2                         0.78738            0.57945
#Within R2                  0.47242            0.47242
#---
#Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
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

1 participant