Comments (5)
Thank you for your fast answer, It now works as expected !
I agree with you about using keep
and drop
instead of the too specific lead
and lag
.
from fixest.
Thanks for your very clear request!
I've just released a new version of the package (0.5.0) so a few comments are in order:
- now collinear variables are removed on the fly, so your solution with
window
should work (and works). - I've added the possibility to add multiple references in interactions, so you can do what you want directly there:
data(base_did)
df = base_did ; df$window = ifelse(df$period %in% 3:7 & df$treat, 1, 0)
est1 = feols(y ~ x1 + window::period | id + period, df)
#> Variables 'window:period::1', 'window:period::2' and 3 others have been removed because of collinearity (see $collin.var).
est2 = feols(y ~ x1 + treat::period(c(1:2, 8:10)) | id + period, base_did)
etable(est1, est2)
#> est1 est2
#> x1 0.9907*** (0.04843) 0.9907*** (0.04843)
#> window:period::3 -2.789** (0.8627)
#> window:period::4 -4.314*** (0.9298)
#> window:period::5 -2.502** (0.9101)
#> window:period::6 -1.725* (0.8379)
#> window:period::7 1.083 (0.7922)
#> treat:period::3 -2.789** (0.8627)
#> treat:period::4 -4.314*** (0.9298)
#> treat:period::5 -2.502** (0.9101)
#> treat:period::6 -1.725* (0.8379)
#> treat:period::7 1.083 (0.7922)
#> Fixed-Effects: ------------------- -------------------
#> id Yes Yes
#> period Yes Yes
#> ___________________ ___________________ ___________________
#> Observations 1,080 1,080
#> S.E. type: Clustered by: id by: id
#> R2 0.50713 0.50713
#> Within R2 0.33496 0.33496
The big problem is that by doing these changes I introduced bugs in coefplot
(sigh)--because the automatic reference was supposed to be unitary and due to other internal quirks.
In est2, the interaction plot works:
coefplot(est2)
But then all the references are represented as data points.
In est1, the interaction plot throws an error. A workaround is to do a "normal" coefplot:
coefplot(est1, only.inter = FALSE, drop = "x1")
You can also locate the coefficients where you want on the x-axis using the argument x
(in case the factors are not consecutive numbers):
coefplot(est1, only.inter = FALSE, drop = "x1", x = c(0, 3.5, 4, 4.5, 6.5, 7), xlim.add = c(-0.1,0.1))
Note that you still have to provide a value for the x1
that is dropped though (I'll try to fix that when I have the time).
On Your suggestions
As you noticed, the factor to be interacted with can be of any type (logical, numeric, character, factor) and can represent anything, not only time periods. So the lead
and lag
arguments are off the table since they are not general enough.
I think I'll introduce the two arguments keep
and drop
on top of the ref
argument. Why? Because the meaning of what keep
and drop
do is explicit, intuitive, and applies to any situation.
I will also keep the ref
argument to ensure a synergy with coefplot
. The difference between ref
and drop
would be:
- coefficients removed by
ref
will appear in the output ofcoefplot
- coefficients removed by
drop
will not appear in the output ofcoefplot
What do you think? Would these changes be OK?
In any case, thanks a lot for the effort, very appreciated!
from fixest.
Great then! :-)
I'll close the issue when I add the new arguments.
from fixest.
That's done! Still haven't fixed the coefplot
bug though, but I will soon.
Thanks again!
from fixest.
Fyi: just got rid of the bug when interacted variables were removed because of collinearity.
from fixest.
Related Issues (20)
- Potential binning issue in regressions HOT 3
- Unable to successfully save plots produced by coefplot() or iplot() HOT 4
- RcppEigen::fastLm HOT 4
- Inconsistent confidence intervals HOT 4
- OLS vs `feols()` HOT 2
- [request] Support etable in self-contained Rmarkdown HTML documents.
- `r2` fails if package is not attached and fixed effects are present HOT 2
- How to set 0 or not applicable values for Cluster, IV, FE parts of the call? HOT 5
- header generates NA in latex table HOT 1
- Can fixest auto-Inverse-Variance weight the FE estimate? HOT 1
- Custom coefficient format for a specific variable in fixest etable
- How to use bias-reduced linearization (BRL) / CR2 - adjusted standard errors with feols? HOT 2
- R Session Aborted with IV when all variables are collinear with the fixed effects
- Feature request/bug: predict/fitted for multiple lhs regressions
- Accessing the within rhs covariates HOT 2
- find weights column within data HOT 2
- run the same model 3 times, the result changes HOT 4
- slicing results using the new fixest_multi class are not of class "fixest" when it seems like they should be
- Abadie et al (2023) standard errors? HOT 6
- fixest2::feglm(mpg ~ wt | as.integer(cyl), data = mtcars) :
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fixest.