Skip to content
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

Extract confidence intervals (or table) from att_gt or aggte #170

Open
rcragun opened this issue Mar 24, 2023 · 5 comments
Open

Extract confidence intervals (or table) from att_gt or aggte #170

rcragun opened this issue Mar 24, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@rcragun
Copy link

rcragun commented Mar 24, 2023

Problem

I do not see any way to extract the confidence intervals/bands from objects created by att_gt or aggte. More generally, it would help to be able to extract the entire table of ATTs, SEs, and confidence interval limits.

For example, I might get the following as part of the output of aggte():

Overall summary of ATT's based on event-study/dynamic aggregation:  
       ATT    Std. Error     [ 95%  Conf. Int.]
 -4116.697      518.2209  -5132.392   -3101.003 *

Dynamic Effects:
 Event time  Estimate Std. Error [95% Pointwise  Conf. Band] 
          1 -4050.087  2172.0486       -8307.224    207.0497  
          2 -6640.275  2571.5133      -11680.348  -1600.2014 *
          3 -3806.172   964.4840       -5696.526  -1915.8178 *
          4 -2775.943   851.4626       -4444.779  -1107.1069 *
          5 -1471.990   585.7501       -2620.039   -323.9410 *

It would be helpful to be able to extract these two matrices from the AGGTEobj object:

Matrix 1

       ATT    Std. Error     CI95LB      CI95UB
 -4116.697      518.2209  -5132.392   -3101.003

Matrix 2

 Event time  Estimate Std. Error          CI95LB      CI95UB
          1 -4050.087  2172.0486       -8307.224    207.0497  
          2 -6640.275  2571.5133      -11680.348  -1600.2014
          3 -3806.172   964.4840       -5696.526  -1915.8178
          4 -2775.943   851.4626       -4444.779  -1107.1069
          5 -1471.990   585.7501       -2620.039   -323.9410

I made up the names for the confidence interval columns.

Naming

I think the behavior should be similar to lm objects. coef(summary(lmobject)) (or summary(lmobject)$coefficients) returns a matrix like the larger table above.

The matrices above should not be called “coefficients”, though. Perhaps att_table and att_table_overall would be good names.

Use case

I have a list of AGGTEobj objects and want to show confidence intervals for all of the ATTs in the same figure.

@rcragun
Copy link
Author

rcragun commented Mar 30, 2023

It seems that MP and AGGTEobj objects have a tidy() method. This was not easy to find, so it might still help to have a component that includes the matrix (as in MPobject$att_table). This would also help for people who do not use tidyverse.

@bcallaway11
Copy link
Owner

Yes, I agree with you. I'm going to mark this as an enhancement that we should work on.

Thank you!

@bcallaway11 bcallaway11 added the enhancement New feature or request label Apr 3, 2023
@rcragun
Copy link
Author

rcragun commented Apr 5, 2023

Note that even with the tidy method, it still does not seem possible to easily extract the overall confidence intervals from AGGTEobj objects, so that might be the highest priority.

@pedrohcgs
Copy link
Collaborator

pedrohcgs commented Apr 5, 2023 via email

@valentinyverse
Copy link

Hi,

I stumbled over the same issue and saw that with the tidy() function in R you can technically pull out estimates, standard errors and confidence intervals. The problem is though, that tidy() reports different conf.high and conf.low for the same object, than what the object itself reports when printed in the console. I believe it is due to difference in calculations for the confidence interval in the did package.

See my question on stackoverflow to the same issue and the response I got:
https://stackoverflow.com/questions/76056729/why-is-the-confidence-interval-different-when-using-tidy-on-output-of-aggte/76064957#76064957

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants