-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add support for two-way clustering #25
Comments
+1 for this, in my case for product-country two way clustering in fepois. |
Update: this is basically done and should only require some unit tests =) Hi @aeturrell, I have added a skeleton for twoway clustering in case you are under time pressure / need to get results sooner than I will be able to fully implement this. Though I think I can get this done by the end of the week =) The syntax for twoway clustering would be fit = fepois("Y ~ X1 + X2", vcov= {'CRV1': "f1+f2"}, data=df) Alternatively, one could also allow to specify the two clustering variables by a list. |
This is now possible with version 0.10.3. from pyfixest.estimation import fepois
from pyfixest.summarize import summary
from pyfixest.utils import get_data
data = get_data(N = 1000, model = "Fepois")
fit_crv1 = fepois("Y ~ X1 + X2 | f1 + f2", data = data, vcov = {"CRV1":"f1+f2"})
fit_crv3 = fepois("Y ~ X1 + X2 | f1 + f2", data = data, vcov = {"CRV3":"f1+f2"})
summary([fit_crv1, fit_crv3])
###
Estimation: Poisson
Dep. var.: Y, Fixed effects: f1+f2
Inference: CRV1
Observations: 997
| Coefficient | Estimate | Std. Error | t value | Pr(>|t|) | 2.5 % | 97.5 % |
|:--------------|-----------:|-------------:|----------:|-----------:|--------:|---------:|
| X1 | -0.052 | 0.035 | -1.502 | 0.133 | -0.120 | 0.016 |
| X2 | 0.007 | 0.014 | 0.520 | 0.603 | -0.020 | 0.034 |
---
Deviance: 1066.019
###
Estimation: Poisson
Dep. var.: Y, Fixed effects: f1+f2
Inference: CRV3
Observations: 997
| Coefficient | Estimate | Std. Error | t value | Pr(>|t|) | 2.5 % | 97.5 % |
|:--------------|-----------:|-------------:|----------:|-----------:|--------:|---------:|
| X1 | -0.052 | 0.038 | -1.375 | 0.169 | -0.126 | 0.022 |
| X2 | 0.007 | 0.015 | 0.480 | 0.631 | -0.022 | 0.036 |
---
Deviance: 1066.019 So I am closing this for now. Let me know if you experience any issues / would prefer another syntax @aeturrell =) |
Oh wow, amazing, thank you so much. Great timing too! Need this this week. |
The text was updated successfully, but these errors were encountered: