Announcement

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

  • Country-year fixed effect

    Dear All,

    I have a dataset like the following:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(wlnyw pc id time) str30 country
            . 1 2  2 "Albania"
     8.160519 1 2  3 "Albania"
     8.144518 1 2  4 "Albania"
     8.070906 6 2  5 "Albania"
     7.988668 6 2  6 "Albania"
     8.239983 8 2  7 "Albania"
     8.476371 9 2  8 "Albania"
     8.750808 9 2  9 "Albania"
     8.779557 9 2 10 "Albania"
    8.7427435 1 3  2 "Algeria"
     8.884125 1 3  3 "Algeria"
     8.911485 1 3  4 "Algeria"
     8.790486 7 3  5 "Algeria"
     8.667766 6 3  6 "Algeria"
     8.663796 6 3  7 "Algeria"
     8.758355 6 3  8 "Algeria"
     8.804875 6 3  9 "Algeria"
     8.896683 6 3 10 "Algeria"
            . 1 6  2 "Angola"  
            . 1 6  3 "Angola"  
     8.554934 1 6  4 "Angola"  
     8.581732 1 6  5 "Angola"  
     8.166536 . 6  6 "Angola"  
     8.358969 6 6  7 "Angola"  
     8.443862 8 6  8 "Angola"  
     8.829568 8 6  9 "Angola"  
     8.873868 8 6 10 "Angola"  
     9.433484 7 8  2 "Argentina"
     9.512621 1 8  3 "Argentina"
     9.315701 7 8  4 "Argentina"
     9.159047 9 8  5 "Argentina"
     9.461655 9 8  6 "Argentina"
     9.476044 9 8  7 "Argentina"
     9.487972 9 8  8 "Argentina"
     9.689914 9 8  9 "Argentina"
     9.706778 9 8 10 "Argentina"
            . 1 9  2 "Armenia"
            . 1 9  3 "Armenia"
            . 1 9  4 "Armenia"
     7.931144 2 9  5 "Armenia"
     7.438384 7 9  6 "Armenia"
     7.673223 8 9  7 "Armenia"
     8.255829 7 9  8 "Armenia"
     8.444622 7 9  9 "Armenia"
     8.612503 7 9 10 "Armenia"
    end
    I estimate a panel data model using

    Code:
    xtreg wlnyw pc i.time, fe r
    I would also like to include country-year fixed effect, assuming that time shocks affect countries in a specific way. I am still confused about how to do that.

    I tried

    Code:
    egen ct=group(id time)
    tab ct, gen(countryyear)
    However this generates 45 dummies (exactly the number of observations I have in the data example above. I am not sure this is the right way to proceed. What if I do the following?

    Code:
    gen idtime=id*time
    
    xtreg wlnyw pc idtime i.time, fe r
    Which is the correct way to proceed?

    Thanks in advance.

  • #2
    First, I would check whether your dataset ise feasible for -xtreg-.
    When applied to your example, -xttest0- gives back the following result:
    Code:
    Breusch and Pagan Lagrangian multiplier test for random effects
    
            wlnyw[id,t] = Xb + u[id] + e[id,t]
    
            Estimated results:
                             |       Var     sd = sqrt(Var)
                    ---------+-----------------------------
                       wlnyw |    .304553       .5518632
                           e |   .0259054       .1609514
                           u |          0              0
    
            Test:   Var(u) = 0
                                 chibar2(01) =     0.00
                              Prob > chibar2 =   1.0000
    If that were the case with your whole dataset, you should consider switching to pooled OLS with standard errors clustered on -panelid-.

    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Hi dmaimone (is that your real name? ),

      Looking at the dataset you posted, you have 45 different time-country combinations (5 countries, 9 time-stamps). So in my understanding, you should get 45 dummies. What am I missing?

      Comment


      • #4
        Thanks both for your replies. The data I posted are only an example of my entire dataset. It contains 150 countries over 9 time periods. This means that when I try to generate country-year fixed effects, I gen about 1500 additional regressors, which in my view appears to be insane! My doubt was on whether the way to generate the country-year dummies I exposed in my post is correct or not. If that is correct, then I should rethink a little bit what I am doing, since the estimation I want to carry out is simply a robustness check and is not my main result.

        By the way, yes. That is my real name dmaimone= Dario Maimone

        Comment


        • #5
          If you have country-year data, you can't generate an interaction of country and year since this would automatically perfectly fit the data - 150*9 parameters to fit 150*9 observations. It is more common to include i.year as a separate control using country as the panel in xtreg.

          Comment


          • #6
            Phil Bromiley Thanks for your suggestion Phil. Indeed, I have used time fixed effects. As I mentioned earlier, I wanted to include also country*year fixed effects as a further robustness check. However, I understood your suggestion and I will include only country and year fixed effects separately.

            Comment


            • #7
              Hi, may I know how do I create year-month * country fixed effect? My year-month variable is in '2010Jan' form, and i try to create by adding i.country*yearmonth, and no observation is produced. Thank you so much!

              Comment


              • #8
                Originally posted by Carlo Lazzaro View Post
                First, I would check whether your dataset ise feasible for -xtreg-.
                When applied to your example, -xttest0- gives back the following result:
                Code:
                Breusch and Pagan Lagrangian multiplier test for random effects
                
                wlnyw[id,t] = Xb + u[id] + e[id,t]
                
                Estimated results:
                | Var sd = sqrt(Var)
                ---------+-----------------------------
                wlnyw | .304553 .5518632
                e | .0259054 .1609514
                u | 0 0
                
                Test: Var(u) = 0
                chibar2(01) = 0.00
                Prob > chibar2 = 1.0000
                If that were the case with your whole dataset, you should consider switching to pooled OLS with standard errors clustered on -panelid-.
                Carlo:
                the Breusch and Pagan Lagrangian multiplier test is meant to choose between RE and Pooled, right?

                Comment


                • #9
                  Duccio:
                  correct.
                  Kind regards,
                  Carlo
                  (Stata 18.0 SE)

                  Comment

                  Working...
                  X