lrberge / fixest

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

Error when multiple estimation with offset #405

Closed etiennebacher closed 8 months ago

etiennebacher commented 1 year ago
library(fixest)
packageVersion("fixest")
#> [1] '0.11.1'

### works
feols(mpg ~ hp, offset = ~ log(qsec), data = mtcars)
#> OLS estimation, Dep. Var.: mpg
#> Observations: 32 
#> Offset: log(qsec) 
#> Standard-errors: IID 
#>              Estimate Std. Error  t value   Pr(>|t|)    
#> (Intercept) 27.066631   1.643907 16.46482  < 2.2e-16 ***
#> hp          -0.067171   0.010181 -6.59757 2.6589e-07 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 3.76316   Adj. R2: 0.578392

### works
feols(c(mpg, am) ~ hp, data = mtcars)
#> Standard-errors: IID 
#> Dep. var.: mpg
#>              Estimate Std. Error  t value   Pr(>|t|)    
#> (Intercept) 30.098861   1.633921 18.42125  < 2.2e-16 ***
#> hp          -0.068228   0.010119 -6.74239 1.7878e-07 ***
#> ---
#> Dep. var.: am
#>              Estimate Std. Error  t value  Pr(>|t|)    
#> (Intercept)  0.665888   0.208106  3.19976 0.0032406 ** 
#> hp          -0.001770   0.001289 -1.37332 0.1798309

### doesn't work
feols(c(mpg, am) ~ hp, offset = ~ log(qsec), data = mtcars)
#> Error in y - offset: non-numeric argument to binary operator
pachadotdev commented 1 year ago

Hi @lrberge

I was here for the same thing. Here's my session info (fixest 0.11.1)

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora Linux 37 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libflexiblas.so.3.3

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C               LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8    LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] fixest_0.11.1  lfe_2.9-0      testthat_3.1.6 Matrix_1.5-3   devtools_2.4.5 usethis_2.1.6 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10         dreamerr_1.2.3      compiler_4.2.2      later_1.3.0         urlchecker_1.0.1    prettyunits_1.1.1  
 [7] profvis_0.3.7       remotes_2.4.2       tools_4.2.2         digest_0.6.31       pkgbuild_1.4.0      pkgload_1.3.2      
[13] nlme_3.1-162        lattice_0.20-45     memoise_2.0.1       lifecycle_1.0.3     rlang_1.1.0         shiny_1.7.4        
[19] cli_3.6.0           rstudioapi_0.14     parallel_4.2.2      fastmap_1.1.1       withr_2.5.0         CoprManager_0.5.0  
[25] stringr_1.5.0       desc_1.4.2          fs_1.6.1            vctrs_0.6.0         htmlwidgets_1.6.1   rprojroot_2.0.3    
[31] grid_4.2.2          glue_1.6.2          R6_2.5.1            processx_3.8.0      sessioninfo_1.2.2   Formula_1.2-5      
[37] callr_3.7.3         purrr_1.0.1         magrittr_2.0.3      ps_1.7.2            promises_1.2.0.1    ellipsis_0.3.2     
[43] htmltools_0.5.4     mime_0.12           xtable_1.8-4        numDeriv_2016.8-1.1 httpuv_1.6.9        sandwich_3.0-2     
[49] stringi_1.7.12      miniUI_0.1.1.1      cachem_1.0.7        crayon_1.5.2        brio_1.1.3          zoo_1.8-11
lrberge commented 8 months ago

Thanks for the report! Now fixed.