fixest icon indicating copy to clipboard operation
fixest copied to clipboard

sw() error

Open shoonlee opened this issue 1 year ago • 0 comments

Hi,

It seems that the sw() feature has an error in selecting observations. Below is a reproducible example. Here, the the coeffieicent for x1 can be estimated (x2 cannot be estimated) but including sw throws an error and does not report the x1 coefficient. Please let me know if more information is needed. Thank you!

df <- data.frame(y = c(1:3, NA, NA),
                 x1 = c(rnorm(5)),
                 x2 = c(0, 0, 0, 1, 2))

> etable(feols(y ~ x1 + x2, df))
NOTE: 2 observations removed because of NA values (LHS: 2).
                feols(y ~ x1 +..
Dependent Var.:                y
                                
Constant          2.893 (0.8312)
x1              -0.8761 (0.6583)
_______________ ________________
S.E. type                    IID
Observations                   3
R2                       0.63915
Adj. R2                  0.27830
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> 


> etable(feols(y ~ x1 + sw(1, x2),df))
NOTE: 2 observations removed because of NA values (LHS: 2).
      |-> this msg only concerns the variables common to all estimations
Error: in etable(feols(y ~ x1 + sw(1, x2), df)):
 Some elements in '...' could not be evaluated: 
  In feols(y ~ x1 + sw(1, x2), df): Error in select_obs(rhs_sw, -obs2remove, nthreads) : 
  After removing NAs (or perfect fit fixed-effects), not a single explanatory variable is different from 0.
This error was unforeseen by the author of the function feols. If you think your call to the function is legitimate, could you report?

shoonlee avatar Apr 03 '24 16:04 shoonlee