Announcement

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

  • Granger-Causality test - Panel data - Anderson-Hsiao estimator

    Hello

    I would like to follow the Anderson-Hsiao framework for a panel data analysis. And I am having issues with the steps and coding involved.
    I wish to perform a Granger causality test using the Anderson-HSIAO estimates as instruments. My dependent variable is "GDP", my explanatory variables are "pci" and "ForeigndirectinvestmentnetBo". My control variables are the following: "BroadmoneyofGDPFMLBLB" , "Popula" and " External".

    I computed the Anderson-Hsiao 2SLS estimator including all of my variables:
    Code:
     ivregress 2sls diff_GDP diff_pci diff_Foreigni diff_Broadmoney diff_Pop diff_Externald (L.D.GDP=L2.D.GDP),robust cluster(country)
    I tested for Granger-causality using GDP and pci
    Code:
    pvar pci GDP, lags(5)
    pvargranger

    Code:
    **Declare panel data
     egen country=group(Entity)
     list Entity (country) in 1/10, sepby(Entity)
     gen year = real(Year)
      xtset country
      xtset country year,yearly
     gen GDP = real(gdp) //destring gdp varaible
    
     gen  Popula =real(PopulationgrowthannualSP)
      gen  External =real(ExternaldebtstockstotalDOD)
     
    
    **Index
     pca rescoups resmaxintensity resongoing resTerrorismfatalitiesGTD20 resconflict respostconflict
     rotate
     predict pci
    
     **includin zeros in missing cells
    foreach x of varlist pci{
      replace `x' = 0 if(`x' == .)
    }
    
    
    ** First differencing all columns
    gen diff_pci = D.pci
    gen diff_GDP = D.GDP
    gen diff_Foreigni = D.ForeigndirectinvestmentnetBo
    gen diff_Broadmoney= D.BroadmoneyofGDPFMLBLB
    gen diff_Pop= D.Popula
    gen diff_Externald = D.External
    
    **Second lagged deifference of GDP as instrument
    ivregress 2sls diff_GDP diff_pci diff_Foreigni diff_Broadmoney diff_Pop diff_Externald (L.D.GDP=L2.D.GDP),robust cluster(country)

    Now, what I would like to do is to perform the Granger-causality test on GDP and pci, including my explanatory and control variables in test, and instrumenting with the Anderson-HSIAO 2SLS.estimator.

    Can someone assist me with the code for the above?

    My data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(GDP pci) double ForeigndirectinvestmentnetBo float(Popula External) double BroadmoneyofGDPFMLBLB
      4.400002  -.4595704 -3942928.3  2.675145 2.72485e+10 72.796361
      .8000006  -.4595704  4353889.3 2.5664566 28153911296  61.77114
    -1.2000005   1.466991   38651266  2.460316 28489965568  49.11131
     1.8000023   1.466991          . 2.3503273 27351246848 51.941995
    -2.1000009   1.466991          . 2.2216294 26274664448 50.101458
     -.8999966   3.393549          . 2.0708578 30241927168 45.318672
      3.799995   3.393549          . 1.9098215 33051430912 37.169446
     4.0999985   3.393549          .  1.753176 33653880832 33.005836
     1.0999999  3.3935504          . 1.6152833 30902562816 36.081434
      5.100004  3.3935494          . 1.5008857 30692708352 42.376822
     3.2000015   3.393549          . 1.4162657 28209283072 42.208981
           3.8   1.466991          .  1.358408 25467371520 37.832606
             3   1.466991          . 1.3098426 22752567296 56.850473
           5.6   1.466991          . 1.2750655 23045429248 62.726626
           7.2   1.466991          . 1.2759147 23778635776 62.816935
           4.3   1.466991          . 1.3178462 22426644480 59.265476
           5.9   1.466991 -1.101e+09 1.3899006 17092404224 53.827594
           1.7   1.466991 -1.762e+09  1.471123  5910806016  57.28216
           3.4   1.466991 -1.540e+09 1.5513825  6134513152 64.092886
           2.4   1.466991 -2.321e+09 1.6361927  6246398976 62.986986
           1.6   1.466991 -2.533e+09 1.7220932  7420896256 73.158861
           3.6   1.466991 -2.081e+09 1.8050187  7260318208  69.05566
           2.9   1.466991 -2.037e+09 1.8833138  6064672256 68.060812
           3.4   1.466991 -1.542e+09 1.9514152  5515632128 67.953132
           2.8   1.466991 -1.964e+09 2.0027277  5245580800 71.729813
           3.8   1.466991 -1.521e+09 2.0335925  5521129472 79.309932
           3.7   1.466991  6.389e+08 2.0453873  4671369728 82.001074
           3.2   1.466991 -1.592e+09 2.0513546  5463160832 78.884977
     .04162146   3.393549 -2.000e+08  3.434427  7288778240         .
     -3.450099   3.393549  3.357e+08  3.378481  8591895552         .
      .9913593   1.466991 -6.645e+08  3.324456  9000344576         .
     -5.838281   3.393549 -2.880e+08  3.280312 10059207680         .
     -23.98342   3.393549 -3.021e+08  3.246642 10571384832         .
     1.3393635   3.393549 -1.703e+08 3.2261446 11292755968         .
            15   1.466991 -4.724e+08  3.216859 11502043136  36.48713
      13.54437   1.466991 -1.806e+08  3.214234 10545818624 27.577574
      7.274277   1.466991 -4.117e+08   3.21732  9948273664 22.615484
     4.6911464   3.393549 -1.114e+09 3.2289414 10784075776 24.437043
     2.1814897   3.393549 -2.471e+09  3.249247 10673242112 22.849355
      3.054624   3.393549 -8.786e+08 3.2772036  9763465216 17.280556
     4.2059984   3.393549 -2.145e+09  3.301198  8776916992 21.135714
     13.665687   1.466991 -1.643e+09  3.329257  9109536768 16.049883
       2.98985  -.4595705 -3.481e+09  3.378811  9099850752 13.508367
     10.952862   1.466991 -1.414e+09  3.453014  9786029056 13.553646
     15.028915  -.4595705  1.523e+09  3.537557 12223970304 13.299819
     11.547683  -.4595705  2.283e+08 3.6195745  9890493440 16.273326
     14.010018   1.466991  1.805e+09 3.6806355 11931686912 20.446871
      11.16614  -.4595705  8.907e+08  3.710531 15501571072 31.520504
      .8587126   1.466991 -2.199e+09  3.703878 20172423168  45.60817
       4.85922  -.4595705  4.568e+09  3.671462 26599589888 34.774751
      3.471981  -.4595705  5.116e+09 3.6341586 33964863488 34.978872
      8.542148  -.4595705  2.351e+09  3.597774 4.42591e+10 31.517732
       4.95459  -.4595705  8.042e+09 3.5519505 5.49465e+10 33.331549
      4.822626  -.4595705 -2.771e+09  3.497493 5.69355e+10 35.675553
      .9435756  -.4595705 -1.081e+10 3.4388506 56272310272  40.94466
     -2.580097  -.4595705  4.525e+08  3.378273 57167384576 39.162307
    -2.8541605  -.4595704  -62096190 3.1007655  1070152448 21.740975
      8.976134  -.4595704  -62376777  3.235059  1119735936 25.115607
     4.2257996  -.4595704 -1.208e+08  3.377159  1149708032 26.467866
      2.957711 -.45957035  -77571727  3.479003  1198996352 29.622098
      5.836172  -.4595704 -1403787.2  3.500774  1270610560 26.490936
     2.0204005  -.4595704  -13648840  3.426061  1382104448 28.441371
      6.045198 -.45957035  -13329502  3.293614  1396512512 22.873627
      4.324284  -.4595704  -13595869  3.145324  1377641344  23.18018
      5.734688  -.4595704  -13876006 3.0283754  1411356800 22.128608
      3.961012  -.4595704  -32748440  2.958613  1433932288 19.507034
      5.341449  -.4595704  -37820420 2.9517546  1488489216 22.995933
      5.859992  -.4595704  -56153557  2.983995  1399684864  26.22559
      5.330411  -.4595704  -41553069   3.02378  1470316544 24.597384
       4.64447  -.4595704  -12158025  3.043083  1608563072 20.009685
      3.444045  -.4595704  -44416700  3.039675  1485978752 22.943317
      4.429629  -.4595704  -65154249  3.005342  1612808832 19.179256
     1.7115777  -.4595704  -53428819 2.9523835  1551746432 21.128573
      3.947014  -.4595704  -54929324  2.897545   648364672 25.330737
      5.986516  -.4595704 -2.613e+08 2.8540854   883287872 28.304637
      4.889899  -.4595704 -1.738e+08 2.8235555   973593408 31.798127
      2.329301  -.4595704 -1.031e+08  2.809302  1309266304  32.73525
     2.1101992  -.4595704 -1.947e+08 2.8060865  1581966848 34.882235
     2.9627504  -.4595704 -1.014e+08  2.803718  1851264384 35.722533
      4.816478  -.4595704 -2.412e+08  2.797649  1675225728 34.007497
      7.189716 -.45957035 -3.017e+08  2.790718  2003816448 36.709118
      6.351832  -.4595704 -3.879e+08 2.7821815  2041492864 40.952857
     2.0958083  -.4595704 -1.170e+08  2.771714  2178021376 42.541423
       3.96486  -.4595704 -1.143e+08 2.7614095  2316211200 41.105935
     13.059406  -.4595704  -42186013   3.63436   549840384 28.924689
      6.772822  -.4595704  -88526216  3.340334   552920448 21.920211
      7.458709  -.4595704   16719789 3.0285375   612559232 27.456387
     2.9170704  -.4595704   11423290  2.768483   606348608 28.332171
      1.916107  -.4595704  2.964e+08 2.5741794   663983872 21.037856
      3.627916  -.4595704   23615781 2.4672565   700397760 20.921851
       7.03041  -.4595704  -29507180  2.419145   717153216  20.47826
        5.8298  -.4595704  -72235497  2.391314   626530368 19.794538
      8.325891  -.4595704  -96006497 2.3444872   574727360 22.389681
      .4436635  -.4595704  -91820639 2.2719958   532169056 28.263056
      9.667241  -.4595704  -35161354  2.161983   510191232  28.50095
     1.9876958  -.4595704  -54918579 2.0328965   452434624 24.816209
     .25057387  -.4595704  3.490e+08 1.8893803   400352896 39.399228
      6.069531  -.4595704 -3.651e+08  1.773421   491350080 45.248542
      4.625895  -.4595704 -2.120e+08  1.730526   514126464 47.878314
      2.705822  -.4595704 -4.296e+08  1.778885   515796288 46.884142
    end


    Last edited by Ishto Stanfield; 05 Apr 2020, 01:37.
Working...
X