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

Crash with fixef.rm = "singleton" #486

Open
marco-t3 opened this issue Apr 10, 2024 · 1 comment
Open

Crash with fixef.rm = "singleton" #486

marco-t3 opened this issue Apr 10, 2024 · 1 comment

Comments

@marco-t3
Copy link

marco-t3 commented Apr 10, 2024

Hi, I've found a small bug that (still?) causes R to crash with version 0.11.2 when using the argument fixef.rm = "singleton" with two LHS variables.

Here's a working example:

library(fixest)

set.seed(123)
data <- data.frame(x1 = rnorm(100),
                   y1 = rnorm(100),
                   y2 = c(NA, rnorm(99)),
                   id = rep(1:50, 2))

#Works
feols(y1 ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data,
      fixef.rm = "singleton")
#Works
feols(y2 ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data,
      fixef.rm = "singleton")
#Works
feols(c(y1, y2) ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data)
#Crashes
feols(c(y1, y2) ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data,
      fixef.rm = "singleton")

The code above causes a crash with the latest version of fixest and throws an error code with an older version.

Aside from this small issue, the package is being a really great tool to work with, thank you :)

@etiennebacher
Copy link

With the current github version, it no longer crashes (but still errors):

library(fixest)

set.seed(123)
data <- data.frame(x1 = rnorm(100),
                   y1 = rnorm(100),
                   y2 = c(NA, rnorm(99)),
                   id = rep(1:50, 2))

#Works
feols(y1 ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data,
      fixef.rm = "singleton")
#> OLS estimation, Dep. Var.: y1
#> Observations: 100
#> Fixed-effects: id: 50
#> Standard-errors: Clustered (id) 
#>    Estimate Std. Error  t value Pr(>|t|) 
#> x1 0.099256   0.135875 0.730491  0.46857 
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 0.68763     Adj. R2: -0.031984
#>                 Within R2:  0.008854
#Works
feols(y2 ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data,
      fixef.rm = "singleton")
#> NOTES: 1 observation removed because of NA values (LHS: 1).
#>        1 fixed-effect singleton was removed (1 observation, breakup: 1).
#> OLS estimation, Dep. Var.: y2
#> Observations: 98
#> Fixed-effects: id: 49
#> Standard-errors: Clustered (id) 
#>    Estimate Std. Error  t value Pr(>|t|) 
#> x1  0.11272   0.140264 0.803628  0.42557 
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 0.691846     Adj. R2: -0.078502
#>                  Within R2:  0.011393
#Works
feols(c(y1, y2) ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data)
#> Standard-errors: Clustered (id) 
#> Dep. var.: y1
#>    Estimate Std. Error  t value Pr(>|t|) 
#> x1 0.099256   0.135875 0.730491  0.46857 
#> ---
#> Dep. var.: y2
#>    Estimate Std. Error  t value Pr(>|t|) 
#> x1  0.11272   0.140227 0.803838  0.42537
#Crashes
feols(c(y1, y2) ~ x1 | id,
      vcov = ~ id,
      panel.id = ~ id,
      data = data,
      fixef.rm = "singleton")
#> Error in eval(expr, envir, enclos): Index out of bounds: [index=98; extent=98].

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