lrberge / fixest

Fixed-effects estimations
https://lrberge.github.io/fixest/
361 stars 59 forks source link

fixest 0.12 has broken etable and sunab #491

Closed morganwkelly closed 2 months ago

morganwkelly commented 2 months ago

R version 4.1.2 on ubuntu 22.04

Running vignette example.

data("base_stagg") res_sunab = feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg)

Error in feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg) : Evaluation of the right-hand-side of the formula raises an error: in string_magic_internal(..., .delim = .delim, .envi...: string_magic requires at least one character scalar to work. Named arguments are only used as variables on which to apply interpolation. FIX: please provide at least one non-named argument.

################################################################ Also etable without sunab

res_basic = feols(y ~ x1 | id + year, base_stagg) etable(res_basic) Error: in string_magic_internal(..., .delim = .delim, .envi...: string_magic requires at least one character scalar to work. Named arguments are only used as variables on which to apply interpolation. FIX: please provide at least one non-named argument.

lrberge commented 2 months ago

Hi, can you re-run with setDreamerr_show_stack(TRUE)? Hopefully it will be informative.

library(dreamerr) ; library(fixest)
setDreamerr_show_stack(TRUE)
data("base_stagg")
res_sunab = feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg)

res_basic = feols(y ~ x1 | id + year, base_stagg)
etable(res_basic)
morganwkelly commented 2 months ago

Hi Laurent

the error has to do with C stack usage and is below.

There is a separate issue that I have been meaning to contact you about which is F tests with a very low number of clusters. I have been doing a lot of work with Tim Conley on standard errors for spatial data. Basically Conley SEs are useless when the data are strongly autocorrelated as is usually the case in economics.

You can get reliable answers however by Bester-Conley-Hansen large clusters where observations are assigned to (usually) four clusters by k-medoids clustering. Standard feols estimation works fine there obviously but the difficulty comes when you try to run Wald tests on multiple coefficients. Monte Carlos show the estimates to be wildly unreliable.

In Clubsandwich they use a Satterthwaite approximation in the denominator of the F statistic which gives far more reliable estimates. https://jepusto.github.io/clubSandwich/articles/Wald-tests-in-clubSandwich.html

Anyhow, as I am sure everyone says to you, fixest is the most extraordinary package and thank you for creating it.

The output is below

best

Morgan

res_sunab = feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg)Error in feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg) : Error : C stack usage 7976244 is too close to the limit This error was unforeseen by the author of the function feols. If you think your call to the function is legitimate, could you report?> res_basic = feols(y ~ x1 | id + year, base_stagg)> etable(res_basic)Error: C stack usage 7969732 is too close to the limit

On Fri, 26 Apr 2024 at 12:10, Laurent Bergé @.***> wrote:

Hi, can you re-run with setDreamerr_show_stack(TRUE)? Hopefully it will be informative.

library(dreamerr) ; library(fixest) setDreamerr_show_stack(TRUE) data("base_stagg")res_sunab = feols(y ~ x1 + sunab(year_treated, year) | id + year, base_stagg) res_basic = feols(y ~ x1 | id + year, base_stagg) etable(res_basic)

— Reply to this email directly, view it on GitHub https://github.com/lrberge/fixest/issues/491#issuecomment-2079179200, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOXXIWGBQ3HEG2DHF4I6QADY7IY3VAVCNFSM6AAAAABG2QUNV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZZGE3TSMRQGA . You are receiving this because you authored the thread.Message ID: @.***>

-- Professor Morgan Kelly School of Economics University College Dublin Dublin 4, Ireland

lrberge commented 2 months ago

Hi Morgan and thanks for the kind words!

Thanks for the suggestion! I'll open a feature request.

On the output, unfortunately I can't really figure out what's going on. I'll install ubuntu+R 4.1.2 to try to reproduce the bug. Sorry for the inconvenience!

morganwkelly commented 2 months ago

Hi Laurent

No problem: I downgraded back immediately to the previous version.

Keep up the good work

Morgan

On Mon, 29 Apr 2024 at 14:14, Laurent Bergé @.***> wrote:

Hi Morgan and thanks for the kind words!

Thanks for the suggestion! I'll open a feature request.

On the output, unfortunately I can't really figure out what's going on. I'll install ubuntu+R 4.1.2 to try to reproduce the bug. Sorry for the inconvenience!

— Reply to this email directly, view it on GitHub https://github.com/lrberge/fixest/issues/491#issuecomment-2082712368, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOXXIWE4A6PFNDMP3SD4RK3Y7ZBTZAVCNFSM6AAAAABG2QUNV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBSG4YTEMZWHA . You are receiving this because you authored the thread.Message ID: @.***>

-- Professor Morgan Kelly School of Economics University College Dublin Dublin 4, Ireland

lrberge commented 2 months ago

FYI the problem is solved in #494 It was due to a peculiarity introduced in R v4.1.0 and removed in v4.1.3 Thanks for reporting!

morganwkelly commented 2 months ago

Well done Laurent!

On Tue, 30 Apr 2024 at 12:25, Laurent Bergé @.***> wrote:

FYI the problem is solved in #494 https://github.com/lrberge/fixest/issues/494 It was due to a peculiarity introduced in R v4.1.0 and removed in v4.3.0. Thanks for reporting!

— Reply to this email directly, view it on GitHub https://github.com/lrberge/fixest/issues/491#issuecomment-2085038532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOXXIWBZ6AJX7XIBHUO7NRTY755TXAVCNFSM6AAAAABG2QUNV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBVGAZTQNJTGI . You are receiving this because you authored the thread.Message ID: @.***>

-- Professor Morgan Kelly School of Economics University College Dublin Dublin 4, Ireland