Code Monkey home page Code Monkey logo

Comments (3)

lrberge avatar lrberge commented on August 18, 2024

Thanks for reporting. This bug is now fixed.

from fixest.

tlcaputi avatar tlcaputi commented on August 18, 2024

Don't mean to bother you. Just wanted to let you know: something in your fix seems to make it impossible to define the bins list outside of the regression.

library(fixest)

# Create a sample dataset
xx = (-7):7
yy = rep(c(0:1), each=length(xx))
d = data.frame(xx=rep(xx, times=2), yy = yy, dv = runif(length(yy)))

# Define categories
bin_categories = list("<=-5" = ~x <= -5, ">=5" = ~x >= 5)

# This doesn't work:
feols(dv ~ i(xx, yy, ref = -1, bin = bin_categories), data = d) 

Error message:

Error in feols(dv ~ i(xx, yy, ref = -1, bin = bin_categories), data = d) : 
  The variable 'bin_categories' is in the RHS of the formula but not in the data set.

Of course, a user can just define the list in the regression and then it works fine.

Thanks so much for the original fix and for this absolutely incredible package!

from fixest.

lrberge avatar lrberge commented on August 18, 2024

For the record, the fact that one cannot use variables from the global environment is on purpose (it improves quality control and avoids many problems). One can only use scalars from the global environment, which are then hard coded in the formula.

I guess you know it, but in your case you could use d$xxx = bin(d$xx, bin_categories) to bin the variable ex ante and avoid doing it at run time:

d$xxx = bin(d$xx, bin_categories)
feols(dv ~ i(xxx, yy, ref = -1), data = d) 
#> OLS estimation, Dep. Var.: dv
#> Observations: 30 
#> Standard-errors: IID 
#>               Estimate Std. Error   t value   Pr(>|t|)    
#> (Intercept)   0.544425   0.072238  7.536598 4.0189e-07 ***
#> xxx::<=-5:yy  0.100750   0.181794  0.554201 5.8591e-01    
#> xxx::-4:yy   -0.384185   0.297843 -1.289892 2.1257e-01    
#> xxx::-3:yy   -0.144298   0.297843 -0.484477 6.3359e-01    
#> xxx::-2:yy   -0.520490   0.297843 -1.747533 9.6688e-02 .  
#> xxx::0:yy    -0.266031   0.297843 -0.893193 3.8293e-01    
#> xxx::1:yy    -0.077570   0.297843 -0.260438 7.9733e-01    
#> xxx::2:yy     0.085091   0.297843  0.285692 7.7821e-01    
#> xxx::3:yy     0.348274   0.297843  1.169320 2.5674e-01    
#> xxx::4:yy     0.327161   0.297843  1.098434 2.8574e-01    
#> xxx::>=5:yy   0.164174   0.181794  0.903078 3.7779e-01    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 0.229953   Adj. R2: 0.011107

Thanks so much for the original fix and for this absolutely incredible package!

Thanks a lot! :-)

from fixest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.