Open benzipperer opened 1 year ago
I think what's causing the error is how reframe
is being called under the hood and how that interacts with how feols
objects are being transformed in broom::tidy()
. There's no error in broom::tidy
, so it must be something else going on (perhaps parallelism in C++ code).
library(dplyr, warn.conflicts = FALSE)
library(fixest)
ests = trade |>
nest_by(Year) |>
mutate(model = list(feols(Euros ~ dist_km | Origin, data = data)))
broom::tidy(ests$model[[1]])
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -42260. 10081. -4.19 0.000904
purrr::map(ests$model, broom::tidy)
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> Warning in eval(x$call$data, x$call_env): restarting interrupted promise
#> evaluation
#> [[1]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -42260. 10081. -4.19 0.000904
#>
#> [[2]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -46187. 11033. -4.19 0.000915
#>
#> [[3]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -43362. 10223. -4.24 0.000821
#>
#> [[4]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -46795. 11035. -4.24 0.000823
#>
#> [[5]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -52298. 12220. -4.28 0.000763
#>
#> [[6]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -53253. 12667. -4.20 0.000883
#>
#> [[7]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -55766. 13397. -4.16 0.000958
#>
#> [[8]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -55920. 13551. -4.13 0.00103
#>
#> [[9]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -57723. 13970. -4.13 0.00102
#>
#> [[10]]
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -58494. 14546. -4.02 0.00126
I'm not sure exactly what you're doing, but it's probably easier to use the split
argument in feols
:
ests = feols(Euros ~ dist_km | Origin, data = trade, split = ~ Year)
purrr::map(ests, broom::tidy)
#> $`sample.var: Year; sample: 2007`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -42260. 10081. -4.19 0.000904
#>
#> $`sample.var: Year; sample: 2008`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -46187. 11033. -4.19 0.000915
#>
#> $`sample.var: Year; sample: 2009`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -43362. 10223. -4.24 0.000821
#>
#> $`sample.var: Year; sample: 2010`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -46795. 11035. -4.24 0.000823
#>
#> $`sample.var: Year; sample: 2011`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -52298. 12220. -4.28 0.000763
#>
#> $`sample.var: Year; sample: 2012`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -53253. 12667. -4.20 0.000883
#>
#> $`sample.var: Year; sample: 2013`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -55766. 13397. -4.16 0.000958
#>
#> $`sample.var: Year; sample: 2014`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -55920. 13551. -4.13 0.00103
#>
#> $`sample.var: Year; sample: 2015`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -57723. 13970. -4.13 0.00102
#>
#> $`sample.var: Year; sample: 2016`
#> # A tibble: 1 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 dist_km -58494. 14546. -4.02 0.00126
Created on 2023-05-05 with reprex v2.0.2
Hi, thanks again for the excellent package!
Do you know why I get this warning message with feols(), but not with lm() ?
Created on 2023-02-24 with reprex v2.0.2