Hi all
I have a panel dataset I am attempting to set up for a staggered difference in difference using the CSDID package by Callaway and Sant'Anna . A deidentified version of the dataset is described below.
I would like to set up an exact match based on state and event quarter . For instance if a treatment sample experiences an event in quarter 5 in Georgia, I would like to make all nontreatment samples in Georgia that we have data for quarter 5 the matched controls. Thereafter I would like to create a propensity score to inverse probability weight based on var 1 var 2 and other variables based on the values of those variables in quarter 5. Quarter 5 would be the "anchor date" or "time to event =zero" in the difference in difference in that scenario.
I am really having trouble setting up the exact match. I tried "joinby", "matchit" and "psmatch2" but have not really been able to make progress. Does anyone have any tips on how I might be able to get started?
id=sample ID
quarter =a sequential time period starting from zero, same for all observations,
eventquarter=the quarter an event happened for treatment , missing otherwise
state= the state the sample is in
outcome=the outcome of interest
var1, var2= only two listed for simplicity but covariates I am hoping to adjust for in a propensity score
treatment= whether a sample is ever in the treatment group
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str4 id byte quarter float eventquarter str2 state int(outcome var1 var2) float treatment
"288" 9 . "NY" 0 1 1 0
"288" 10 . "NY" 0 3 7 0
"288" 11 . "NY" 0 3 6 0
"277" 12 9 "NY" 0 0 4 1
"277" 13 9 "NY" 0 1 0 1
"277" 16 9 "NY" 0 0 1 1
I have a panel dataset I am attempting to set up for a staggered difference in difference using the CSDID package by Callaway and Sant'Anna . A deidentified version of the dataset is described below.
I would like to set up an exact match based on state and event quarter . For instance if a treatment sample experiences an event in quarter 5 in Georgia, I would like to make all nontreatment samples in Georgia that we have data for quarter 5 the matched controls. Thereafter I would like to create a propensity score to inverse probability weight based on var 1 var 2 and other variables based on the values of those variables in quarter 5. Quarter 5 would be the "anchor date" or "time to event =zero" in the difference in difference in that scenario.
I am really having trouble setting up the exact match. I tried "joinby", "matchit" and "psmatch2" but have not really been able to make progress. Does anyone have any tips on how I might be able to get started?
id=sample ID
quarter =a sequential time period starting from zero, same for all observations,
eventquarter=the quarter an event happened for treatment , missing otherwise
state= the state the sample is in
outcome=the outcome of interest
var1, var2= only two listed for simplicity but covariates I am hoping to adjust for in a propensity score
treatment= whether a sample is ever in the treatment group
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str4 id byte quarter float eventquarter str2 state int(outcome var1 var2) float treatment
"288" 9 . "NY" 0 1 1 0
"288" 10 . "NY" 0 3 7 0
"288" 11 . "NY" 0 3 6 0
"277" 12 9 "NY" 0 0 4 1
"277" 13 9 "NY" 0 1 0 1
"277" 16 9 "NY" 0 0 1 1