Announcement

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

  • Clustering standard errors on Dummies

    Hello all,

    I am estimating a first differences model of the following form for 16 countries and 12 time periods: ΔYit = ß0 + ß1ΔXit + øt + λR + ɛit

    ΔYit is the change in the manufacturing share in country i between year t and t+1.
    ΔXit is the change in import exposure in country i between year t and t+1.
    Vector λR contains five dummies for different parts of Europe (e.g. Dummy north is equal to 1 if the country is Sweden, Denmark, or Norway, and zero otherwise)


    Code:
    xtset year
    xtreg diff_y diff_x north east south west central, r
    Related literature uses standard errors clustered on these regions, i.e., clustered on these different dummies (north, east, south, west, central).

    How do I incorporate this into my code?

    Thank you!
    Last edited by Cla Tuor; 29 Dec 2021, 12:22.

  • #2
    Cla:
    first, you should create a single categorical variable called -region- with different level (one per each geographic zone).
    Then you can go:
    Code:
    xtset countries year
    xtreg diff_y diff_x north i.region, vce(cluster region)
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Carlo Lazzaro Thank you!

      Would you please elaborate on how I have to do the first step?

      And why did you add country to the xtset command? Since I use FD I do not have country fixed-effects.



      Comment


      • #4
        I can't comment on much without an example dataset, but what I would do here is

        Code:
        * Just an example, adapt to your purposes
        g region = .
        
        replace regionname = "North" if inlist(country,1,2)
        
        replace regionname = "South" if inlist(country,3,4)
        
        egen region = group(regionname)
        
        drop regionname
          
         xtset countries year xtreg diff_y diff_x north i.region, vce(cluster region)

        If I understand you well, you simply want to cluster SEs on your regions. Make a unique ID for these regions, then cluster on them in xtreg.
        Last edited by Jared Greathouse; 29 Dec 2021, 13:00. Reason: Meant to drop the now-useless original region variable.

        Comment


        • #5
          You add country to the xtset command because you have a panel of countries and want to tell this to Stata.

          Comment


          • #6
            I think Jared Greathouse means to say -drop regionname-, not -drop region- in #4.

            Comment


            • #7
              Good catch!! Indeed I did mean to say -drop regionnname- Clyde Schechter

              Comment


              • #8
                Cla:
                Clyde and Jared reached the party sooner than me and replied brilliantly.
                1) -xtset-ting your dataset with -timevar- is a bad idea, as Stata is forced to consider it as your -panelid- (which is -country-, in fact);
                2) running -xtreg,re- instead of -xtreg,fe- is not a waiver for not to -xtset- your data properly as your first step.
                Kind regards,
                Carlo
                (StataNow 18.5)

                Comment


                • #9
                  Unfortunately, it is not clear to me yet how to proceed.

                  You can find an abstract of my dataset in the table below: 16 countries and six different regions.

                  Do I have to create dummies for these six different regions first? Or can I directly proceed with the code above?

                  Do you think you could update the code to my dataset, as I cannot follow it? E.g., what do the numbers stand for in the bracket after inlist?

                  Thank you, and please bear with me as I am new to STATA.

                  country region
                  Austria ger
                  Belgium ben
                  Denmark sca
                  Finland sca
                  France ben
                  Germany ger
                  Greece med
                  Ireland bi
                  Italy med
                  Netherlands ben
                  Norway sca
                  Portugal ibe
                  Spain ibe
                  Sweden sca
                  Switzerland ger
                  UK bi

                  Comment


                  • #10
                    Cla Tuor All you do here is
                    Code:
                    egen regionid = group(region)
                    I didn't know how your data look, so I couldn't do anything but give a toy example, but since you already have a region variable defined, you just use the syntax I give here in this post.

                    We'd be able to help you much easier if you used dataex to give an example of what your real data look like.

                    egen here gives a unique ID to each region that should apply to any nation that has the same regional name.

                    Comment


                    • #11
                      It worked! Thank you for your help!

                      Comment

                      Working...
                      X