lrberge / fixest

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

`r2` fails if package is not attached and fixed effects are present #365

Closed hughjonesd closed 1 year ago

hughjonesd commented 1 year ago

Here's an example:

requireNamespace("fixest")
tmp <- data.frame(a = 1:10, y = rnorm(10), b = rep(1:2,5))
mod <- fixest::feols(y~a|b, tmp) 
fixest::r2(mod)
# Error in if (is_calling_fun("deltaMethod")) { : 
#  the condition has length > 1

The error goes away if I attach the package:

library(fixest)
r2(mod)
       cor2          r2         ar2         pr2        apr2         wr2        war2        wpr2 
 0.07859521  0.07859521 -0.18466330  0.02903102 -0.11283315  0.03121368 -0.10718437  0.01145035 
      wapr2 
-0.06076606 

Package version: 0.10.4. R version: 4.2.0.

lrberge commented 1 year ago

Hi, this bug should have been fixed in the dev version. Could you check if it still persists in your use case?

hughjonesd commented 1 year ago

Yup, it's fixed.