New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixest vcov catches #357
Fixest vcov catches #357
Conversation
R/get_vcov.R
Outdated
@@ -15,6 +15,42 @@ get_vcov <- function(model, vcov = NULL, conf_level = NULL, ...) { | |||
"The `vcov` argument accepts a variance-covariance matrix, a vector of standard errors, or a ", | |||
"function that returns one of these, such as `stats::vcov`.") | |||
|
|||
## fixest models | |||
if (class(model) %in% c("fixest", "fixest_multi")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is the test failures are due to this line, because class(model)
is a vector with two elements for these classes. So I think you need class(model)[1] %in% ...
or maybe inherits(model, "fixest") || inherits(model, "fixest_multi")
This looks fantastic, thanks! I'd be happy to merge when tests pass. I'm pretty sure I identified the culprit in my comment above, and it should be a very easy fix. |
0aebd03
to
eca79d5
Compare
I updated with your hotfix and also added some better checking + flow, depending on the fixest version. Looks like everything is passing except for an annoying warning about an undeclared dependency ( |
Fantastic! |
I know you (we!) largely came out against hardcoding specific model classes in #280. But been I've running into this whilst teaching, so thought I might as well have a go at it. I won't be offended if you decide not to merge given the aforementioned stance, but I do think the current behaviour is a little sub-optimal given the popularity of fixest.
(Note: If you're game, I can probably do something similar for lfe::felm, which also requires a couple of control flow catches. estimatr is harder b/c --- unlike lfe::felm --- it doesn't include the iid vcov errors as part of the return object).
cc @elbersb
Examples:.
Created on 2021-08-14 by the reprex package (v2.0.0)