Announcement

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

  • Difference-in-difference with three time periods

    Dear all,

    I am working on my bachelor essay and I have to use stata for a regression. My topic is the difference of impact of the Olympic and the Paralympic games on tourism. In previous literature, it's common to use the gravity model but it is not possible here due to the data available.
    I want to run a diff-in-diff with three time periods to compare the time before, during and after the event. The dependant variable is the tourist arrivals, We have a dummy variable for the threatment group, =1 for greece, the hosting country and =0 for the control groups which are spain, croatia and
    italy. Time is showed by the monthly variable timeOG, and =0 for the period before the Olympics, =1 during the Olympics in august and =2 for after the Olympics, as you can see on the screenshot of our data.

    Click image for larger version

Name:	data.PNG
Views:	2
Size:	53.4 KB
ID:	1494759

    Our main problem is that stata considers that timeOG is a binary variable and does the diff-in-diff only between the time before and the time during the event. Is it possible to have a difference between three periods or not ?
    Futhermore, I would like to control for country fixed effect, but I don't know how to do it. Does anyone have a clue?

    Click image for larger version

Name:	Capture.PNG
Views:	2
Size:	18.6 KB
ID:	1494758

    Click image for larger version

Name:	tab.PNG
Views:	2
Size:	4.1 KB
ID:	1494757

    I'm quite new to stata so Don't hesitate to tell me if my question is futile or if the method I want to use is not the right one.
    Thank you all.

  • #2
    The -diff- command will not accommodate three time periods. But you can do the DID analysis directly with native Stata commands.

    Please read the FAQ, emphasizing #12, for excellent advice about how to most effectively show example data (the -dataex- command) and Stata code or output (code delimiters). Among the things you will learn there is that screen shots are strongly discouraged. Your screen shot of your data, for example, is not readable on my computer. Even if it were, it would not be possible for me to import data from a screen shot into Stata to check code on it. That's why we ask people to use -dataex- to post example data. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    That said, from the output of -diff- that you show, it looks like your code will need to be something like this:

    Code:
    xtset country year
    xtreg touristarrivals i.treated##i.timeOG, fe
    You may want to include other covariates in the equation. But that is the basic approach. The coefficients of 1.treated#1.timeOG and 1.treated#2.timeOG will be the DID estimators of the effects during those two time periods (compared to period 0).

    Comment


    • #3
      Thank you for the help: So I did what you adviced me to do and I included control variables for population and GDP.
      Here are our data as you couldn't see it before :

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str7 country str3 month long touristarrival byte(countrynum treated monthnum time) long pop double(Gdpccurrent GDPpcconstant) float(lnta lngdp lnpop)
      "grece"   "jan"  305058 1 1  1 0 11270  22007.85 27614.405934628227 12.628257  9.999154    9.3299
      "grece"   "feb"  332590 1 1  2 0 11270  22007.85 27614.405934628227 12.714665  9.999154    9.3299
      "grece"   "mar"  443823 1 1  3 0 11270  22007.85 27614.405934628227 13.003181  9.999154    9.3299
      "grece"   "apr"  446981 1 1  4 0 11270  22007.85 27614.405934628227  13.01027  9.999154    9.3299
      "grece"   "maj"  509494 1 1  5 0 11270  22007.85 27614.405934628227 13.141173  9.999154    9.3299
      "grece"   "jun"  541285 1 1  6 0 11270  22007.85 27614.405934628227   13.2017  9.999154    9.3299
      "grece"   "jul"  719763 1 1  7 0 11270  22007.85 27614.405934628227 13.486677  9.999154    9.3299
      "grece"   "aug"  704037 1 1  8 1 11270  22007.85 27614.405934628227 13.464586  9.999154    9.3299
      "grece"   "sep"  521566 1 1  9 2 11270  22007.85 27614.405934628227  13.16459  9.999154    9.3299
      "grece"   "okt"  444539 1 1 10 3 11270  22007.85 27614.405934628227 13.004793  9.999154    9.3299
      "grece"   "nov"  372290 1 1 11 3 11270  22007.85 27614.405934628227  12.82743  9.999154    9.3299
      "grece"   "dec"  329095 1 1 12 3 11270  22007.85 27614.405934628227 12.704102  9.999154    9.3299
      "espagne" "jan" 2225018 2 0  1 0 43352 24981.314 30504.357430610315 14.615275 10.125883 10.677108
      "espagne" "feb" 2819695 2 0  2 0 43352 24981.314 30504.357430610315  14.85214 10.125883 10.677108
      "espagne" "mar" 3205472 2 0  3 0 43352 24981.314 30504.357430610315  14.98037 10.125883 10.677108
      "espagne" "apr" 4071636 2 0  4 0 43352 24981.314 30504.357430610315 15.219556 10.125883 10.677108
      "espagne" "maj" 3777714 2 0  5 0 43352 24981.314 30504.357430610315  15.14463 10.125883 10.677108
      "espagne" "jun" 4450719 2 0  6 0 43352 24981.314 30504.357430610315 15.308577 10.125883 10.677108
      "espagne" "jul" 5475058 2 0  7 0 43352 24981.314 30504.357430610315 15.515714 10.125883 10.677108
      "espagne" "aug" 6798045 2 0  8 1 43352 24981.314 30504.357430610315 15.732145 10.125883 10.677108
      "espagne" "sep" 4572667 2 0  9 2 43352 24981.314 30504.357430610315 15.335608 10.125883 10.677108
      "espagne" "okt" 4048570 2 0 10 3 43352 24981.314 30504.357430610315 15.213874 10.125883 10.677108
      "espagne" "nov" 2946179 2 0 11 3 43352 24981.314 30504.357430610315  14.89602 10.125883 10.677108
      "espagne" "dec" 3008580 2 0 12 3 43352 24981.314 30504.357430610315  14.91698 10.125883 10.677108
      "croatie" "jan"   58603 3 0  1 0  4384  9354.099  12583.81371783059  10.97854   9.14357  8.385716
      "croatie" "feb"   68763 3 0  2 0  4384  9354.099  12583.81371783059  11.13842   9.14357  8.385716
      "croatie" "mar"   82901 3 0  3 0  4384  9354.099  12583.81371783059 11.325402   9.14357  8.385716
      "croatie" "apr"  110317 3 0  4 0  4384  9354.099  12583.81371783059 11.611114   9.14357  8.385716
      "croatie" "maj"  157035 3 0  5 0  4384  9354.099  12583.81371783059 11.964224   9.14357  8.385716
      "croatie" "jun"  161618 3 0  6 0  4384  9354.099  12583.81371783059  11.99299   9.14357  8.385716
      "croatie" "jul"  164309 3 0  7 0  4384  9354.099  12583.81371783059 12.009504   9.14357  8.385716
      "croatie" "aug"  149632 3 0  8 1  4384  9354.099  12583.81371783059 11.915935   9.14357  8.385716
      "croatie" "sep"  127071 3 0  9 2  4384  9354.099  12583.81371783059 11.752501   9.14357  8.385716
      "croatie" "okt"  110785 3 0 10 3  4384  9354.099  12583.81371783059 11.615347   9.14357  8.385716
      "croatie" "nov"   80980 3 0 11 3  4384  9354.099  12583.81371783059 11.301957   9.14357  8.385716
      "croatie" "dec"   69842 3 0 12 3  4384  9354.099  12583.81371783059  11.15399   9.14357  8.385716
      "italie"  "jan" 2744638 4 0  1 0 58495 31239.993  37070.33051554522  14.82516 10.349454 10.976697
      "italie"  "feb" 2901676 4 0  2 0 58495 31239.993  37070.33051554522   14.8808 10.349454 10.976697
      "italie"  "mar" 3261262 4 0  3 0 58495 31239.993  37070.33051554522 14.997624 10.349454 10.976697
      "italie"  "apr" 3906496 4 0  4 0 58495 31239.993  37070.33051554522  15.17815 10.349454 10.976697
      "italie"  "maj" 4309394 4 0  5 0 58495 31239.993  37070.33051554522 15.276308 10.349454 10.976697
      "italie"  "jun" 5129094 4 0  6 0 58495 31239.993  37070.33051554522  15.45044 10.349454 10.976697
      "italie"  "jul" 6307829 4 0  7 0 58495 31239.993  37070.33051554522 15.657302 10.349454 10.976697
      "italie"  "aug" 7416121 4 0  8 1 58495 31239.993  37070.33051554522 15.819167 10.349454 10.976697
      "italie"  "sep" 4330640 4 0  9 2 58495 31239.993  37070.33051554522 15.281226 10.349454 10.976697
      "italie"  "okt" 3420121 4 0 10 3 58495 31239.993  37070.33051554522 15.045186 10.349454 10.976697
      "italie"  "nov" 2525372 4 0 11 3 58495 31239.993  37070.33051554522 14.741899 10.349454 10.976697
      "italie"  "dec" 2988186 4 0 12 3 58495 31239.993  37070.33051554522 14.910177 10.349454 10.976697
      end
      I did the DiD you adviced and I found this :

      Code:
      . xtreg lnta i.treated##i.time lngdp lnpop i.monthnum, r
      note: 8.monthnum omitted because of collinearity
      note: 9.monthnum omitted because of collinearity
      note: 12.monthnum omitted because of collinearity
      
      Random-effects GLS regression                   Number of obs     =         48
      Group variable: countrynum                      Number of groups  =          4
      
      R-sq:                                           Obs per group:
           within  = 0.9270                                         min =         12
           between = 1.0000                                         avg =       12.0
           overall = 0.9970                                         max =         12
      
                                                      Wald chi2(3)      =          .
      corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =          .
      
                                   (Std. Err. adjusted for 4 clusters in countrynum)
      ------------------------------------------------------------------------------
                   |               Robust
              lnta |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
         1.treated |   2.086073   .0249007    83.78   0.000     2.037268    2.134877
                   |
              time |
                1  |   .9967446   .0755138    13.20   0.000     .8487402    1.144749
                2  |    .630774   .1001011     6.30   0.000     .4345796    .8269685
                3  |    .156376   .0825976     1.89   0.058    -.0055123    .3182643
                   |
      treated#time |
              1 1  |  -.1023788   .1172945    -0.87   0.383    -.3322719    .1275142
              1 2  |  -.0364037   .0492117    -0.74   0.459    -.1328568    .0600495
              1 3  |   .0125107   .0694728     0.18   0.857    -.1236534    .1486748
                   |
             lngdp |   -4.62987   7.01e-11 -6.6e+10   0.000     -4.62987    -4.62987
             lnpop |    3.54758   3.17e-11  1.1e+11   0.000      3.54758     3.54758
                   |
          monthnum |
                2  |   .1346979   .0506553     2.66   0.008     .0354153    .2339805
                3  |    .314836   .0598446     5.26   0.000     .1975428    .4321293
                4  |   .4929645   .0912544     5.40   0.000     .3141092    .6718198
                5  |   .6197753   .1541117     4.02   0.000      .317722    .9218286
                6  |   .7266185   .1239551     5.86   0.000     .4836709    .9695662
                7  |   .9054909   .0552301    16.39   0.000     .7972419     1.01374
                8  |          0  (omitted)
                9  |          0  (omitted)
               10  |   .2984879   .0833861     3.58   0.000     .1350541    .4619217
               11  |    .020514   .0915353     0.22   0.823    -.1588919    .1999199
               12  |          0  (omitted)
                   |
             _cons |   23.68036   .0698561   338.99   0.000     23.54344    23.81728
      -------------+----------------------------------------------------------------
           sigma_u |          0
           sigma_e |  .10713621
               rho |          0   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      I interpreted the result as :
      - 1.treated is the mean difference between the control and the treament group before the Olympics.
      - 1.1treated#time = -0.102 means that the tourist arrivals decreased in august, at the time of the Olympics, compared to the time before (time=0) in the hosting country by 10%

      Is that a corrected interpretation or am I completly wrong ?

      Thank you for the help

      Comment


      • #4
        I'm a little confused about your time variable. Your -diff- output in #1 suggests that time is a three level variable coded 0/1/2. But the output and data in #3 show a four-level time variable, coded 0/1/2/3.

        Anyway, the interpretation of 1.treated#1.time = -0.102 is that the change in tourist arrivals in Greece during the interval for which time is coded as 1 (perhaps that is when they had the Olympics) compared to tourist arrivals there during the interval when time = 0, was 10% less than the corresponding change in tourist arrivals in the other countries over that same period. A simpler, less verbose way to say that is that the effect of the Olympics on Greek tourism was a change of approximately 10% less than the corresponding change in other countries over the same time period. Since the coefficient of 1.time itself is positive, at about 1, this actually corresponds to tourist arrivals increasing by a factor of about 2.72 in the other countries, but increasing by only a factor of about 2.45 in Greece. (2.45 is about 90% of 2.72).

        Added: I just noticed a few things about your regression. You did this as a random effects regression. With only four groups, you are not getting an adequate sample of region-space to have usable estimates of variance at the region level. So a fixed effects model is preferable. Also, the effect you are trying to estimate is a within-region effect, so it is properly modeled with fixed, rather than random, effects anyway.

        And also with only four groups, you cannot use the cluster robust standard errors--they are only valid with a large number of groups. (There is not universal agreement on how large a number is required, but I think everyone agrees four is too few.)
        Last edited by Clyde Schechter; 25 Apr 2019, 13:10.

        Comment

        Working...
        X