Announcement

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

  • Define unit of analysis in a Panel Data with DID

    Hi everyone,

    I am trying to carry out a DID with panel data using the command xtdidregress. There are thre pre-treatment periods and three post-treatment periods. I have two countries, and within each country multiple companies, however, only the companies from one country receive the treatment >=2018. My biggest challenge is running the xtdidregress, as I either get the error of repeated time values witin panel or incorrect group() specification.



    Which unit of analysis makes more sense to take? In other words, should I move from firm-level to country level and how do I do that? for xtset command

    Code:
    gen id = _n
    order id
    reshape long x , i(id) j(year)
    rename x esgscore
    
    egen panel_id = group (id year)
    
    xtset panel_id year
    
    g lCompanysize=ln(Companysize)
    g post= year>=2018
    g treated = Country == "treatecountry"
    g posttreated = post*treated

    Thank you all tons in advance!
    Last edited by Rina Vel; 15 Jul 2023, 07:51.

  • #2
    I would conduct the analysis on a company level, so a company level two-way-fixed effects. I would also cluster standard errors, in your case, on a company level.

    You could try a multi-level model using the command mixed.

    Papke and Wooldridge have written a paper on the level of the fixed-effect to control for. If I find it I'll let you know.

    Comment


    • #3
      Hi Maxence,

      Thank you for your reply.

      Are you saying I should run a firm and time fixed effects?

      Could you present it roughly in stata?

      Thank you in advance!

      Comment


      • #4
        Code:
        xtset firm year
        
        xtreg outcome controls treated#post, cluster(firm)

        Comment


        • #5
          I ran this but it says no observations.

          Code:
          gen firm = _n
          order firm
          reshape long x , i(firm) j(year)
          rename x esgscore
          xtset firm year
          g lCompanysize=ln(Companysize)
          g post= year>=2018
          g treated = Country == "treatedcountryname"
          xtreg esgscore Industry lCompanysize treated#post, cluster(firm)
          Last edited by Rina Vel; 15 Jul 2023, 08:52.

          Comment


          • #6
            In other for us to really help you, show us your wide data that you appear to be reshaping

            Comment


            • #7
              Here is a short version of the wide data. Apologies for the many decimals, I changed the format to two %2.1fc but dataex still showing them.
              However, hope this dataex makes my data and my point clear.

              Company size (total assets), employees and Industry are control variables.

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input str25 CompanyName str11 Country double(x2020 x2019 x2018 x2017 x2016 x2015) long Employees str32 Industry double Companysize
              "Bayer AG"                  "Germany"     90.6657897727993 89.1229700755766 89.6513776350617 84.5258418659235 82.9239367709559 74.9506794871111 101369 "Pharmaceuticals"                       1.24877e+11
              "Beiersdorf AG"             "Germany"     62.5551288137393 63.4967300878465 62.5258271393716 59.2129141171354 54.0533418449871 56.1198599714869  21401 "Personal Care Products"                 1.2348e+10
              "Bilfinger SE"              "Germany"     70.1827709867488 68.5112377294931 70.4913841899759 71.4534828282375 63.5691359519145 69.8584277749703  30309 "Commercial Services & Supplies"          3.052e+09
              "Hugo Boss AG"              "Germany"      86.981829836204  86.180507607644 88.2313392567014 74.7499353614545  74.312616026742 72.3755276855487  16930 "Textiles, Apparel & Luxury Goods"       3126602000
              "Zurich Insurance Group AG" "Switzerland" 87.7477461475956  83.889526070865 79.7112289702673 66.9166034856785  67.859389232716 61.1959545753086  59498 "Insurance"                            352999500800
              "GAM Holding AG"            "Switzerland" 65.0740237526076 54.6634915328194 56.4257261428047 37.3875142248359 35.1285618834538 41.3541946627452    541 "Capital Markets"                  356717611.423626
              "OC Oerlikon Corp."         "Switzerland" 53.5866635278245 47.5209521011017 47.5050359423704 47.7116348217156 46.2677037051513 48.1458482360531  12184 "Machinery"                        3979589787.97058
              "Ems Chemie Holding AG"     "Switzerland" 35.4342133917283 33.4143865183697 22.1999083944094  21.850806380752 22.4783511535177 21.2008935198761   2693 "Chemicals"                         2341054089.1389
              "Georg Fischer AG"          "Switzerland" 74.8807562337898 76.5205151995843 74.8490853680764 73.5418784325318  76.597173184077 74.6863317347426  15207 "Machinery"                        3738004327.13111
              end
              Thanks a lot!

              Comment


              • #8
                This computes for me.
                Code:
                * Example generated by -dataex-. For more info, type help dataex
                clear
                input str25 CompanyName str11 Country double(x2020 x2019 x2018 x2017 x2016 x2015) long Employees str32 Industry double Companysize
                "Bayer AG"                  "Germany"     90.6657897727993 89.1229700755766 89.6513776350617 84.5258418659235 82.9239367709559 74.9506794871111 101369 "Pharmaceuticals"                       1.24877e+11
                "Beiersdorf AG"             "Germany"     62.5551288137393 63.4967300878465 62.5258271393716 59.2129141171354 54.0533418449871 56.1198599714869  21401 "Personal Care Products"                 1.2348e+10
                "Bilfinger SE"              "Germany"     70.1827709867488 68.5112377294931 70.4913841899759 71.4534828282375 63.5691359519145 69.8584277749703  30309 "Commercial Services & Supplies"          3.052e+09
                "Hugo Boss AG"              "Germany"      86.981829836204  86.180507607644 88.2313392567014 74.7499353614545  74.312616026742 72.3755276855487  16930 "Textiles, Apparel & Luxury Goods"       3126602000
                "Zurich Insurance Group AG" "Switzerland" 87.7477461475956  83.889526070865 79.7112289702673 66.9166034856785  67.859389232716 61.1959545753086  59498 "Insurance"                            352999500800
                "GAM Holding AG"            "Switzerland" 65.0740237526076 54.6634915328194 56.4257261428047 37.3875142248359 35.1285618834538 41.3541946627452    541 "Capital Markets"                  356717611.423626
                "OC Oerlikon Corp."         "Switzerland" 53.5866635278245 47.5209521011017 47.5050359423704 47.7116348217156 46.2677037051513 48.1458482360531  12184 "Machinery"                        3979589787.97058
                "Ems Chemie Holding AG"     "Switzerland" 35.4342133917283 33.4143865183697 22.1999083944094  21.850806380752 22.4783511535177 21.2008935198761   2693 "Chemicals"                         2341054089.1389
                "Georg Fischer AG"          "Switzerland" 74.8807562337898 76.5205151995843 74.8490853680764 73.5418784325318  76.597173184077 74.6863317347426  15207 "Machinery"                        3738004327.13111
                end
                cls
                
                gen firm = _n
                order firm
                reshape long x , i(firm) j(year)
                rename x esgscore
                g treat = cond(Country == "Germany" & year >= 2018,1,0)
                xtset firm year
                g lCompanysize=ln(Companysize)
                
                xtdidregress (esgscore) (treat), group(firm) time(year)

                Comment


                • #9
                  Thank you for your answer Jared, it was really helpful!

                  Moreover, is there a way I can add a control variable(lcompanysize) with xtdidregress?

                  Comment

                  Working...
                  X