Hi all,
I have a database that looks like this:
What it basically represents is a panel structure by disease class with a normalized year, being 0 the year in which an advanced therapy is introduced in the market for that disease. Treated disease classes are the ones in which such an advanced therapy has been introduced. I guess I can do it balanced (e.g. by taking -3 -2 -1 0 1 2 3 4 years only for all the disease classes). My aim is actually doing a diff in diff analysis in this context. The main problem that I have is let's say, can I define pre and post dummy as being 0 for negative years and 1 for positive years, 0 included (and then create the interaction between treatment and this dummy) or should I create a year dummy for each one of the normalized years and interact each dummy with treatment variable?
In other words, how would you proceed for a diff in diff analysis where the dependent variable is log sales?
Thank you,
Federico
I have a database that looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id_indication norm_year) str83 IndicationLevel3 float(treated launch_year_first_gene_cell) double(prod_ann_sales n_prods counter_new_prod) float(log_sales gr_rate did) 13 -7 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 2 0 . . -7 13 -6 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 3 1 . . -6 13 -5 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 3 0 . . -5 13 -4 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 4 0 . . -4 13 -3 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 4 0 . . -3 13 -2 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 4 1 . . -2 13 -1 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 4 2 . . -1 13 0 "Age-related macular degeneration (AMD), unspecified" 1 2023 68.09300762509591 6 0 4.2208743 . 0 13 1 "Age-related macular degeneration (AMD), unspecified" 1 2023 185.3200987636163 6 0 5.222085 1.0012102 1 13 2 "Age-related macular degeneration (AMD), unspecified" 1 2023 291.38369445292403 6 0 5.674641 .4525566 2 13 3 "Age-related macular degeneration (AMD), unspecified" 1 2023 208.286373822512 4 0 5.338914 -.3357272 3 13 4 "Age-related macular degeneration (AMD), unspecified" 1 2023 260.949361715908 3 0 5.564326 .22541237 4 13 5 "Age-related macular degeneration (AMD), unspecified" 1 2023 316.946554921264 4 1 5.758733 .194407 5 13 6 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 5 0 . . 6 13 7 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 6 1 . . 7 13 8 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 8 0 . . 8 13 9 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 8 0 . . 9 13 10 "Age-related macular degeneration (AMD), unspecified" 1 2023 32.1958562267076 9 3 3.471838 . 10 13 11 "Age-related macular degeneration (AMD), unspecified" 1 2023 34.1135746125679 9 1 3.529695 .05785751 11 13 12 "Age-related macular degeneration (AMD), unspecified" 1 2023 37.2969798215507 9 0 3.6189125 .08921719 12 13 13 "Age-related macular degeneration (AMD), unspecified" 1 2023 41.9779202678342 9 1 3.737144 .1182313 13 13 14 "Age-related macular degeneration (AMD), unspecified" 1 2023 49.02764073361 9 1 3.892384 .15524054 14 13 15 "Age-related macular degeneration (AMD), unspecified" 1 2023 55.761731290709 8 1 4.0210876 .12870336 15 13 16 "Age-related macular degeneration (AMD), unspecified" 1 2023 350.1011718268503 12 2 5.858222 1.8371344 16 13 17 "Age-related macular degeneration (AMD), unspecified" 1 2023 377.4424266057366 11 1 5.933418 .07519627 17 13 18 "Age-related macular degeneration (AMD), unspecified" 1 2023 393.1269686571709 9 1 5.974133 .04071426 18 13 19 "Age-related macular degeneration (AMD), unspecified" 1 2023 420.9569089549775 9 0 6.042531 .068398 19 13 20 "Age-related macular degeneration (AMD), unspecified" 1 2023 365.8 6 0 5.902087 -.1404438 20 13 21 "Age-related macular degeneration (AMD), unspecified" 1 2023 378.4 6 0 5.935952 .033864975 21 13 22 "Age-related macular degeneration (AMD), unspecified" 1 2023 386.65 6 0 5.95752 .0215683 22 13 23 "Age-related macular degeneration (AMD), unspecified" 1 2023 395.1 6 1 5.979139 .021618843 23 13 24 "Age-related macular degeneration (AMD), unspecified" 1 2023 403.8 6 1 6.00092 .02178097 24 13 25 "Age-related macular degeneration (AMD), unspecified" 1 2023 412.5 6 2 6.022236 .02131653 25 13 32 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.1481715679621 3 0 3.991724 . 32 13 33 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.1116936855903 3 0 3.99105 -.0006740093 33 13 34 "Age-related macular degeneration (AMD), unspecified" 1 2023 55.1951505556411 3 0 4.010875 .01982498 34 13 35 "Age-related macular degeneration (AMD), unspecified" 1 2023 56.6109652361522 3 1 4.036203 .02532768 35 13 36 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.6618182873792 3 0 4.0011654 -.035037518 36 13 37 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.6050236621769 4 0 4.000126 -.001039505 37 13 38 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.605023662177 4 1 4.000126 0 38 13 39 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.6050236621769 4 1 4.000126 0 39 13 40 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.6050236621769 4 0 4.000126 0 40 13 41 "Age-related macular degeneration (AMD), unspecified" 1 2023 54.6050236621769 4 0 4.000126 0 41 13 42 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 1 0 . . 42 13 43 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 1 1 . . 43 13 44 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 1 0 . . 44 13 45 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 1 0 . . 45 13 46 "Age-related macular degeneration (AMD), unspecified" 1 2023 0 1 0 . . 46 30 -10 "Anaemia, other" 1 2021 0 1 0 . . -10 30 -9 "Anaemia, other" 1 2021 0 1 0 . . -9 30 -8 "Anaemia, other" 1 2021 0 1 0 . . -8 30 -7 "Anaemia, other" 1 2021 0 4 1 . . -7 30 -6 "Anaemia, other" 1 2021 0 4 0 . . -6 30 -5 "Anaemia, other" 1 2021 0 4 0 . . -5 30 -4 "Anaemia, other" 1 2021 0 5 1 . . -4 30 -3 "Anaemia, other" 1 2021 0 9 1 . . -3 30 -2 "Anaemia, other" 1 2021 0 12 1 . . -2 30 -1 "Anaemia, other" 1 2021 0 12 2 . . -1 30 0 "Anaemia, other" 1 2021 100.11260297837309 11 1 4.6062956 . 0 30 1 "Anaemia, other" 1 2021 579.720334648584 12 0 6.362546 1.7562504 1 30 2 "Anaemia, other" 1 2021 1163.9830434580736 14 2 7.059603 .6970572 2 30 3 "Anaemia, other" 1 2021 1161.740647254543 13 1 7.057675 -.0019283295 3 30 4 "Anaemia, other" 1 2021 1585.65415838967 13 1 7.368752 .3110776 4 30 5 "Anaemia, other" 1 2021 1978.8235687993501 13 2 7.590258 .22150517 5 30 6 "Anaemia, other" 1 2021 1928.692600759952 12 1 7.564598 -.02566004 6 30 7 "Anaemia, other" 1 2021 1855.09233611685 11 1 7.52569 -.038908 7 30 8 "Anaemia, other" 1 2021 23.9490317324397 14 3 3.175928 -4.349762 8 30 9 "Anaemia, other" 1 2021 25.33961379635926 14 1 3.232369 .05644107 9 30 10 "Anaemia, other" 1 2021 24.6364820047618 15 2 3.2042284 -.028140545 10 30 11 "Anaemia, other" 1 2021 25.0925969451134 15 2 3.222573 .018344402 11 30 12 "Anaemia, other" 1 2021 1086.1758350892396 19 2 6.990418 3.7678456 12 30 13 "Anaemia, other" 1 2021 1127.0110193879407 17 1 7.027324 .036905766 13 30 14 "Anaemia, other" 1 2021 1003.8513499695789 20 1 6.911599 -.11572504 14 30 15 "Anaemia, other" 1 2021 682.7168904686663 22 2 6.52608 -.385519 15 30 16 "Anaemia, other" 1 2021 2584.635519918764 27 2 7.85734 1.3312597 16 30 17 "Anaemia, other" 1 2021 2293.00244779975 26 0 7.737617 -.11972237 17 30 18 "Anaemia, other" 1 2021 2012.229915048289 21 2 7.606999 -.13061857 18 30 19 "Anaemia, other" 1 2021 1799.338598517175 21 4 7.495174 -.11182451 19 30 20 "Anaemia, other" 1 2021 1589.9405640059429 20 2 7.371452 -.12372255 20 30 21 "Anaemia, other" 1 2021 1466.391572721288 19 1 7.29056 -.08089209 21 30 22 "Anaemia, other" 1 2021 1216.31719813333 13 2 7.103583 -.1869769 22 30 23 "Anaemia, other" 1 2021 1143.44247835 13 2 7.041799 -.06178427 23 30 24 "Anaemia, other" 1 2021 1043.90635213333 10 2 6.950725 -.09107351 24 30 25 "Anaemia, other" 1 2021 934.2093944 8 1 6.839701 -.11102438 25 30 26 "Anaemia, other" 1 2021 0 3 0 . . 26 30 27 "Anaemia, other" 1 2021 40.1342101292367 3 1 3.692229 . 27 30 28 "Anaemia, other" 1 2021 30.1912818825526 2 0 3.407553 -.28467584 28 30 29 "Anaemia, other" 1 2021 994.9361820818389 4 1 6.902678 3.495125 29 30 30 "Anaemia, other" 1 2021 1008.3022795487369 6 2 6.916023 .013344765 30 30 31 "Anaemia, other" 1 2021 806.8550278523296 8 0 6.693144 -.2228794 31 30 32 "Anaemia, other" 1 2021 565.6512559155442 9 0 6.337978 -.355166 32 30 33 "Anaemia, other" 1 2021 488.98279001097495 12 0 6.192327 -.14565039 33 30 34 "Anaemia, other" 1 2021 420.7261592804868 12 1 6.041982 -.15034533 34 30 35 "Anaemia, other" 1 2021 368.46768495898147 12 1 5.909353 -.1326294 35 30 36 "Anaemia, other" 1 2021 318.6006661335485 12 2 5.763938 -.14541435 36 30 37 "Anaemia, other" 1 2021 264.843321264327 10 2 5.579138 -.18480015 37 30 38 "Anaemia, other" 1 2021 222.003216049088 10 1 5.402692 -.17644644 38 30 39 "Anaemia, other" 1 2021 0 8 0 . . 39 30 40 "Anaemia, other" 1 2021 0 6 1 . . 40 30 41 "Anaemia, other" 1 2021 0 4 0 . . 41 end
In other words, how would you proceed for a diff in diff analysis where the dependent variable is log sales?
Thank you,
Federico