Closed michaeltopper1 closed 1 year ago
Could you show me an example of what error you're getting so I can troubleshoot? To be clear, I don't reproduce an error locally
Certainly! I naively thought the error would be seen on your end. Here's a reprex:
library(fixest)
library(did2s)
#> did2s (v1.1.0). For more information on the methodology, visit <https://www.kylebutts.github.io/did2s>
#>
#> To cite did2s in publications use:
#>
#> Butts & Gardner, "The R Journal: did2s: Two-Stage
#> Difference-in-Differences", The R Journal, 2022
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {did2s: Two-Stage Difference-in-Differences Following Gardner (2021)},
#> author = {Kyle Butts and John Gardner},
#> year = {2021},
#> url = {https://journal.r-project.org/articles/RJ-2022-048/},
#> }
es <- did2s(df_het,
yname = "dep_var", first_stage = ~ 0 | state + year,
second_stage = ~ i(rel_year, ref = c(-1, Inf)), treatment = "treat",
cluster_var = "state"
)
#> Running Two-stage Difference-in-Differences
#> - first stage formula `~ 0 | state + year`
#> - second stage formula `~ i(rel_year, ref = c(-1, Inf))`
#> - The indicator variable that denotes when treatment is on is `treat`
#> - Standard errors will be clustered by `state`
#> Error: in summary.fixest(est$second_stage, .vcov ...:
#> Argument '.vcov' must be either: i) a matrix, or ii) a function.
#> Problem: it is of length 0, while it should have a positive length.
Created on 2023-08-18 with reprex v2.0.2
Should be fixed by 31b26cd. Let me know if it doesn't work for you. I'm in the process of adding sparse_model_matrix
support into fixest
so I can use it across my packages. I manually copied that to this package but didn't fix a bug.
As an FYI, almost always a bug will be found in the vcov creation part of the code. You can, in the short-term use did2s:::did2s_estimate()
to get point estimates with incorrect standard errors. It will be very fast, so I tend to use that with big data when I'm trying to make sure my code/data is correct.
Hey Kyle,
Great work with the package, it's one of my go-tos for robust TWFE estimation!
I did however, find an issue with the development version of the package when estimating an event study.
Below is your example from your README that fails to run:
I keep switching back and forth between the CRAN version and this development version. Looks like in the CRAN version 1.1.0, the event studies work great. However, in the development version, these event studies crash.
Why not just switch back to the CRAN version ? I would, except the newest development version is the only version that will work with my large dataset (~4 mill observations) when including many FEs.
Not sure if this is a quick fix or not, but hope it's something super simple!