Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
iplot()errors on valid IV models that usesunab(..., no_agg = TRUE)in an interacted endogenous term, even though the coefficient names are valid and plottable.On the econometrics side, you may argue that Sun & Abraham do not cover fuzzy designs, so this is working as intended as we don't know what the Wald-DiD estimator yields under staggered treatments (do we? maybe under homogeneous effects but staggered treatments?). But then I think it should at least output a clearer error like the "without a doubt, your model is misspecified" when you have only variables that are colinear with the FEs. I may do that if you want.
Repro
Actual behavior
iplot() throws:
Expected behavior
iplot() should plot the IV sunab coefficient
Root cause
In IV stage 2,
iplot()used broadfit_prefix stripping, which would fail to recover the correcti()/sunabterm names.I think there was an issue in the past with this (which maybe I reported myself? not sure), so I was extra cautious in stripping only actual endogenous variables that were fitted in the first stage.
Fix
object$iv_endo_names_fit.fit_<endo>:) where appropriate.iv_endo_names_fit.Tests
Added regression coverage in
tests/fixest_tests.R:sunab(..., no_agg = TRUE)interacted fitted regressor now works withiplot().i()variable named withfit_prefix (e.g.fit_user) still works, preventing over-matching regressions.Verification
Interact) passes.IV iplot: OK.Disclaimer
I noticed the error while writing code for a WP and thought it'd be pretty easy to fix. I had Codex write the correction, and it just changed the regex, but I was suspicious so I probed it a bit more and found the issue with variables that start with "fit_", so I had it make the code robust to that as well. Tests pass, I have experience with R and the code smells okay to me, but let me know if you want me to check more thoroughly something specific.