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

Error in feols with 'subset' and 'fixef' parameters #503

Open
MaelAstruc opened this issue Jun 3, 2024 · 0 comments
Open

Error in feols with 'subset' and 'fixef' parameters #503

MaelAstruc opened this issue Jun 3, 2024 · 0 comments

Comments

@MaelAstruc
Copy link
Contributor

Hello,

I have encountered a bug while trying some subset analyses.

Here is a reproducible example:

N <- 10000
periods <- 10
indivs <- N/periods
countries <- 100

df <- data.frame(
  id = rep(1:indivs, each = periods),
  year = rep(1:periods, times = indivs),
  country = floor(runif(N, 0, countries + 1))
)

df <- df |>
  dplyr::group_by(id) |>
  dplyr::mutate(indiv_FE = runif(1) * 10) |>
  dplyr::group_by(year) |>
  dplyr::mutate(year_FE = runif(1) * 10) |>
  dplyr::group_by(country) |>
  dplyr::mutate(country_FE = runif(1) * 10) |>
  dplyr::ungroup() |>
  dplyr::mutate(
    e = rnorm(N),
    x = runif(N) + indiv_FE + year_FE + country_FE,
    y = 1 + 2 * x + indiv_FE + year_FE + country_FE + e
  )

fixest::feols(y ~ x, data = df)
fixest::feols(y ~ x, data = df, fixef = c("id", "year", "country"))
fixest::feols(y ~ x, data = df, subset = ~country > 50)
fixest::feols(y ~ x, data = df, subset = df$country > 50)
fixest::feols(y ~ x, data = df, subset = ~country > 50, fixef = c("id", "year", "country"))
fixest::feols(y ~ x, data = df, subset = df$country > 50, fixef = c("id", "year", "country"))

The last two give this error:

# Error in eval(all_vars_call, data) : objet 'id' introuvable
# Erreur dans fixest::feols(y ~ x, data = df, subset = ~country > 50, fixef = c("id",  : 
#   Error in res[[2]] : indice hors limites
# This error was unforeseen by the author of the function feols. If you think your call to the function is legitimate, could you report?
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