I am working on a sugar tax evaluation, using an interrupted time series model that accounts for two implementation periods where the sugar tax increased. I am having trouble graphing the counterfactual line for the two periods after the interventions. As a note: I have used itsa as well, but this user-written command does not allow me to add the counterfactual lines to the graph. Therefore, I have estimated the equation using newey and interaction for each of the tax periods - the first tax is inclusive of weeks 1 to 37; tax 2 is inclusive of weeks 63 to 103. Below is the code I have been using to plot my graph, however the counterfactual plot does not match the results I am getting with itsa, nor does it make theoretical sense, as the estimates plotted do not overlap the fitted values, even when the itsa command returns non-significant results. Either my code to include the two treatment periods is incorrectly specified, or my prediction equations are incorrect. Any help would be greatly appreciated Ariel Linden!
Note: vpc is my outcome of interest, which stands for volume per capita, newid is the type of product I am looking at, in this example, newid ==2 is the non-sugary drinks.
itsa command:
itsa vpc overall trend holidays season, single treat(2) trperiod(37 63) lag(1) posttrend figure
manual command to make graph with counterfactuals plotted in it:
* regression
newey vpc tax1 tax1#c.week tax2 tax2#c.week tax1#tax2 overall trend holidays season if newid==2, lag(1)
* generate predicted values based on model
predict pred if newid==2
* generate the counterfactual
gen pred1 = pred - _b[tax1] if tax1==1 & tax2==0 & newid==2
gen pred2 = pred - _b[tax1] - _b[tax2] if tax1==1 & tax2==1 & newid==2
* plot scatter graph
twoway (scatter vpc week if newid==2) ///
(line pred week, lcolor(black)) ///
(line pred1 week, lcolor(black) lpattern(dash)) ///
(line pred2 week, lcolor(black) lpattern(dash)) , ///
xline(37 63) ///
legend(order(1 "Weekly sales" 2 "Fitted values" 3 "Counterfactual")) ///
ytitle("Weekly sales (fl oz/capita)")
If useful, the taxes are defined as following:
gen tax1 = 1 if week >= 37
replace tax1 = 0 if week < 37
lab var tax1 "Tax 1 (@Week 37)"
lab def tax 0 "Pre-tax" 1 "Post-tax"
gen tax2 = 1 if week >= 63
replace tax2 = 0 if week < 63
lab var tax2 "Tax 2 (@Week 63)"
Thanks in advance for any support,
Alexa Segal (PhD Candidate at Imperial College London)
Related Posts with Interrupted time series with multiple treatment periods
Conditional code blockDoes Stata have a way to do conditional code blocks, i.e. Code: if condition { do this do this do …
Using "if" and "and" commands while generating variablesI have a numeric variable, say x. A lot of values are 0. The rest are all positive. I want to create…
Merging one file with every other file in folderHello, I am trying to merge one file in a folder with every other file in it by looping through eve…
Testing text on local macro dereferenceBecause the Stata User's Guide PDF is printed in a typeface that does not display punctuation identi…
First occurrenceHi all, I have a dataset with the launch_date (data_lancio) for each molecule, which is repeated ov…
Subscribe to:
Post Comments (Atom)
0 Response to Interrupted time series with multiple treatment periods
Post a Comment