Announcement

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

  • The effects of brexit on fdi comparing uk and EU27 countries. using difference in difference estimation technique

    Hey everyone, please i have been struggling to model my DID estimation on stata for my dissertation which i have a deadline on the 5th of january. and my supervisor is not responding to his emails because his on holiday. i really need help.

    so basically what i am trying to do is too understand the pre and post effect of brexit (policy change) on fdi between uk and EU27 countries.
    these are what i am too achieve;
    DID estimation
    graphical diagnostics and test (parallel trend)
    standard error considerations
    default cluster-robust standard error

    my data is also a longitudinal panel dataset from 2000-2019 . it is strongly balance but any time i try to model the DID estimation i always have problem with the treatment variable or group variable on stata.

  • #2
    . dataex country countryid years FDI GDP lnGDP lnFDI post

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str3 country byte countryid int years double(FDI GDP) float(lnGDP lnFDI post)
    "AUT"  1 2000           1108.004   196799778883.361 26.005453  7.010315 0
    "BEL"  2 2000            207.387 236204532891.10007 26.187963  5.334587 0
    "BGR"  3 2000             13.452 13245833843.545425  23.30695  2.599128 0
    "HRV"  4 2000                  0 21839780971.026768    23.807         . 0
    "CYP"  5 2000            185.076  9985844486.333649 23.024435  5.220767 0
    "CZE"  6 2000                  0 164158739097.62344   25.8241         . 0
    "DNK"  7 2000                  0   61828166496.0941 24.847626         . 0
    "EST"  8 2000                  0  5686579747.535244 22.461374         . 0
    "FIN"  9 2000 1686.5700000000002  125706651925.5574 25.557217  7.430452 0
    "FRA" 10 2000         121058.692 1362248940482.7715  27.94016  11.70403 0
    "DEU" 11 2000 54997.630000000005 1943145384190.1604  28.29533 10.915046 0
    "GRC" 12 2000                  0    130133845586.88  25.59183         . 0
    "HUN" 13 2000 14.943999999999999  47218405892.42581  24.57805   2.70431 0
    "IRL" 14 2000           5765.193   99958806891.4686 25.328024  8.659594 0
    "ITA" 15 2000           4313.624  1143829832319.882 27.765404  8.369534 0
    "LVA" 16 2000                  0  7958852838.933951  22.79755         . 0
    "LTU" 17 2000                  0 11524776866.637894 23.167765         . 0
    "LUX" 18 2000           1041.477 21177470978.441128 23.776203  6.948395 0
    "MLT" 19 2000                  0  4069515579.071135  22.12679         . 0
    "NLD" 20 2000          69030.557  416442786069.6518 26.755014 11.142304 0
    "POL" 21 2000             70.133 172219461126.06705 25.872036 4.2503934 0
    "PRT" 22 2000                  0 118310710337.20288  25.49658         . 0
    "ROU" 23 2000                  0  37253259016.99756 24.341005         . 0
    "SVK" 24 2000                  0 20289627636.676712 23.733376         . 0
    "SVN" 25 2000                  0  29169953012.71421 24.096405         . 0
    "ESP" 26 2000                  0  596877648793.0718  27.11498         . 0
    "SWE" 27 2000                  0  262835454366.8551 26.294794         . 0
    "GBR" 28 2000          83349.481  1662127402027.538  28.13912 11.330797 0
    "AUT"  1 2001            343.799  197337879194.6309  26.00818  5.840057 0
    "BEL"  2 2001            -33.127  236541297539.1499  26.18939         . 0
    "BGR"  3 2001                  0 14183497963.107063 23.375345         . 0
    "HRV"  4 2001                  0 23273640257.196846 23.870586         . 0
    "CYP"  5 2001            258.161 10397897085.610199  23.06487  5.553584 0
    "CZE"  6 2001             23.187 164791442543.37482 25.827946  3.143592 0
    "DNK"  7 2001 6017.1900000000005  67808032979.54291 24.939947  8.702375 0
    "EST"  8 2001                  0  6254649538.984872  22.55659         . 0
    "FIN"  9 2001           1609.682 129421029082.77406 25.586336  7.383792 0
    "FRA" 10 2001          63717.324 1376465324384.7876  27.95054 11.062212 0
    "DEU" 11 2001 43523.685999999994 1944107382550.3357 28.295824  10.68106 0
    "GRC" 12 2001            139.198 136191353914.98882  25.63733  4.935897 0
    "HUN" 13 2001             20.295  53749989092.01972  24.70761 3.0103745 0
    "IRL" 14 2001            7192.16 109252057270.69351 25.416924  8.880747 0
    "ITA" 15 2001          13561.482 1167012796420.5818  27.78547  9.514989 0
    "LVA" 16 2001                  0  8362398701.589434  22.84701         . 0
    "LTU" 17 2001                  0  12237388001.72637  23.22776         . 0
    "LUX" 18 2001            282.299 21369028187.919464  23.78521  5.642967 0
    "MLT" 19 2001               1.44 4088368978.3458934  22.13141  .3646431 0
    "NLD" 20 2001  94488.28199999999   431213422818.792  26.78987  11.45623 0
    "POL" 21 2001             33.319 190905493539.16806 25.975044  3.506128 0
    "PRT" 22 2001            197.184 121498889485.45862  25.52317  5.284137 0
    "ROU" 23 2001                  0  40394824679.12322  24.42197         . 0
    "SVK" 24 2001                  0    20876309970.385  23.76188         . 0
    "SVN" 25 2001                  0 30752150335.570473 24.149225         . 0
    "ESP" 26 2001           1201.569  627286800894.8546  27.16467  7.091383 0
    "SWE" 27 2001           5392.967   242395852494.409  26.21384  8.592851 0
    "GBR" 28 2001          23318.191  1643908161796.459   28.1281  10.05699 0
    "AUT"  1 2002           1616.635 213377771503.85846  26.08633  7.388102 0
    "BEL"  2 2002           2345.277 257157820440.42914 26.272955  7.760159 0
    "BGR"  3 2002                  0 16402846413.095812  23.52072         . 0
    "HRV"  4 2002                  0 27074550257.811844  24.02186         . 0
    "CYP"  5 2002            105.102 11420227884.615385  23.15865 4.6549315 0
    "CZE"  6 2002              4.835 178635163717.43066  25.90861  1.575881 0
    "DNK"  7 2002 3971.6409999999996  82196001050.74744  25.13237  8.286935 0
    "EST"  8 2002                  0  7367975887.727229  22.72041         . 0
    "FIN"  9 2002           1243.752  139738377564.4645  25.66304  7.125888 0
    "FRA" 10 2002 62141.117999999995 1494286655373.6118  28.03267 11.037163 0
    "DEU" 11 2002          77836.196 2068624129493.6948 28.357904 11.262362 0
    "GRC" 12 2002             143.45   153830946734.425  25.75912  4.965987 0
    "HUN" 13 2002             12.894 67608919144.368355 24.937006  2.556762 0
    "IRL" 14 2002           7639.051 127985972143.79823 25.575186  8.941029 0
    "ITA" 15 2002           9017.067 1270712309429.7007   27.8706  9.106874 0
    "LVA" 16 2002                  0  9557031605.275124 22.980543         . 0
    "LTU" 17 2002                  0 14259781159.011929  23.38071         . 0
    "LUX" 18 2002           8036.323    23537637869.377 23.881866  8.991727 0
    "MLT" 19 2002              35.46  4470446391.446391 22.220755 3.5684054 0
    "NLD" 20 2002  66319.70300000001  471613965744.4005 26.879427 11.102242 0
    "POL" 21 2002             22.453 199072058823.52942 26.016933  3.111424 0
    "PRT" 22 2002            138.343 134156091661.96123  25.62227  4.929736 0
    "ROU" 23 2002                  0 46066101951.293304  24.55334         . 0
    "SVK" 24 2002                  0 23489890274.314217 23.879835         . 0
    "SVN" 25 2002                  0  35130340673.81893  24.28233         . 0
    "ESP" 26 2002 4060.0099999999998  705394315829.0984  27.28202  8.308941 0
    "SWE" 27 2002  7596.170999999999  266849061835.6595  26.30995    8.9354 0
    "GBR" 28 2002          51950.529 1784076738609.1125  28.20992 10.858047 0
    "AUT"  1 2003             622.86 261695778781.03836  26.29045  6.434322 0
    "BEL"  2 2003           3902.234  317381715575.6208  26.48337  8.269304 0
    "BGR"  3 2003                  0 21144983551.682346  23.77467         . 0
    "HRV"  4 2003                  0  34985749883.41714 24.278206         . 0
    "CYP"  5 2003            119.575  14547325028.31257 23.400673  4.783944 0
    "CZE"  6 2003             16.062 218096033517.00897   26.1082  2.776456 0
    "DNK"  7 2003           4247.137 100090467581.26839  25.32934     8.354 0
    "EST"  8 2003                  0  9874013098.464317  23.01317         . 0
    "FIN"  9 2003           1730.789 171274266365.68848  25.86653  7.456333 0
    "FRA" 10 2003          65933.698 1840480812641.0835  28.24105 11.096405 0
    "DEU" 11 2003 59921.314000000006 2496128668171.5576 28.545763 11.000788 0
    "GRC" 12 2003 207.37900000000002   201924269751.693  26.03116  5.334548 0
    "HUN" 13 2003             16.062  85302003908.04198 25.169464  2.776456 0
    "IRL" 14 2003           8847.671 164307961625.28217  25.82501   9.08791 0
    "ITA" 15 2003           7409.595 1574145823927.7651 28.084734  8.910531 0
    "LVA" 16 2003                  0  11771975156.80728  23.18899         . 0
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 560 observations
    Use the count() option to list more

    .

    Comment


    • #3
      . xtdidregress (lnFDI lnGDP) (countryid, continuous), group(post) time(years)
      treatment variable varies at the post years level
      For example, if state and year are your group() and time() variables and you have individual-level
      data, all individuals in the state in a given year should have the same treatment. Your data do not
      fulfill this requirement.

      Comment


      • #4
        Jeffrey:
        what if you type:
        Code:
        xtdidregress (lnFDI lnGDP) (countryid), group(post) time(years)
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          it says invalid treatment variable
          either the treatment does not vary or it is never zero. the treatment variable is either zero for controlled observations or 1 for treated observations. to use a continuous treatment, specify (countryid, continuous) for your treatment specification.
          that what it says.

          Comment


          • #6
            Jefrey:
            the issue seems to rest on the fact that post is always.
            Converting 0 into 1 in the last observation, gives back an outcome table (which is possibly uninformative, given the arbitrary tweak):
            Code:
            . replace post = 1 in 100
            (1 real change made)
            
            . xtdidregress (lnFDI lnGDP) (post), group(new_countryid) time(years)
            
            Number of groups and treatment time
            
            Time variable: years
            Control:       post = 0
            Treatment:     post = 1
            -----------------------------------
                         |   Control  Treatment
            -------------+---------------------
            Group        |
            new_countr~d |        20          1
            -------------+---------------------
            Time         |
                 Minimum |      2000       2002
                 Maximum |      2001       2002
            -----------------------------------
            
            Difference-in-differences regression                        Number of obs = 65
            Data type: Longitudinal
            
                                     (Std. err. adjusted for 21 clusters in new_countryid)
            ------------------------------------------------------------------------------
                         |               Robust
                   lnFDI | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
            ATET         |
                    post |
               (1 vs 0)  |   -.013301   .3157234    -0.04   0.967    -.6718884    .6452864
            ------------------------------------------------------------------------------
            Note: ATET estimate adjusted for covariates, panel effects, and time effects.
            
            .
            Unsolicited advice: you cannot rely upon the results of such a complex methodology if you do not have a precise idea of what is going on behind the curtain.
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              thanks, Carlo I think you understand what I am trying to articulate better from your advice but I don't know how to go about it
              Brexit right what I am trying to do is since the policy was implemented in 2016 - the effect from 2016 afterward
              than before 2016 everyone was the same no Brexit policy effect.
              can you give me an insight on how to go about this cause your result above shows something reasonable

              Comment


              • #8
                then as regards the group(new_countryid), what did you specify or do?

                Comment


                • #9
                  Jeffrey:
                  this is what I coded and what I got as far as my previous toy-example is concerned:
                  Code:
                  . encode country, g(new_countryid)
                  
                  . xtset new_countryid years
                  
                  . replace post = 1 in 100
                  
                  . xtdidregress (lnFDI lnGDP) (post), group(new_countryid) time(years)
                  
                  Number of groups and treatment time
                  
                  Time variable: years
                  Control:       post = 0
                  Treatment:     post = 1
                  -----------------------------------
                               |   Control  Treatment
                  -------------+---------------------
                  Group        |
                  new_countr~d |        20          1
                  -------------+---------------------
                  Time         |
                       Minimum |      2000       2002
                       Maximum |      2001       2002
                  -----------------------------------
                  
                  Difference-in-differences regression                        Number of obs = 65
                  Data type: Longitudinal
                  
                                           (Std. err. adjusted for 21 clusters in new_countryid)
                  ------------------------------------------------------------------------------
                               |               Robust
                         lnFDI | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                  ATET         |
                          post |
                     (1 vs 0)  |   -.013301   .3157234    -0.04   0.967    -.6718884    .6452864
                  ------------------------------------------------------------------------------
                  Note: ATET estimate adjusted for covariates, panel effects, and time effects.
                  Again, the issue with your data is that you do not have 1 in -post- variable; hence -xtdidregress- complains.
                  Kind regards,
                  Carlo
                  (StataNow 18.5)

                  Comment


                  • #10
                    okay so how can I solve this issue of not having 1 in post variable.
                    and from my understanding of what you did "replace post 1 = 100" do I do the same or how did you come about 1=100? so I could look at my data and decide the appropriate.

                    Comment


                    • #11
                      Jeffrrey:
                      if you do not have at least ine value=1 in your -post- variable, -xtdidregress- cannot work.
                      As far as the toy-example is concerned, I've chose the observation to be changed in a totally arbitrary way.
                      Kind regards,
                      Carlo
                      (StataNow 18.5)

                      Comment


                      • #12
                        carlo, i have done what you suggested but now it say years not nested in countryid?

                        Comment


                        • #13
                          i think i have been able to sort post but the issue i am seeing is with group when i try either years is not nested in countryid
                          when i encode countryid it then says none of the group defined by new countryid is not a control
                          Last edited by jeffrey bosah; 30 Dec 2021, 13:08.

                          Comment


                          • #14

                            . dataex country years lnFDI lnGDP post new_countryid1

                            ----------------------- copy starting from the next line -----------------------
                            Code:
                            * Example generated by -dataex-. For more info, type help dataex
                            clear
                            input str3 country int years float(lnFDI lnGDP post) long new_countryid1
                            "AUT" 2000  7.010315 26.005453 0 1
                            "AUT" 2001  5.840057  26.00818 0 1
                            "AUT" 2002  7.388102  26.08633 0 1
                            "AUT" 2003  6.434322  26.29045 0 1
                            "AUT" 2004  6.477118  26.43006 0 1
                            "AUT" 2005  7.234112  26.47893 0 1
                            "AUT" 2006  7.566986  26.54037 0 1
                            "AUT" 2007  7.890485  26.68605 0 1
                            "AUT" 2008  6.722452 26.787735 0 1
                            "AUT" 2009  7.366107  26.71516 0 1
                            "AUT" 2010  7.594461 26.694254 0 1
                            "AUT" 2011  8.630413 26.789654 0 1
                            "AUT" 2012  8.831329  26.73802 0 1
                            "AUT" 2013   8.30161  26.78721 0 1
                            "AUT" 2014  8.263699  26.81457 0 1
                            "AUT" 2015  7.930228  26.66821 0 1
                            "AUT" 2016  7.394414  26.70359 1 1
                            "AUT" 2017  8.126156 26.754505 1 1
                            "AUT" 2018  7.298759 26.843445 1 1
                            "AUT" 2019  7.741985  26.82137 1 1
                            "BEL" 2000  5.334587 26.187963 0 2
                            "BEL" 2001         .  26.18939 0 2
                            "BEL" 2002  7.760159 26.272955 0 2
                            "BEL" 2003  8.269304  26.48337 0 2
                            "BEL" 2004  9.323993 26.632807 0 2
                            "BEL" 2005  9.038934  26.67799 0 2
                            "BEL" 2006  9.505415 26.734333 0 2
                            "BEL" 2007  9.069913  26.87669 0 2
                            "BEL" 2008  8.617882 26.967867 0 2
                            "BEL" 2009  8.890609  26.89985 0 2
                            "BEL" 2010  9.492636  26.89903 0 2
                            "BEL" 2011 10.625958  26.98217 0 2
                            "BEL" 2012 11.152515 26.930206 0 2
                            "BEL" 2013 10.386354  26.98025 0 2
                            "BEL" 2014 10.661504  27.00493 0 2
                            "BEL" 2015 10.401152 26.859154 0 2
                            "BEL" 2016 10.471236 26.888136 1 2
                            "BEL" 2017  9.974218 26.940914 1 2
                            "BEL" 2018 11.733724  27.02039 1 2
                            "BEL" 2019 11.731337 27.006073 1 2
                            "BGR" 2000  2.599128  23.30695 0 3
                            "BGR" 2001         . 23.375345 0 3
                            "BGR" 2002         .  23.52072 0 3
                            "BGR" 2003         .  23.77467 0 3
                            "BGR" 2004         .  23.98742 0 3
                            "BGR" 2005         . 24.120096 0 3
                            "BGR" 2006         . 24.260735 0 3
                            "BGR" 2007         .  24.51662 0 3
                            "BGR" 2008         . 24.720346 0 3
                            "BGR" 2009         .  24.67496 0 3
                            "BGR" 2010         .  24.64884 0 3
                            "BGR" 2011         . 24.778147 0 3
                            "BGR" 2012         . 24.717806 0 3
                            "BGR" 2013   2.80148  24.74522 0 3
                            "BGR" 2014 2.2364452 24.767756 0 3
                            "BGR" 2015 1.0388622  24.65081 0 3
                            "BGR" 2016  3.925433 24.711395 1 3
                            "BGR" 2017  4.968952  24.80418 1 3
                            "BGR" 2018 2.9762945  24.91841 1 3
                            "BGR" 2019  4.316928 24.956146 1 3
                            "CYP" 2000  5.220767 23.024435 0 4
                            "CYP" 2001  5.553584  23.06487 0 4
                            "CYP" 2002 4.6549315  23.15865 0 4
                            "CYP" 2003  4.783944 23.400673 0 4
                            "CYP" 2004  5.014953  23.57516 0 4
                            "CYP" 2005  5.431725  23.63743 0 4
                            "CYP" 2006  6.068664  23.72263 0 4
                            "CYP" 2007  5.642506 23.900017 0 4
                            "CYP" 2008  6.779313  24.04991 0 4
                            "CYP" 2009  6.385041  23.97926 0 4
                            "CYP" 2010  8.271579  23.97102 0 4
                            "CYP" 2011  8.361662  24.03983 0 4
                            "CYP" 2012  8.830351  23.94128 0 4
                            "CYP" 2013  8.787777  23.89718 0 4
                            "CYP" 2014  8.796767 23.865557 0 4
                            "CYP" 2015  8.879628 23.711086 0 4
                            "CYP" 2016  8.662454  23.76557 1 4
                            "CYP" 2017  8.623246  23.85313 1 4
                            "CYP" 2018  9.244284 23.962833 1 4
                            "CYP" 2019  8.501024 23.972025 1 4
                            "CZE" 2000         .   25.8241 0 5
                            "CZE" 2001  3.143592 25.827946 0 5
                            "CZE" 2002  1.575881  25.90861 0 5
                            "CZE" 2003  2.776456   26.1082 0 5
                            "CZE" 2004   2.44997 26.250204 0 5
                            "CZE" 2005 1.6420987 26.300983 0 5
                            "CZE" 2006         . 26.368305 0 5
                            "CZE" 2007  2.997181 26.489784 0 5
                            "CZE" 2008 3.3979254 26.590755 0 5
                            "CZE" 2009  .4824261  26.49546 0 5
                            "CZE" 2010   2.39407   26.4978 0 5
                            "CZE" 2011 4.1878347  26.56392 0 5
                            "CZE" 2012         .  26.51368 0 5
                            "CZE" 2013  3.921359   26.5627 0 5
                            "CZE" 2014 2.7528324 26.589716 0 5
                            "CZE" 2015  5.665824  26.43592 0 5
                            "CZE" 2016  1.998909  26.46984 1 5
                            "CZE" 2017   2.39206 26.528765 1 5
                            "CZE" 2018  6.241499  26.60056 1 5
                            "CZE" 2019   3.03375  26.57421 1 5
                            end
                            label values new_countryid1 new_countryid1
                            label def new_countryid1 1 "AUT", modify
                            label def new_countryid1 2 "BEL", modify
                            label def new_countryid1 3 "BGR", modify
                            label def new_countryid1 4 "CYP", modify
                            label def new_countryid1 5 "CZE", modify
                            ------------------ copy up to and including the previous line ------------------

                            Listed 100 out of 560 observations
                            Use the count() option to list more

                            Comment


                            • #15
                              jeffrey bosah you have been sending me private messages when you want my response to a posting - please do NOT do this as I will not respond to such private messages and, because this practice irritates me, I will also not respond to your posting

                              Comment

                              Working...
                              X