Announcement

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

  • 2 Questions regarding data analysis

    ac d.lrgdp.gph pac d.lrgdp.gph Graph.gph

    Dear Stata Users,

    This might be a really easy question for some of you to answer but I'm relatively new to this software. I plotted the autocorrelation and partial autocorrelations of the first difference of real GDP but can't seem to make up what the picture is trying to illustrate. I find it weird that there are random spikes appearing out of the confidence bands and am not too sure as to how to interpret it. Secondly, I'm trying to explore the relationship between oil price movements and real gdp and have plotted a line graph. However, again, from the graph, it is extremely challenging to spot for some sort of pattern or trend. I wanted to ask if there is any way of making the graph clearer so that I can try to explore a relationship? Thank you.

    ac d.lrgdp.gph pac d.lrgdp.gph Graph.gph


  • #2
    I would suggest posting both your data and the code used to produce the graphs using -dataex- and CODE delimiters.

    Comment


    • #3
      My data looks like this:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str7 date double exc long rgdp double(unp inf op) float(lrgdp lop lexc time lrgdp_1 Dlrgdp lop_1 Dlop lexc_1 Dlexc)
      "Q1 1980" 4.94676666566667 339021              1.5  7.74278215223094            35.58 12.733817  3.571784  1.598734  80         .            .         .            .         .            .
      "Q2 1980"      4.942499999 324697              1.4  10.2464332036316            35.45 12.690648  3.568123 1.5978713  81 12.733817   -.04316902  3.571784 -.0036604404  4.946767 -.0008628368
      "Q3 1980" 4.84123333233333 315430              2.1   12.291933418694 32.7066666666667 12.661692  3.487579 1.5771695  82 12.690648  -.028956413  3.568123   -.08054447    4.9425  -.020701766
      "Q4 1980"      5.026399999 343069              1.6  13.1147540983606            39.09 12.745687 3.6658666  1.614704  83 12.661692    .08399487  3.487579    .17828774  4.841233    .03753448
      "Q1 1981"      5.350099999 339189              1.8  14.7381242387332 37.2933333333333 12.734313 3.6188145 1.6771152  84 12.745687   -.01137352 3.6658666   -.04705215    5.0264    .06241119
      "Q2 1981" 5.68363333233333 331605                2                14            33.54   12.7117  3.512739 1.7375907  85 12.734313  -.022613525 3.6188145   -.10607576    5.3501    .06047547
      "Q3 1981" 6.08516666566667 326427              2.4  13.5689851767389 31.7966666666667 12.695962 3.4593616  1.805854  86   12.7117  -.015737534  3.512739   -.05337715  5.683633    .06826341
      "Q4 1981" 5.83913333233333 346128              1.8  12.3745819397994 33.5233333333333 12.754564 3.5122416 1.7645824  87 12.695962    .05860233 3.4593616    .05288005  6.085166   -.04127169
      "Q1 1982" 5.95133333233333 339288                2  11.8895966029724 30.6733333333333 12.734605  3.423394 1.7836152  88 12.754564   -.01995945 3.5122416   -.08884788  5.839133   .019032836
      "Q2 1982"      6.077099999 330830              2.4  11.0423116615067 32.1066666666667  12.70936  3.469064 1.8045276  89 12.734605  -.025244713  3.423394    .04567003  5.951334    .02091241
      "Q3 1982"      6.641599999 327615              2.8  10.8433734939759 31.8066666666667 12.699594  3.459676  1.893353  90  12.70936  -.009765625  3.469064  -.009387732    6.0771    .08882523
      "Q4 1982"      7.146099999 348779              3.2  11.6071428571428            31.59 12.762194 3.4528406 1.9665668  91 12.699594    .06259918  3.459676   -.00683546    6.6416   .073213935
      "Q1 1983" 7.10993333233333 345516              3.6  9.77229601518024            29.16 12.752794  3.372798  1.961493  92 12.762194  -.009399414 3.4528406    -.0800426    7.1461  -.005073905
      "Q2 1983" 7.16973333233333 347946              3.7   9.1078066914498            29.48 12.759803  3.383712 1.9698684  93 12.752794   .007008553  3.372798   .010914087  7.109933  .0083755255
      "Q3 1983" 7.40316666566667 341769              3.8  7.78985507246374 30.2966666666667  12.74189  3.411038 2.0019078  94 12.759803  -.017912865  3.383712    .02732563  7.169734   .032039404
      "Q4 1983" 7.50263333233333 364775              2.6  7.28888888888891            28.94 12.807036  3.365225  2.015254  95  12.74189   .065146446  3.411038   -.04581285  7.403167   .013346195
      "Q1 1984" 7.68896666566667 368229              3.2  6.30942091616251 29.2333333333333  12.81646   3.37531 2.0397863  96 12.807036    .00942421  3.365225   .010084867  7.502633    .02453232
      "Q2 1984" 7.74113333266667 360828              3.3  6.47359454855195 29.3133333333333 12.796157 3.3780425 2.0465481  97  12.81646  -.020303726   3.37531   .002732754  7.688967    .00676179
      "Q3 1984" 8.36613333266667 368434              3.6  6.13445378151261 28.1466666666667 12.817017  3.337429 2.1241918  98 12.796157    .02085972 3.3780425   -.04061341  7.741133    .07764363
      "Q4 1984" 8.84959999933333 387247              2.5  5.96520298260146            27.49 12.866818  3.313822 2.1803722  99 12.817017    .04980183  3.337429  -.023606777  8.366134    .05618048
      "Q1 1985" 9.36676666666667 391743                3  5.69105691056911 27.3666666666667 12.878362  3.309326  2.237168 100 12.866818   .011543274  3.313822 -.0044965744    8.8496    .05679584
      "Q2 1985"      8.893666666 377860              2.3  5.75999999999999            26.95  12.84228  3.293983 2.1853395 101 12.878362  -.036082268  3.309326  -.015342474  9.366767   -.05182862
      "Q3 1985"      8.342333333 385100              3.1  5.77988915281077 27.0933333333333 12.861259  3.299288  2.121343 102  12.84228    .01897907  3.293983   .005304575  8.893666   -.06399655
      "Q4 1985" 7.78616666666667 412488                2  5.62939796716187 28.0733333333333 12.929962   3.33482 2.0523486 103 12.861259    .06870365  3.299288   .035532236  8.342334   -.06899428
      "Q1 1986"           7.3197 401783                2  5.76923076923076            17.16 12.903667  2.842581 1.9905694 104 12.929962   -.02629471   3.33482     -.492239  7.786167   -.06177926
      "Q2 1986" 7.40296666666667 399497              1.9  6.05143721633889 12.4433333333333 12.897962  2.521185  2.001881 105 12.903667  -.005705833  2.842581    -.3213961    7.3197    .01131153
      "Q3 1986"           7.3868 399205              2.3  8.00898203592812 12.4433333333333  12.89723  2.521185 1.9996946 106 12.897962 -.0007314682  2.521185            0  7.402966 -.0021862984
      "Q4 1986"           7.4695 430057              1.7  8.80829015544041            14.64 12.971673 2.6837575  2.010828 107  12.89723    .07444286  2.521185     .1625726    7.3868   .011133432
      "Q1 1987" 7.03546666666667 412198              2.4  9.96363636363637 17.7066666666667  12.92926  2.873941  1.950964 108 12.971673   -.04241371 2.6837575    .19018364    7.4695   -.05986404
      "Q2 1987"           6.7112 413613              1.8  9.70042796005709            18.39 12.932686  2.911807 1.9037777 109  12.92926   .003426552  2.873941    .03786588  7.035467   -.04718626
      "Q3 1987"           6.7302 397776              2.2  7.90020790020794            18.94 12.893644  2.941276  1.906605 110 12.932686   -.03904152  2.911807   .029469013    6.7112  .0028271675
      "Q4 1987" 6.47293333333333 435545              1.9  7.41496598639454 17.7566666666667 12.984353  2.876761 1.8676294 111 12.893644    .09070873  2.941276  -.064515114    6.7302   -.03897548
      "Q1 1988"            6.365 419283              2.5  7.07671957671957 15.7533333333333 12.946301  2.757052 1.8508142 112 12.984353    -.0380516  2.876761   -.11970901  6.472933  -.016815186
      "Q2 1988"            6.256 404907              2.9  7.02210663198959            16.09 12.911412  2.778198  1.833541 113 12.946301   -.03488922  2.757052    .02114606     6.365  -.017273188
      "Q3 1988"           6.8359 401254              3.4  6.61528580603723 14.0866666666667  12.90235 2.6452286  1.922188 114 12.911412  -.009062767  2.778198   -.13296938     6.256    .08864713
      "Q4 1988" 6.61103333333333 429452              3.9  6.01646611779607 13.1466666666667 12.970265  2.576168   1.88874 115  12.90235    .06791592 2.6452286  -.069060326    6.8359   -.03344822
      "Q1 1989" 6.72326666666667 408393              4.8  4.69425571340333 17.0233333333333 12.919985  2.834585 1.9055742 116 12.970265   -.05028057  2.576168    .25841665  6.611033   .016834259
      "Q2 1989" 7.00846666666667 417709 4.76666666666667  4.67800729040098            18.47  12.94254  2.916148  1.947119 117 12.919985    .02255535  2.834585    .08156276  6.723267     .0415448
      "Q3 1989"           7.0385 407719 5.03333333333333  4.51807228915663            17.41 12.918333  2.857045  1.951395 118  12.94254  -.024207115  2.916148   -.05910301  7.008467   .004276037
      "Q4 1989" 6.84776666666667 438257 4.93333333333333  4.30107526881723            18.72  12.99056 2.9295924 1.9239225 119 12.918333    .07222748  2.857045   .072547674    7.0385  -.027472496
      "Q1 1990" 6.53356666666667 427717 5.66666666666667  4.36578171091446 19.4633333333333 12.966217  2.968532  1.876953 120  12.99056   -.02434349 2.9295924    .03893995  6.847767   -.04696953
      "Q2 1990"           6.4893 416785 5.16666666666667  3.83052814857803            15.82 12.940326  2.761275 1.8701546 121 12.966217  -.025891304  2.968532   -.20725727  6.533566  -.006798387
      "Q3 1990"            6.154 412074              5.2  3.80403458213255 25.6566666666667 12.928958 3.2448034 1.8171023 122 12.940326  -.011367798  2.761275     .4835284    6.4893   -.05305231
      "Q4 1990"           5.8621 447813 4.83333333333333    4.524627720504               31  13.01213  3.433987  1.768508 123 12.928958     .0831728 3.2448034     .1891837     6.154   -.04859436
      "Q1 1991"           5.9725 433742              5.6  3.90050876201245            19.85 12.980206  2.988204 1.7871656 124  13.01213    -.0319252  3.433987    -.4457831    5.8621   .018657684
      "Q2 1991" 6.75420333333333 439794 5.23333333333333  3.80100614868644            18.33 12.994061  2.908539  1.910165 125 12.980206   .013855934  2.988204   -.07966495    5.9725    .12299943
      "Q3 1991" 6.81336666666667 427301 5.46666666666667  3.49805663520268 19.4233333333333 12.965244  2.966475 1.9188864 126 12.994061  -.028817177  2.908539    .05793595  6.754203   .008721352
      "Q4 1991"           6.3917 456129              5.5  2.57534246575342 19.8666666666667  13.03053  2.989043 1.8550003 127 12.965244    .06528664  2.966475   .022568226  6.813367  -.063886166
      "Q1 1992" 6.35493333333333 457330              6.1  2.33949945593033 17.5066666666667  13.03316  2.862582 1.8492314 128  13.03053    .00262928  2.989043    -.1264615    6.3917  -.005768895
      "Q2 1992"           6.3128 443666 5.96666666666667   2.4232633279483 19.6833333333333 13.002828  2.979772 1.8425794 129  13.03316  -.030332565  2.862582     .1171906  6.354933  -.006651998
      "Q3 1992" 5.79393333333333 447403                6  2.30686695278971 19.9966666666667 13.011215  2.995566 1.7568114 130 13.002828   .008387566  2.979772   .015793324    6.3128   -.08576798
      "Q4 1992" 6.39633666666667 471367 5.63333333333333  2.24358974358973 18.9566666666667 13.063393 2.9421556 1.8557254 131 13.011215    .05217743  2.995566   -.05341005  5.793933    .09891403
      "Q1 1993"           6.9538 457344 6.26666666666667  2.60499734183944            17.99  13.03319  2.889816 1.9392883 132 13.063393   -.03020191 2.9421556   -.05233955  6.396337    .08356285
      "Q2 1993" 6.84676666666667 451547              6.1  2.41850683491062 17.9933333333333 13.020434  2.890001 1.9237765 133  13.03319  -.012756348  2.889816 .00018525124    6.9538   -.01551175
      "Q3 1993" 7.25126666666667 458853              6.1  2.14997378080752             16.2 13.036485  2.785011  1.981176 134 13.020434   .016050339  2.890001      -.10499  6.846766    .05739963
      "Q4 1993" 7.32468333333333 503800 5.33333333333333  1.98537095088822 14.9633333333333 13.129934  2.705603   1.99125 135 13.036485     .0934496  2.785011   -.07940865  7.251266    .01007378
      "Q1 1994" 7.44243666666667 482274 5.63333333333333   1.2435233160622            13.87 13.086267  2.629728 2.0071983 136 13.129934   -.04366684  2.705603   -.07587433  7.324683   .015948415
      "Q2 1994" 7.20914333333333 486378 5.66666666666667  .975359342915802            16.27 13.094742  2.789323   1.97535 137 13.086267    .00847435  2.629728    .15959454  7.442437  -.031848192
      "Q3 1994" 6.84432666666667 474431 5.36666666666667  1.54004106776183            17.05 13.069872   2.83615   1.92342 138 13.094742   -.02486992  2.789323    .04682732  7.209143   -.05193007
      "Q4 1994"          6.73443 523076 4.96666666666667  1.74180327868853 16.6033333333333 13.167482 2.8096035  1.907233 139 13.069872    .09761047   2.83615  -.026546717  6.844326  -.016186953
      "Q1 1995" 6.52158333333333 508034 5.53333333333333  2.66120777891503 17.2233333333333 13.138304  2.846265 1.8751172 140 13.167482   -.02917862 2.8096035   .036661625   6.73443  -.032115936
      "Q2 1995" 6.23681333333333 492214              5.2  2.69445856634468 18.1766666666667 13.106668 2.9001386 1.8304694 141 13.138304  -.031635284  2.846265    .05387354  6.521584   -.04464781
      "Q3 1995" 6.30330666666667 505191              4.8   2.3255813953488            16.44  13.13269 2.7997174 1.8410743 142 13.106668    .02602291 2.9001386    -.1004212  6.236814   .010604978
      "Q4 1995" 6.27892333333333 542393              4.2  2.16515609264855 16.9766666666667 13.203746   2.83184 1.8371985 143  13.13269    .07105446 2.7997174   .032122374  6.303307 -.0038758516
      "Q1 1996" 6.41570333333333 536283                5  .897308075772663 18.3133333333333 13.192417 2.9076295 1.8587487 144 13.203746  -.011328697   2.83184     .0757897  6.278924    .02155018
      "Q2 1996" 6.53549666666667 520406                5  .990099009900991 19.4866666666667 13.162365 2.9697304 1.8772483 145 13.192417  -.030052185 2.9076295    .06210089  6.415703   .018499613
      "Q3 1996"          6.41397 536030 4.76666666666667  1.38339920948619            20.63 13.191945  3.026746 1.8584784 146 13.162365   .029580116 2.9697304     .0570159  6.535497   -.01876986
      "Q4 1996" 6.43406333333333 558078 4.23333333333333  1.77427304090683 23.0633333333333 13.232254  3.138244 1.8616062 147 13.191945    .04030895  3.026746    .11149788   6.41397   .003127813
      "Q1 1997"          6.62962 548270 4.26666666666667  3.06324110671939 21.0833333333333 13.214523  3.048483 1.8915474 148 13.232254  -.017730713  3.138244   -.08976126  6.434063     .0299412
      "Q2 1997" 7.07691666666667 566972 4.23333333333333  2.69607843137256            18.49 13.248065   2.91723 1.9568384 149 13.214523    .03354168  3.048483   -.13125277   6.62962    .06529093
      "Q3 1997" 7.46047666666667 552684 3.96666666666667  2.29044834307992 18.6566666666667 13.222542 2.9262035 2.0096192 150 13.248065  -.025523186   2.91723    .00897336  7.076917    .05278087
      "Q4 1997"          7.12659 596533              3.2  2.22760290556901            18.84  13.29889  2.935982  1.963833 151 13.222542     .0763483 2.9262035   .009778738  7.460477   -.04578638
      "Q1 1998" 7.53980666666667 588947              3.3  2.15723873441995 14.1633333333333 13.286092 2.6506565 2.0201964 152  13.29889   -.01279831  2.935982   -.28532577   7.12659    .05636358
      "Q2 1998" 7.51393333333333 573271 3.46666666666667   2.2434367541766            13.28 13.259114  2.586259 2.0167592 153 13.286092   -.02697754 2.6506565  -.064397335  7.539807  -.003437281
      "Q3 1998" 7.63745333333333 561890              3.1  2.28680323963794 13.0033333333333  13.23906  2.565206 2.0330641 154 13.259114   -.02005291  2.586259  -.021053314  7.513933    .01630497
      "Q4 1998" 7.48919666666667 599781              2.5  2.32117479867363            11.85  13.30432  2.472328 2.0134616 155  13.23906    .06525898  2.565206   -.09287786  7.637454  -.019602537
      "Q1 1999" 7.66309333333333 587707              2.8  2.25246363209761 11.6433333333333 13.283984  2.454734 2.0364158 156  13.30432   -.02033615  2.472328  -.017594099  7.489197   .022954226
      "Q2 1999"           7.7982 574061 2.96666666666667  2.47432306255837            16.03  13.26049  2.774462 2.0538929 157 13.283984  -.023492813  2.454734     .3197281  7.663094   .017477036
      "Q3 1999"           7.8432 581940              3.2  2.04937121564973 20.4433333333333 13.274122  3.017657 2.0596468 158  13.26049   .013630867  2.774462     .2431948    7.7982   .005753994
      "Q4 1999" 7.89219333333333 626967 3.16666666666667  2.68518518518515 23.8066666666667  13.34865  3.169966  2.065874 159 13.274122    .07452679  3.017657    .15230894    7.8432   .006227255
      "Q1 2000" 8.22004333333333 626590              3.4  2.89123451124368 26.6166666666667 13.348047 3.2815375 2.1065755 160  13.34865 -.0006017685  3.169966    .11157179  7.892193    .04070139
      "Q2 2000" 8.77797333333333 589911              3.2  2.91571753986331 26.7666666666667 13.287727  3.287157 2.1722455 161 13.348047    -.0603199 3.2815375   .005619764  8.220043    .06567001
      "Q3 2000"          8.95455 594980 3.33333333333333  3.42309447740759 29.8833333333333 13.296283  3.397301 2.1921618 162 13.287727   .008555412  3.287157    .11014366  8.777973   .019916296
      "Q4 2000"           9.2548 635181 3.03333333333333  3.11091073038775            29.67 13.361666 3.3901365 2.2251422 163 13.296283    .06538296  3.397301  -.007164478   8.95455   .032980442
      "Q1 2001" 8.88969333333333 631517 3.33333333333333  3.52363960749332            26.07  13.35588  3.260785 2.1848927 164 13.361666  -.005785942 3.3901365   -.12935114    9.2548   -.04024959
      "Q2 2001" 9.17891333333333 603358 3.36666666666667  3.93979637007527 26.7266666666667 13.310266  3.285662  2.216909 165  13.35588   -.04561424  3.260785   .024876595  8.889693   .032016277
      "Q3 2001"          8.99699 609647 3.56666666666667   2.5595763459841 25.2133333333333 13.320636  3.227373   2.19689 166 13.310266   .010370255  3.285662   -.05828905  9.178913  -.020018816
      "Q4 2001"          8.90102 653161 3.36666666666667   2.0113686051596 19.3133333333333  13.38958 2.9607956 2.1861658 167 13.320636    .06894302  3.227373   -.26657724   8.99699  -.010724306
      "Q1 2002" 8.90953333333333 623584 3.73333333333333   1.0340370529944 20.9233333333333  13.34324  3.040865 2.1871219 168  13.38958   -.04633999 2.9607956     .0800693   8.90102  .0009560585
      "Q2 2002"          8.18353 636919 3.73333333333333  .468483816013621 25.2033333333333 13.364398  3.226976 2.1021235 169  13.34324    .02115917  3.040865     .1861112 8.9095335   -.08499837
      "Q3 2002"          7.52372 612090 3.66666666666667  1.41996557659209 26.9366666666667 13.324635 3.2934885 2.0180607 170 13.364398   -.03976345  3.226976   .066512346   8.18353   -.08406281
      "Q4 2002"         7.318332 661001 3.53333333333333  2.22888984140592 26.7366666666667  13.40151  3.286036 1.9903824 171 13.324635    .07687569 3.2934885  -.007452488   7.52372   -.02767825
      "Q1 2003" 7.05690666666667 647009 3.96666666666667  4.60554371002131 31.3366666666667 13.380116  3.444789 1.9540068 172  13.40151   -.02139473  3.286036     .1587529  7.318332   -.03637564
      "Q2 2003" 7.00835333333333 618078 4.33333333333333  2.24671470962272 26.4866666666667  13.33437 3.2766414 1.9471028 173 13.380116   -.04574585  3.444789   -.16814756  7.056907  -.006904006
      "Q3 2003" 7.33666666666667 624952 4.43333333333333  1.90920661858297 28.3833333333333  13.34543  3.345802 1.9928846 174  13.33437   .011060715 3.2766414     .0691607  7.008353    .04578185
      "Q4 2003"          6.91894 666858              4.1  1.21593291404613            29.36 13.410333  3.379633 1.9342626 175  13.34543   .064902306  3.345802    .03383112  7.336667     -.058622
      "Q1 2004" 6.90666666666667 676751 4.13333333333333 -1.42682429677945            32.13 13.425058   3.46979  1.932487 176 13.410333   .014725685  3.379633    .09015703   6.91894  -.001775503
      "Q2 2004"             6.86 650667 4.33333333333333  .829187396351576 35.6266666666667 13.385754 3.5730944 1.9257075 177 13.425058   -.03930473   3.46979    .10330415  6.906667  -.006779671
      "Q3 2004" 6.86333333333333 638736              4.5  1.20732722731057 40.5533333333333 13.367247  3.702618 1.9261932 178 13.385754  -.018507004 3.5730944    .12952352      6.86 .00048577785
      "Q4 2004" 6.33333333333333 691973 4.13333333333333  1.24275062137531            42.73 13.447302  3.754901 1.8458267 179 13.367247    .08005524  3.702618    .05228329  6.863333    -.0803665
      end
      format %tq time
      Autocorrelation and Partial Autocorrelation codes:
      Code:
      ac d.lrgdp
      Code:
      pac d.lrgdp
      Graph Plotted:
      twoway (tsline lrgdp) (tsline op, yaxis(2))
      Thank you.
      Last edited by Shazzle Singh; 11 Jan 2019, 17:01.

      Comment


      • #4
        I plotted the autocorrelation and partial autocorrelations of the first difference of real GDP but can't seem to make up what the picture is trying to illustrate.
        I think you first need to understand ACF and PACF are. Put simply, the ACF is just a correlation coefficient between two points in time, while the PACF is similar, it controls (or partials) for any period in between. So the second spike in the ACF is the correlation between the current period Yt and Yt-2. The PACF in the second spike is the coefficient B from the regression Yt = b + b1Yt-1 + BYt-2. Here you're looking at the relationship between Yt and Yt-2 after controlling all periods in between (Yt-1). These are typically used for ARIMA modelling (there are other uses), but I'm not sure what you're after.

        I find it weird that there are random spikes appearing out of the confidence bands and am not too sure as to how to interpret it.
        You're working with non-seasonally adjusted data. You can see the spike at t = 4,8,12, etc. That's because GDP in the fourth quarter tends to be higher from seasonal factors (the holidays, for example). I would suggest using seasonally adjusted data, it'll make things a lot simpler.

        Secondly, I'm trying to explore the relationship between oil price movements and real gdp and have plotted a line graph. However, again, from the graph, it is extremely challenging to spot for some sort of pattern or trend. I wanted to ask if there is any way of making the graph clearer so that I can try to explore a relationship? Thank you.
        At the very least, I would suggest looking at a scatter of the growth rates. I would also recommend looking into modelling how an oil price shock affects growth via impulse response functions. You can use a VAR for that or a VECM if you have variables that are cointegrated (I'm not sure what variables you're going to use). There's a decent amount of literature on this topic. Hope this helps.

        Comment

        Working...
        X