bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
287 stars 91 forks source link

Error: "No pre-treatment periods to test" #108

Open azev77 opened 2 years ago

azev77 commented 2 years ago

I created a simple fake dataset: 5 years: 1993-1997 6 groups: 1-6 30 observations = 5 * 6 2 groups (group # 3 & 4) are treated in 1994 2 groups (group # 5 & 6) are treated in 1996

image

I thought my data has the same structure as in your example.

When I run

out <- att_gt(yname = "hpg",
              gname = "first_treat",
              idname = "fips11",
              tname = "year",
              xformla = ~1,         #xformla = ~X,
              data = Book1,
              est_method = "reg"
)

I get the message:

image

But that's wrong bc 1993 is the first year in my data & has no treatment.

How can I fix this? please help

pedrohcgs commented 2 years ago

You need more than 1 pre-treatment period to pre-test.

It is true we cant pre-test parallel trends for the g=1994, but we should be able to do it or the others, I think.

On Fri, Jan 28, 2022 at 18:23 azev77 @.***> wrote:

I created a simple fake dataset: 5 years: 1993-1997 6 groups: 1-6 30 observations = 5 * 6 2 groups (group # 3 & 4) are treated in 1994 2 groups (group # 5 & 6) are treated in 1996

[image: image] https://user-images.githubusercontent.com/7883904/151643491-1db8c7cc-7443-4eda-a2c0-454ca6090165.png

I thought my data has the same structure as in your example.

When I run

out <- att_gt(yname = "hpg", gname = "first_treat", idname = "fips11", tname = "year", xformla = ~1, #xformla = ~X, data = Book1, est_method = "reg" )

I get the message: [image: image] https://user-images.githubusercontent.com/7883904/151643595-344cbfaf-ad70-469a-aa47-c6ca5fc35083.png

But that's wrong bc 1993 is the first year in my data & has no treatment.

How can I fix this? please help

— Reply to this email directly, view it on GitHub https://github.com/bcallaway11/did/issues/108, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE7343OK22DITUXACT2CGTUYNFRXANCNFSM5NCIV4CA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Pedro H. C. Sant'Anna Department of Economics Vanderbilt University 615-875-8448 (phone) @.*** https://pedrohcgs.github.io

pedrohcgs commented 2 years ago

But it seems that you have just 2 units in the g=1996. Is that the case? With teo observations in a group, it is very hard hard to use any sampling-based procedure to do inference.

On Fri, Jan 28, 2022 at 19:22 Pedro H. C. Sant'Anna @.***> wrote:

You need more than 1 pre-treatment period to pre-test.

It is true we cant pre-test parallel trends for the g=1994, but we should be able to do it or the others, I think.

On Fri, Jan 28, 2022 at 18:23 azev77 @.***> wrote:

I created a simple fake dataset: 5 years: 1993-1997 6 groups: 1-6 30 observations = 5 * 6 2 groups (group # 3 & 4) are treated in 1994 2 groups (group # 5 & 6) are treated in 1996

[image: image] https://user-images.githubusercontent.com/7883904/151643491-1db8c7cc-7443-4eda-a2c0-454ca6090165.png

I thought my data has the same structure as in your example.

When I run

out <- att_gt(yname = "hpg", gname = "first_treat", idname = "fips11", tname = "year", xformla = ~1, #xformla = ~X, data = Book1, est_method = "reg" )

I get the message: [image: image] https://user-images.githubusercontent.com/7883904/151643595-344cbfaf-ad70-469a-aa47-c6ca5fc35083.png

But that's wrong bc 1993 is the first year in my data & has no treatment.

How can I fix this? please help

— Reply to this email directly, view it on GitHub https://github.com/bcallaway11/did/issues/108, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE7343OK22DITUXACT2CGTUYNFRXANCNFSM5NCIV4CA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Pedro H. C. Sant'Anna Department of Economics Vanderbilt University 615-875-8448 (phone) @.*** https://pedrohcgs.github.io

--

Pedro H. C. Sant'Anna Department of Economics Vanderbilt University 615-875-8448 (phone) @.*** https://pedrohcgs.github.io

azev77 commented 2 years ago

I'm confused.

  1. in the example data(mpdta) the first year is 2003 and the first treatment is 2004 hence there is also only 1 pre-treatment time period...
  2. I tried w/ a dataset w/ > 150k observations but got the same message "No pre-treatment periods to test"
  3. eventually would it make sense to nest the 2*2 case as a special case?
  4. I can't get the other example in the docs to work image

The following modification works but it's not in the docs:

dta <- build_sim_dataset(reset.sim())
arizagusti commented 10 months ago

Hi, I would like to ask about a similar problem that I face. I have a large dataset with around 3 million observations and I am trying to run your estimator with the never treated as the control. I am using the following code:

num_acc_bal_2017_nev_treat <- att_gt(yname = "num_acc", tname = "year", idname = "id_estab_num", gname = "year_inspect", control = "nevertreated", allow_unbalanced_panel = FALSE, data = df_2017_never_treated, base_period = "universal", panel = TRUE )

and am getting the following error "No pre-treatment periods to test"

I don't believe that I have no pre-treatment periods. I cross tabulated the number of observations by year of treatment and year (shown in the following table) and as you can see, I do have pre-treatment periods to test and there are not a few of them. I also tried running the command csdid on stata, and it does work. Would you be able to help me out with this? Thanks in advance for the help!

Screen Shot 2023-09-09 at 6 13 18 PM