Consider
Where we have a simulated dataset of, say, average minutes of view time a brick and mortar watch store website gets a day. We have 10 stores and 21 days of interest. Suppose an intervention happens on day 11 in store 7.
I'd like to simulate a 20% increase in view time in store 7 for every day on and after day 11. How might I do this for the variable viewte, i.e., the variable where I give the treatment effect to store 7 versus the counterfactual viewtime?
EDIT: Nevermind, I believe the answer is
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long id float(time viewtime) 1 1 19.975714 1 2 37.55126 1 3 31.75454 1 4 34.482708 1 5 37.957687 1 6 34.685757 1 7 33.42585 1 8 38.066654 1 9 35.42233 1 10 40.10519 1 11 34.073597 1 12 33.787212 1 13 38.15853 1 14 41.39658 1 15 38.52955 1 16 32.819977 1 17 33.45546 1 18 39.41245 1 19 29.78051 1 20 36.461903 1 21 15.513946 2 1 16.433659 2 2 33.840595 2 3 30.447447 2 4 28.703976 2 5 35.939415 2 6 29.0572 2 7 33.041367 2 8 28.40986 2 9 36.257923 2 10 27.53276 2 11 29.869293 2 12 34.053246 2 13 33.908848 2 14 36.9726 2 15 38.28301 2 16 30.911623 2 17 35.976807 2 18 26.072025 2 19 27.30855 2 20 30.367455 2 21 11.185527 3 1 19.37394 3 2 21.69295 3 3 20.575077 3 4 27.018557 3 5 27.957724 3 6 29.93282 3 7 29.18073 3 8 29.65938 3 9 28.848133 3 10 26.185246 3 11 29.24073 3 12 31.060265 3 13 32.779613 3 14 26.03101 3 15 29.35387 3 16 31.6572 3 17 27.20466 3 18 30.169035 3 19 27.57851 3 20 23.29845 3 21 14.912492 4 1 15.184877 4 2 22.69606 4 3 26.2822 4 4 30.965963 4 5 26.81514 4 6 30.4255 4 7 28.56511 4 8 24.688187 4 9 28.350506 4 10 28.60852 4 11 26.83364 4 12 26.74885 4 13 26.12186 4 14 30.77479 4 15 29.15254 4 16 28.851885 4 17 24.692554 4 18 25.326546 4 19 20.599073 4 20 22.905653 4 21 13.914255 5 1 18.787546 5 2 16.889162 5 3 19.677586 5 4 24.65078 5 5 23.704874 5 6 23.60718 5 7 25.95545 5 8 29.256506 5 9 25.62223 5 10 22.98634 5 11 27.367266 5 12 26.55358 5 13 27.35243 5 14 29.45252 5 15 30.69631 5 16 22.603455 5 17 21.62428 5 18 20.724356 5 19 18.064196 5 20 18.004604 5 21 21.84812 6 1 16.409021 6 2 18.98396 6 3 19.191635 6 4 19.071903 6 5 24.96807 6 6 23.68199 6 7 25.9617 6 8 29.490175 6 9 29.31766 6 10 26.54584 6 11 31.95323 6 12 28.646675 6 13 24.282307 6 14 31.065004 6 15 29.886604 6 16 27.49262 6 17 17.919289 6 18 23.236425 6 19 20.84606 6 20 20.14031 6 21 12.76243 7 1 15.110672 7 2 18.400694 7 3 22.01156 7 4 27.270947 7 5 20.76483 7 6 24.91901 7 7 20.831715 7 8 27.008083 7 9 25.94575 7 10 23.6886 7 11 20.69621 7 12 25.39767 7 13 22.00724 7 14 24.76831 7 15 28.88044 7 16 27.93262 7 17 21.46696 7 18 24.653774 7 19 18.369066 7 20 21.40514 7 21 17.199383 8 1 18.944729 8 2 10.582004 8 3 23.365593 8 4 17.311329 8 5 20.985207 8 6 21.29792 8 7 17.702425 8 8 21.01373 8 9 29.44366 8 10 24.27804 8 11 24.91311 8 12 24.065584 8 13 28.387234 8 14 24.49404 8 15 25.22412 8 16 24.40357 8 17 26.06957 8 18 20.239094 8 19 22.94946 8 20 16.647745 8 21 15.432597 9 1 19.83008 9 2 11.46518 9 3 25.599997 9 4 18.582874 9 5 20.10782 9 6 23.231836 9 7 22.71034 9 8 24.67556 9 9 30.17142 9 10 26.793924 9 11 28.24531 9 12 22.00683 9 13 26.5634 9 14 27.998957 9 15 19.589085 9 16 23.666945 9 17 24.21726 9 18 19.18795 9 19 19.68241 9 20 15.386485 9 21 14.81707 10 1 17.011488 10 2 16.99726 10 3 22.111366 10 4 15.96531 10 5 24.6821 10 6 23.82261 10 7 19.079796 10 8 21.65741 10 9 22.92414 10 10 19.57149 10 11 28.774475 10 12 24.77729 10 13 28.74128 10 14 23.130474 10 15 24.27274 10 16 21.09427 10 17 21.36292 10 18 20.445274 10 19 19.57014 10 20 17.517897 10 21 12.557162 end label values id id label def id 1 "Store1", modify label def id 2 "Store2", modify label def id 3 "Store3", modify label def id 4 "Store4", modify label def id 5 "Store5", modify label def id 6 "Store6", modify label def id 7 "Store7", modify label def id 8 "Store8", modify label def id 9 "Store9", modify label def id 10 "Store10", modify loc int_time = 11 xtset id time, g local lbl: value label `r(panelvar)' loc unit ="Store7":`lbl' g treated = cond(id==`unit' & time >= `int_time',1,0) cls twoway line viewt `r(timevar)' if `r(panelvar)' ~=`unit', lcol(gs8%10) connect(L) || ///& `r(timevar)' < `int_time' tsline viewt if `r(panelvar)' ==`unit' , lwidth(thick),, ///& `r(timevar)' < `int_time' tline(`int_time', lpat(solid)) lcol(black) legend(order(1 "Donors" 2 "Store 7") /// ring(0) /// pos(11) /// region(fcol(none))) // su view if time >= `int_time' & id==`unit' clonevar viewte = view //replace viewte = viewte* 2
I'd like to simulate a 20% increase in view time in store 7 for every day on and after day 11. How might I do this for the variable viewte, i.e., the variable where I give the treatment effect to store 7 versus the counterfactual viewtime?
EDIT: Nevermind, I believe the answer is
Code:
replace viewte = viewte + (viewte * .2) if id ==`unit' & time >=11
