I have a question regarding how to run a generalized diff-in-diff with treatments that are implemented at different times and with different intensities (continuous rather than binary treatments).

Suppose I have monthly data over the last 10 years indicating how many flu vaccines a government program provided in 100 cities. Over this 10 year period this program was the only flu vaccine provider in 35 of these cities. However, in 33 of these cities there was a single, competing commercial provider for this entire 10 year period, and I have data on how many vaccines that company provided by month as well. This company also opened up vaccine clinics in the remaining 32 cities at different points over the 10 year period (and I have data on the number of vaccines they provide each month once opened).

I want to estimate how much the private provision of vaccines displaces public provision.

The data has both a panel element (city) and time series element. I believe I understand how to approach this using diff-in-diff if I simply consider the opening of a private clinic as a binary treatment variable. To do this I create a dummy variable called treat, which is 1 in for the cities that receive the treatment of having a private clinic open up at sometime during the 10 year period (and is 1 in those observations at all times, including before treatment started) and 0 in all observations for the untreated groups (the cities that have never faced any vaccine competition). Then I create another dummy variable called activetreat which is 1 in the treatment group after treatment begins, but is 0 in the treatment group before treatment begins and is 0 in all observations in the control group. Then, something like:

xtset city

xtreg government_vaccines i.treat i.activetreat i.time, fe

However, this approach effectively throws out data from the 33 cities that always had competition and it does not take into effect the magnitude of the treatment, namely the number of vaccines that private clinics administer, which can vary by time and city (e.g. it can take few years to ramp up operations).

I'm aware of a few papers that have done something like this ( Acemoglu, Autor and Lyle (2004) ) but it's not clear to me how to operationalize this approach in Stata.

Can anyone provide any guidance regarding how to run generalized diff-in-diff with treatments that are implemented at different times and with varying magnitudes over time?

Suppose I have monthly data over the last 10 years indicating how many flu vaccines a government program provided in 100 cities. Over this 10 year period this program was the only flu vaccine provider in 35 of these cities. However, in 33 of these cities there was a single, competing commercial provider for this entire 10 year period, and I have data on how many vaccines that company provided by month as well. This company also opened up vaccine clinics in the remaining 32 cities at different points over the 10 year period (and I have data on the number of vaccines they provide each month once opened).

I want to estimate how much the private provision of vaccines displaces public provision.

The data has both a panel element (city) and time series element. I believe I understand how to approach this using diff-in-diff if I simply consider the opening of a private clinic as a binary treatment variable. To do this I create a dummy variable called treat, which is 1 in for the cities that receive the treatment of having a private clinic open up at sometime during the 10 year period (and is 1 in those observations at all times, including before treatment started) and 0 in all observations for the untreated groups (the cities that have never faced any vaccine competition). Then I create another dummy variable called activetreat which is 1 in the treatment group after treatment begins, but is 0 in the treatment group before treatment begins and is 0 in all observations in the control group. Then, something like:

xtset city

xtreg government_vaccines i.treat i.activetreat i.time, fe

However, this approach effectively throws out data from the 33 cities that always had competition and it does not take into effect the magnitude of the treatment, namely the number of vaccines that private clinics administer, which can vary by time and city (e.g. it can take few years to ramp up operations).

I'm aware of a few papers that have done something like this ( Acemoglu, Autor and Lyle (2004) ) but it's not clear to me how to operationalize this approach in Stata.

Can anyone provide any guidance regarding how to run generalized diff-in-diff with treatments that are implemented at different times and with varying magnitudes over time?

## Comment