fixest
fixest copied to clipboard
interrupted promise warning from reframe(broom:tidy)
trafficstars
Hi, thanks again for the excellent package!
Do you know why I get this warning message with feols(), but not with lm() ?
library(dplyr, warn.conflicts = FALSE)
library(fixest)
trade %>%
nest_by(Year) %>%
mutate(model = list(feols(Euros ~ dist_km | Origin, data = data))) %>%
reframe(broom::tidy(model))
#> Warning: There were 9 warnings in `reframe()`.
#> The first warning was:
#> ℹ In argument: `broom::tidy(model)`.
#> ℹ In row 2.
#> Caused by warning:
#> ! restarting interrupted promise evaluation
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 8 remaining warnings.
#> # A tibble: 10 × 6
#> Year term estimate std.error statistic p.value
#> <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 2007 dist_km -42260. 10081. -4.19 0.000904
#> 2 2008 dist_km -46187. 11033. -4.19 0.000915
#> 3 2009 dist_km -43362. 10223. -4.24 0.000821
#> 4 2010 dist_km -46795. 11035. -4.24 0.000823
#> 5 2011 dist_km -52298. 12220. -4.28 0.000763
#> 6 2012 dist_km -53253. 12667. -4.20 0.000883
#> 7 2013 dist_km -55766. 13397. -4.16 0.000958
#> 8 2014 dist_km -55920. 13551. -4.13 0.00103
#> 9 2015 dist_km -57723. 13970. -4.13 0.00102
#> 10 2016 dist_km -58494. 14546. -4.02 0.00126
trade %>%
nest_by(Year) %>%
mutate(model = list(lm(Euros ~ dist_km + as.factor(Origin), data = data))) %>%
reframe(broom::tidy(model))
#> # A tibble: 160 × 6
#> Year term estimate std.error statistic p.value
#> <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 2007 (Intercept) 61449779. 7855309. 7.82 6.66e-15
#> 2 2007 dist_km -42260. 3022. -14.0 2.37e-43
#> 3 2007 as.factor(Origin)BE 37714454. 9763559. 3.86 1.14e- 4
#> 4 2007 as.factor(Origin)DE 73967731. 9755537. 7.58 4.25e-14
#> 5 2007 as.factor(Origin)DK 17392750. 9790353. 1.78 7.57e- 2
#> 6 2007 as.factor(Origin)ES 72818361. 9934761. 7.33 2.81e-13
#> 7 2007 as.factor(Origin)FI 28691575. 10798670. 2.66 7.92e- 3
#> 8 2007 as.factor(Origin)FR 71717039. 9748046. 7.36 2.29e-13
#> 9 2007 as.factor(Origin)GB 18898109. 9774637. 1.93 5.33e- 2
#> 10 2007 as.factor(Origin)GR 32502186. 10670611. 3.05 2.34e- 3
#> # … with 150 more rows
Created on 2023-02-24 with reprex v2.0.2
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