fixest
fixest copied to clipboard
slicing results using the new fixest_multi class are not of class "fixest" when it seems like they should be
Consider the example provided in the "Multiple Estimations" vignette:
base = iris
[names](https://rdrr.io/r/base/names.html)(base) = [c](https://rdrr.io/r/base/c.html)("y1", "y2", "x1", "x2", "species")
res_multi = [feols](https://lrberge.github.io/fixest/reference/feols.html)([c](https://rdrr.io/r/base/c.html)(y1, y2) ~ x1 + [csw](https://lrberge.github.io/fixest/reference/stepwise.html)(x2, x2^2) | [sw0](https://lrberge.github.io/fixest/reference/stepwise.html)(species), base, fsplit = ~species)
On my machine, a single "slice" of res_multi (e.g., the rest of a single fixed effects regression) has class "fixest_multi":
> res_multi[lhs=1,fixef=1,sample=1,rhs=1]
Standard-errors: IID
#
# DEP. VAR.: y1
#
# FIXED-EFFECTS: 1
### Sample: Full sample
Expl. vars.: x1 + x2
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.190582 0.097046 43.18146 < 2.2e-16 ***
x1 0.541777 0.069282 7.81991 9.4145e-13 ***
x2 -0.319551 0.160453 -1.99156 4.8272e-02 *
> class(res_multi[lhs=1,fixef=1,sample=1,rhs=1])
[1] "fixest_multi"
To me, this is unfortunate, because "fixest_multi" is not recognized as a useful class by outside packages that otherwise work nicely with fixest, like, for example, broom or even the base R generics (vcov etc):
> vcov(res_multi[lhs=1,fixef=1,sample=1,rhs=1])
Error in UseMethod("vcov") :
no applicable method for 'vcov' applied to an object of class "fixest_multi"
My current solution to this dilemma is to manually unwrap this one step further:
> class(res_multi[lhs=1,fixef=1,sample=1,rhs=1][[1]])
[1] "fixest"
However, it would be nice if this was unnecessary.