Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Collinearity problem DiD

    Hello,

    I have this data. I'm trying to run a placebo DiD. Pre-treatment =2018. Some of the drugs got treated in 2019, and others in 2020.

    When I use this command random effect, I get some results. However, when I use fixed effects, all the drugs are omitted due to collinearity.


    Code:
    xtreg Tot_Clms treatment_indicator##year  year2019 i.civica_altrantive_code i.Gnrc_Name_code , vce(cluster civica_altrantive_code)
    Any idea how to solve this issue??

    Thank you,

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str227 Brnd_Name str137 Gnrc_Name long Tot_Clms_2017 float date str137 civica_altrantive float(civica_date treatment_indicator t_2018 t_2019 t_2020) long(Gnrc_Name_code Brnd_Name_code civica_altrantive_code) float(year K id year2019 year2020)
    "Actiq"                                          "Fentanyl Citrate"                71 2018 "Fentalyn & Morphin"          2019 0 1 0 0 42  1  7 0 -1  1 1 0
    "Actiq"                                          "Fentanyl Citrate"                61 2019 "Fentalyn & Morphin"          2019 1 0 1 0 42  1  7 1  0  1 1 0
    "Actiq"                                          "Fentanyl Citrate"                34 2020 "Fentalyn & Morphin"          2019 1 0 0 1 42  1  7 0  1  1 1 0
    "Akten"                                          "Lidocaine HCl/PF"                53 2018 "Lidocaine"                   2019 0 1 0 0 52  2 10 0 -1  2 1 0
    "Akten"                                          "Lidocaine HCl/PF"                89 2019 "Lidocaine"                   2019 1 0 1 0 52  2 10 1  0  2 1 0
    "Akten"                                          "Lidocaine HCl/PF"                48 2020 "Lidocaine"                   2019 1 0 0 1 52  2 10 0  1  2 1 0
    "Aldactone"                                      "Spironolactone"                2851 2018 "metoprolol Tartrate"         2019 0 1 0 0 72  3 18 0 -1  3 1 0
    "Aldactone"                                      "Spironolactone"                2456 2019 "metoprolol Tartrate"         2019 1 0 1 0 72  3 18 1  0  3 1 0
    "Aldactone"                                      "Spironolactone"                2084 2020 "metoprolol Tartrate"         2019 1 0 0 1 72  3 18 0  1  3 1 0
    "Alembic Pharmac"                                "Famotidine"                  412649 2018 "Pantoprazole"                2020 0 1 0 0 39 72 13 0 -2  4 0 1
    "Alembic Pharmac"                                "Famotidine"                  630009 2019 "Pantoprazole"                2020 0 0 1 0 39 72 13 0 -1  4 0 1
    "Alembic Pharmac"                                "Famotidine"                 1782882 2020 "Pantoprazole"                2020 1 0 0 1 39 72 13 1  0  4 0 1
    "American Antibi"                                "Amoxicillin"                     27 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2  5 0 1
    "American Antibi"                                "Amoxicillin"                     27 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1  5 0 1
    "American Antibi"                                "Amoxicillin"                     44 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0  5 0 1
    "Amikacin Sulfate"                               "Amikacin Sulfate"             16532 2018 "Ampiciliin"                  2020 0 1 0 0  1  4  1 0 -2  6 0 1
    "Amikacin Sulfate"                               "Amikacin Sulfate"             13442 2019 "Ampiciliin"                  2020 0 0 1 0  1  4  1 0 -1  6 0 1
    "Amikacin Sulfate"                               "Amikacin Sulfate"             11600 2020 "Ampiciliin"                  2020 1 0 0 1  1  4  1 1  0  6 0 1
    "Amitriptyline HCl"                              "Amitriptyline HCl"          3797915 2018 "Lorazepam"                   2020 0 1 0 0  2  5 19 0 -1  7 0 1
    "Amitriptyline HCl"                              "Amitriptyline HCl"          3681732 2019 "Lorazepam"                   2020 1 0 1 0  2  5 19 0  0  7 0 1
    "Amitriptyline HCl"                              "Amitriptyline HCl"          3755045 2020 "Lorazepam"                   2020 1 0 0 1  2  5 19 1  1  7 0 1
    "Amoxapine"                                      "Amoxapine"                     3126 2018 "Lorazepam"                   2020 0 1 0 0  3  6 19 0 -1  8 0 1
    "Amoxapine"                                      "Amoxapine"                     4047 2019 "Lorazepam"                   2020 1 0 1 0  3  6 19 0  0  8 0 1
    "Amoxapine"                                      "Amoxapine"                     2934 2020 "Lorazepam"                   2020 1 0 0 1  3  6 19 1  1  8 0 1
    "Amoxicillin,Aurobindo Pharm"                    "Amoxicillin"                1412964 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2  9 0 1
    "Amoxicillin,Aurobindo Pharm"                    "Amoxicillin"                2341980 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1  9 0 1
    "Amoxicillin,Aurobindo Pharm"                    "Amoxicillin"                1777946 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0  9 0 1
    "Amoxicillin,Bi-Coastal Phar"                    "Amoxicillin"                   4621 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2 10 0 1
    "Amoxicillin,Bi-Coastal Phar"                    "Amoxicillin"                    272 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1 10 0 1
    "Amoxicillin,Bi-Coastal Phar"                    "Amoxicillin"                    211 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0 10 0 1
    "Amoxicillin,Northstar Rx Ll"                    "Amoxicillin"                 534065 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2 11 0 1
    "Amoxicillin,Northstar Rx Ll"                    "Amoxicillin"                 605909 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1 11 0 1
    "Amoxicillin,Northstar Rx Ll"                    "Amoxicillin"                 596963 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0 11 0 1
    "Amoxicillin,Rising Pharm"                       "Amoxicillin"                 672617 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2 12 0 1
    "Amoxicillin,Rising Pharm"                       "Amoxicillin"                 760515 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1 12 0 1
    "Amoxicillin,Rising Pharm"                       "Amoxicillin"                 782981 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0 12 0 1
    "Amoxicillin,Sandoz"                             "Amoxicillin"                2054664 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2 13 0 1
    "Amoxicillin,Sandoz"                             "Amoxicillin"                2312775 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1 13 0 1
    "Amoxicillin,Sandoz"                             "Amoxicillin"                1990184 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0 13 0 1
    "Amoxicillin,Teva USA"                           "Amoxicillin"                2444739 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2 14 0 1
    "Amoxicillin,Teva USA"                           "Amoxicillin"                1370516 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1 14 0 1
    "Amoxicillin,Teva USA"                           "Amoxicillin"                1236808 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0 14 0 1
    "Amoxicillin,West-Ward/Hikma"                    "Amoxicillin"                 336622 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  4  7 14 0 -2 15 0 1
    "Amoxicillin,West-Ward/Hikma"                    "Amoxicillin"                 380317 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  4  7 14 0 -1 15 0 1
    "Amoxicillin,West-Ward/Hikma"                    "Amoxicillin"                 541682 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  4  7 14 1  0 15 0 1
    "Amoxicillin-Clavulanate Pot ER,Dr.Reddy'S Lab"  "Amoxicillin/Potassium Clav"     223 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  8 14 0 -2 16 0 1
    "Amoxicillin-Clavulanate Pot ER,Dr.Reddy'S Lab"  "Amoxicillin/Potassium Clav"     113 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  8 14 0 -1 16 0 1
    "Amoxicillin-Clavulanate Pot ER,Dr.Reddy'S Lab"  "Amoxicillin/Potassium Clav"      47 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  8 14 1  0 16 0 1
    "Amoxicillin-Clavulanate Pot ER,Sandoz"          "Amoxicillin/Potassium Clav"   13731 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  8 14 0 -2 17 0 1
    "Amoxicillin-Clavulanate Pot ER,Sandoz"          "Amoxicillin/Potassium Clav"   15062 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  8 14 0 -1 17 0 1
    "Amoxicillin-Clavulanate Pot ER,Sandoz"          "Amoxicillin/Potassium Clav"   14445 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  8 14 1  0 17 0 1
    "Amoxicillin-Clavulanate Potass,Aurobindo Pharm" "Amoxicillin/Potassium Clav"  926899 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 18 0 1
    "Amoxicillin-Clavulanate Potass,Aurobindo Pharm" "Amoxicillin/Potassium Clav" 1221369 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 18 0 1
    "Amoxicillin-Clavulanate Potass,Aurobindo Pharm" "Amoxicillin/Potassium Clav" 1666963 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 18 0 1
    "Amoxicillin-Clavulanate Potass,Dr.Reddy'S Lab"  "Amoxicillin/Potassium Clav"   18480 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 19 0 1
    "Amoxicillin-Clavulanate Potass,Dr.Reddy'S Lab"  "Amoxicillin/Potassium Clav"    7901 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 19 0 1
    "Amoxicillin-Clavulanate Potass,Dr.Reddy'S Lab"  "Amoxicillin/Potassium Clav"    2086 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 19 0 1
    "Amoxicillin-Clavulanate Potass,Micro Labs USA," "Amoxicillin/Potassium Clav"   62387 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 20 0 1
    "Amoxicillin-Clavulanate Potass,Micro Labs USA," "Amoxicillin/Potassium Clav"  274570 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 20 0 1
    "Amoxicillin-Clavulanate Potass,Micro Labs USA," "Amoxicillin/Potassium Clav"  351507 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 20 0 1
    "Amoxicillin-Clavulanate Potass,Morton Grove Ph" "Amoxicillin/Potassium Clav"    7131 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 21 0 1
    "Amoxicillin-Clavulanate Potass,Morton Grove Ph" "Amoxicillin/Potassium Clav"   11142 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 21 0 1
    "Amoxicillin-Clavulanate Potass,Morton Grove Ph" "Amoxicillin/Potassium Clav"    7672 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 21 0 1
    "Amoxicillin-Clavulanate Potass,Northstar Rx Ll" "Amoxicillin/Potassium Clav"  512570 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 22 0 1
    "Amoxicillin-Clavulanate Potass,Northstar Rx Ll" "Amoxicillin/Potassium Clav"  603123 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 22 0 1
    "Amoxicillin-Clavulanate Potass,Northstar Rx Ll" "Amoxicillin/Potassium Clav"  502922 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 22 0 1
    "Amoxicillin-Clavulanate Potass,Sandoz"          "Amoxicillin/Potassium Clav" 2794166 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 23 0 1
    "Amoxicillin-Clavulanate Potass,Sandoz"          "Amoxicillin/Potassium Clav" 2320555 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 23 0 1
    "Amoxicillin-Clavulanate Potass,Sandoz"          "Amoxicillin/Potassium Clav" 1151934 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 23 0 1
    "Amoxicillin-Clavulanate Potass,Teva USA"        "Amoxicillin/Potassium Clav"  500764 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 24 0 1
    "Amoxicillin-Clavulanate Potass,Teva USA"        "Amoxicillin/Potassium Clav"  265598 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 24 0 1
    "Amoxicillin-Clavulanate Potass,Teva USA"        "Amoxicillin/Potassium Clav"  299806 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 24 0 1
    "Amoxicillin-Clavulanate Potass,West-Ward/Hikma" "Amoxicillin/Potassium Clav"  147199 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5  9 14 0 -2 25 0 1
    "Amoxicillin-Clavulanate Potass,West-Ward/Hikma" "Amoxicillin/Potassium Clav"  692029 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5  9 14 0 -1 25 0 1
    "Amoxicillin-Clavulanate Potass,West-Ward/Hikma" "Amoxicillin/Potassium Clav"  595475 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5  9 14 1  0 25 0 1
    "Anafranil"                                      "Clomipramine HCl"               469 2018 "Lorazepam"                   2020 0 1 0 0 24 10 19 0 -1 26 0 1
    "Anafranil"                                      "Clomipramine HCl"               441 2019 "Lorazepam"                   2020 1 0 1 0 24 10 19 0  0 26 0 1
    "Anafranil"                                      "Clomipramine HCl"               416 2020 "Lorazepam"                   2020 1 0 0 1 24 10 19 1  1 26 0 1
    "Apokyn"                                         "Apomorphine HCl"               4136 2018 "Fentalyn & Morphin"          2019 0 1 0 0  7 11  7 0 -1 27 1 0
    "Apokyn"                                         "Apomorphine HCl"               4423 2019 "Fentalyn & Morphin"          2019 1 0 1 0  7 11  7 1  0 27 1 0
    "Apokyn"                                         "Apomorphine HCl"               4543 2020 "Fentalyn & Morphin"          2019 1 0 0 1  7 11  7 0  1 27 1 0
    "App/Fresenius K"                                "Famotidine"                    1350 2018 "Pantoprazole"                2020 0 1 0 0 39 72 13 0 -2 28 0 1
    "App/Fresenius K"                                "Famotidine"                    1473 2019 "Pantoprazole"                2020 0 0 1 0 39 72 13 0 -1 28 0 1
    "App/Fresenius K"                                "Famotidine"                    1079 2020 "Pantoprazole"                2020 1 0 0 1 39 72 13 1  0 28 0 1
    "App/Premierpro"                                 "Famotidine/PF"                  676 2018 "Pantoprazole"                2020 0 1 0 0 41 71 13 0 -2 29 0 1
    "App/Premierpro"                                 "Famotidine/PF"                  459 2019 "Pantoprazole"                2020 0 0 1 0 41 71 13 0 -1 29 0 1
    "App/Premierpro"                                 "Famotidine/PF"                  838 2020 "Pantoprazole"                2020 1 0 0 1 41 71 13 1  0 29 0 1
    "Arixtra"                                        "Fondaparinux Sodium"            207 2018 "Bivalirudin"                 2020 0 1 0 0 45 12  3 0 -2 30 0 1
    "Arixtra"                                        "Fondaparinux Sodium"            156 2019 "Bivalirudin"                 2020 0 0 1 0 45 12  3 0 -1 30 0 1
    "Arixtra"                                        "Fondaparinux Sodium"            143 2020 "Bivalirudin"                 2020 1 0 0 1 45 12  3 1  0 30 0 1
    "Augmentin"                                      "Amoxicillin/Potassium Clav"     147 2019 "Piperacillin and Tazobactam" 2020 0 0 1 0  5 13 14 0 -1 31 0 1
    "Augmentin"                                      "Amoxicillin/Potassium Clav"      67 2020 "Piperacillin and Tazobactam" 2020 1 0 0 1  5 13 14 1  0 31 0 1
    "Augmentin,Dr.Reddy'S Lab"                       "Amoxicillin/Potassium Clav"     173 2018 "Piperacillin and Tazobactam" 2020 0 1 0 0  5 13 14 0 -2 32 0 1
    "Belbuca"                                        "Buprenorphine HCl"            51827 2018 "Fentalyn & Morphin"          2019 0 1 0 0  9 14  7 0 -1 33 1 0
    "Belbuca"                                        "Buprenorphine HCl"           130068 2019 "Fentalyn & Morphin"          2019 1 0 1 0  9 14  7 1  0 33 1 0
    "Belbuca"                                        "Buprenorphine HCl"           176630 2020 "Fentalyn & Morphin"          2019 1 0 0 1  9 14  7 0  1 33 1 0
    "Betamethasone Acetate-Sod Phos*"                ""                            873303 2020 "Dexamethasone"               2019 1 0 0 1  . 15  6 0  1 34 1 0
    "Bethkis"                                        "Tobramycin"                      45 2018 "Ampiciliin"                  2020 0 1 0 0 75 16  1 0 -2 35 0 1
    "Bethkis"                                        "Tobramycin"                      48 2019 "Ampiciliin"                  2020 0 0 1 0 75 16  1 0 -1 35 0 1
    "Bethkis"                                        "Tobramycin"                      53 2020 "Ampiciliin"                  2020 1 0 0 1 75 16  1 1  0 35 0 1
    end
    format %ty date
    format %ty civica_date
    label values Gnrc_Name_code Gnrc_Name_code
    label def Gnrc_Name_code 1 "Amikacin Sulfate", modify
    label def Gnrc_Name_code 2 "Amitriptyline HCl", modify
    label def Gnrc_Name_code 3 "Amoxapine", modify
    label def Gnrc_Name_code 4 "Amoxicillin", modify
    label def Gnrc_Name_code 5 "Amoxicillin/Potassium Clav", modify
    label def Gnrc_Name_code 7 "Apomorphine HCl", modify
    label def Gnrc_Name_code 9 "Buprenorphine HCl", modify
    label def Gnrc_Name_code 24 "Clomipramine HCl", modify
    label def Gnrc_Name_code 39 "Famotidine", modify
    label def Gnrc_Name_code 41 "Famotidine/PF", modify
    label def Gnrc_Name_code 42 "Fentanyl Citrate", modify
    label def Gnrc_Name_code 45 "Fondaparinux Sodium", modify
    label def Gnrc_Name_code 52 "Lidocaine HCl/PF", modify
    label def Gnrc_Name_code 72 "Spironolactone", modify
    label def Gnrc_Name_code 75 "Tobramycin", modify
    label values Brnd_Name_code Brnd_Name_code
    label def Brnd_Name_code 1 "Actiq", modify
    label def Brnd_Name_code 2 "Akten", modify
    label def Brnd_Name_code 3 "Aldactone", modify
    label def Brnd_Name_code 4 "Amikacin Sulfate", modify
    label def Brnd_Name_code 5 "Amitriptyline HCl", modify
    label def Brnd_Name_code 6 "Amoxapine", modify
    label def Brnd_Name_code 7 "Amoxicillin", modify
    label def Brnd_Name_code 8 "Amoxicillin-Clavulanate Pot ER", modify
    label def Brnd_Name_code 9 "Amoxicillin-Clavulanate Potass", modify
    label def Brnd_Name_code 10 "Anafranil", modify
    label def Brnd_Name_code 11 "Apokyn", modify
    label def Brnd_Name_code 12 "Arixtra", modify
    label def Brnd_Name_code 13 "Augmentin", modify
    label def Brnd_Name_code 14 "Belbuca", modify
    label def Brnd_Name_code 15 "Betamethasone Acetate-Sod Phos*", modify
    label def Brnd_Name_code 16 "Bethkis", modify
    label def Brnd_Name_code 71 "Famotidine", modify
    label def Brnd_Name_code 72 "Famotidine*", modify
    label values civica_altrantive_code civica_altrantive_code
    label def civica_altrantive_code 1 "Ampiciliin", modify
    label def civica_altrantive_code 3 "Bivalirudin", modify
    label def civica_altrantive_code 6 "Dexamethasone", modify
    label def civica_altrantive_code 7 "Fentalyn & Morphin", modify
    label def civica_altrantive_code 10 "Lidocaine", modify
    label def civica_altrantive_code 13 "Pantoprazole", modify
    label def civica_altrantive_code 14 "Piperacillin and Tazobactam", modify
    label def civica_altrantive_code 18 "metoprolol Tartrate", modify
    label def civica_altrantive_code 19 "Lorazepam", modify
    ------------------ copy up to and including the previous line ------------------


  • #2
    Well, you do not show us how you -xtset- your data, but if you did -xtset Gnrc_Name_code-, then I would expect exactly what you describe to happen. With -xtset Gnrc_Name_code-, the -xtreg- command uses the Gnrc_Name_code variable for the fixed effects. When you then specify i.Gnrc_Name_code in the list of explanatory/predictor variables, it is redundant: they are already there as the fixed effects and they can't be there twice. So they get dropped.

    Comment


    • #3
      Thank you, Clyde

      xtset -Brnd_Name. I dropped i.Gnrc_Name_code and run the regression, but the problem is still the same

      Comment


      • #4
        xtset -Brnd_Name. I dropped i.Gnrc_Name_code and run the regression, but the problem is still the same
        None of this is possible. Brnd_Name is a string variable, and -xtset- will not accept it. I presume you meant Brnd_Name_code.
        And if you drop i.Gnrc_Name_code, then the problem that all of those values were being omitted necessarily went away because you weren't even trying to include them any more. So something else must have gone wrong, but you don't say what. You need to be precise and specific in posing your questions in order to get useful advice. At this point, I'm not even sure what problem you are trying to solve.

        When I run the command you showed in #1 after -xtset Brnd_Name_code-, omitting i.Gnrc_Name , I get:

        Code:
        . xtreg Tot_Clms treatment_indicator##year  year2019 i.civica_altrantive_code ///
        >     , vce(cluster civica_altrantive_code)
        note: 0.treatment_indicator#1.year identifies no observations in the sample.
        note: 1.treatment_indicator#1.year omitted because of collinearity.
        note: 18.civica_altrantive_code omitted because of collinearity.
        
        Random-effects GLS regression                   Number of obs     =        100
        Group variable: Brnd_Name_~e                    Number of groups  =         18
        
        R-squared:                                      Obs per group:
             Within  = 0.0000                                         min =          1
             Between = 0.2632                                         avg =        5.6
             Overall = 0.1411                                         max =         24
        
                                                        Wald chi2(2)      =          .
        corr(u_i, X) = 0 (assumed)                      Prob > chi2       =          .
        
                                         (Std. err. adjusted for 9 clusters in civica_altrantive_code)
        ----------------------------------------------------------------------------------------------
                                     |               Robust
                       Tot_Clms_2017 | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -----------------------------+----------------------------------------------------------------
               1.treatment_indicator |  -1210.778   37647.82    -0.03   0.974    -74999.15    72577.59
                              1.year |   891.9718   36535.93     0.02   0.981    -70717.14    72501.09
                                     |
            treatment_indicator#year |
                                0 1  |          0  (empty)
                                1 1  |          0  (omitted)
                                     |
                            year2019 |  -4086.074   12549.27    -0.33   0.745     -28682.2    20510.05
                                     |
              civica_altrantive_code |
                        Bivalirudin  |  -6784.667   1.97e-11 -3.4e+14   0.000    -6784.667   -6784.667
                      Dexamethasone  |   871540.2   11842.79    73.59   0.000     848328.8    894751.7
                 Fentalyn & Morphin  |   38846.67   9.48e-11  4.1e+14   0.000     38846.67    38846.67
                          Lidocaine  |  -2400.333   9.15e-11 -2.6e+13   0.000    -2400.333   -2400.333
                       Pantoprazole  |   236202.9   1.99e-11  1.2e+16   0.000     236202.9    236202.9
        Piperacillin and Tazobactam  |     396208   1.32e-10  3.0e+15   0.000       396208      396208
                metoprolol Tartrate  |          0  (omitted)
                          Lorazepam  |    1243020   12549.27    99.05   0.000      1218424     1267616
                                     |
                               _cons |   7059.602   21710.73     0.33   0.745    -35492.64    49611.84
        -----------------------------+----------------------------------------------------------------
                             sigma_u |  998218.13
                             sigma_e |  626717.69
                                 rho |  .71726824   (fraction of variance due to u_i)
        ----------------------------------------------------------------------------------------------
        I see two problems in this. The first is the elimination of the treatment_indicator#year variable. The -xtreg- command you are running appears to be an attempt to do a difference-in-differences analysis (and your thread title confirms this). The problem is that you do not have appropriate data for a DID analysis:
        Code:
        . tab treatment_indicator year
        
        treatment_ |         year
         indicator |         0          1 |     Total
        -----------+----------------------+----------
                 0 |        58          0 |        58
                 1 |         9         33 |        42
        -----------+----------------------+----------
             Total |        67         33 |       100
        You have no observations for the control (treatment_indicator = 0) group in year 1. So you can't do a DID analysis with this data. In a DID analysis both the treatment and control groups have outcome measured both before and after the time when intervention begins. Now, you may have gathered the data in this way because, as you note in #1, some of the drugs got treated in 2018 and others in 2019, so you weren't sure how to define pre- and post- treatment times for the control group. That's the underlying reason why you do not have the makings of a DID design here.

        What you might be able to do instead is a generalized DID design. In that design, you use an under_treatment variable which is set to 1 when a given drug has received treatment, and 0 when it hasn't. Then you use under_treatment as your main variable (its coefficient will be the generalized DID estimator of treatment effect) in a drug-fixed-effects model along with i.date (not the 0/1 t_2019 variable) fixed effects. Then you get:
        Code:
        . xtreg Tot_Clms i.under_treatment i.date, fe vce(cluster civica_altrantive_code)
        
        Fixed-effects (within) regression               Number of obs      =       100
        Group variable: Brnd_Name_~e                    Number of groups   =        18
        
        R-sq:  Within  = 0.0005                         Obs per group: min =         1
               Between = 0.0190                                        avg =       5.6
               Overall = 0.0003                                        max =        24
        
                                                        F(3,8)             =      3.36
        corr(u_i, Xb)  = 0.0049                         Prob > F           =    0.0759
        
                              (Std. err. adjusted for 9 clusters in civica_altrantive_code)
        -----------------------------------------------------------------------------------
                          |               Robust
            Tot_Clms_2017 | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        ------------------+----------------------------------------------------------------
        1.under_treatment |  -12499.09   35127.81    -0.36   0.731    -93503.97    68505.79
                          |
                     date |
                    2019  |   29677.89   12338.35     2.41   0.043     1225.606    58130.18
                    2020  |    26427.2   29664.61     0.89   0.399    -41979.52    94833.92
                          |
                    _cons |   510547.2   19717.84    25.89   0.000     465077.8    556016.6
        ------------------+----------------------------------------------------------------
                  sigma_u |  897462.72
                  sigma_e |   630529.9
                      rho |  .66952157   (fraction of variance due to u_i)
        -----------------------------------------------------------------------------------
        The second problem you have in the code as you had it (but not in what I have just shown immediately above because I didn't try to include it) is the omission of one value of the civica_altrantive_code variable. Well, you just can't include that variable in the model. In your data (at least in the example data, and I assume in the full data set) civica_altrantive_code is a time-invariant attribute of the brand name. So it is colinear with the Brnd_Name_code fixed effects and its values drop out. This is the same type of problem I pointed out in #2. You can never estimate the effects of a variable that does not vary within the panel fixed effect when running a fixed-effects analysis. It is a mathematical impossibility, so don't bother trying to work around it. Moreover, there is no point in trying to include such a variable, even if it were possible. That's because whatever effect it might have is, in a fixed effects model, automatically adjusted for by the panel fixed effects themselves. Otherwise put, civica_altrantive_code has no information that is not already present in Brnd_Name_code, so any effect it has is already taken care of by the Brnd_Name_code indicators, which are themselves covered by the -fe- in the command.




        Comment


        • #5
          Thank you so much, Clyde, for your helpful comment.

          Comment

          Working...
          X