Announcement

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

  • Vector Autoregressive Model, Impulse Response Functions and Forecast Error Decomposition

    Good Evening everyone,

    I am writing my Master Thesis and have a question regarding my programming and if I did not make a mistake somewhere.

    I am using CDS data from banks from the year 2010 until the end of 2023. I am using the weighted average of the CDS of the banks based on the Total Assets value of the banks to calculate the Country index. Afterwards I calculate the logathimic return of the Country index. I also calculate the general return of the Euribor as the interest rate was negative for some time in Europe and I can not use the logarithmic return in this case.

    In the following I want to create Vector Autoregressive Models with only 2 variables in each model, explicitly the logarithmic return of one Country index and the return of the Euribor. I also want to see which variables causes which, so I use Granger Causality. To analyze how one variable causes the other, I use Impulse Response Functions and Forecast Error Variance Decomposition.

    In the following you will see the extract from my data. In this case you see the logarithmic return of Germany Index and the return of the Euribor as variables.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(logRetGer EURIBOR_ret)
     -.0008014830285189013                     0
       -.00584418500812003 -.0014285714285714457
      -.012739185594069698  -.007153075822603716
      -.006811061390831834 -.0028818443804035088
       -.00648451575592779 -.0014450867052022698
      -.013719130225710039 -.0028943560057886897
       .008814034818116715  -.005805515239477366
       .009069609881145599 -.0014598540145985828
       .010345526811589952 -.0029239766081871066
        .00863079240874731 -.0029325513196480912
      .0038169302922630667  -.004411764705882337
      -.005042368677640866  -.002954209748892156
        .02896551084103673  -.001481481481481528
      .0013641110225295803 -.0029673590504450953
       .012289439781784843 -.0029761904761904656
      -.014296752480117872 -.0014925373134327957
     -.0030742423386257087  -.002989536621823663
        .00400158027583307 -.0029985007496251548
       .004743096737987085                     0
      .0069640995208763165                     0
      .0024376452424326486                     0
      -.005216658290761326                     0
    -.00018017967925330634                     0
        .02580239606151851                     0
       .007002358654900506  -.003007518796992459
       .010371841677900773  -.003016591251885359
      -.005835596314967259                     0
       -.01074118288924797   .001512859304084735
     -.0013974243861093149                     0
       .008973370473476775  .0015105740181269312
        .00807586281750453  -.003016591251885359
       .005774222293185463    .00302571860816947
      -.011153073737283739 -.0015082956259426794
     -.0006444289101124145 -.0030211480362537513
      -.012066391649905419  .0015151515151514694
       -.01195080082200128                     0
       .014909036908611766                     0
       .010880373138635786   -.00302571860816947
       .005371140991983641 -.0015174506828528056
      -.009628323111307227  -.003039513677811523
     -.0028819914264924897 -.0015243902439023849
      -.017474910923017187                     0
      -.010138857447169036                     0
        .00814934651860331 -.0015267175572518665
       -.00918346392829665  -.001529051987767538
      -.010293038032942143 -.0015313935681470214
      -.005160373152986908                     0
       -.01193137496287989 -.0015337423312883347
        .01086081075473966  -.001536098310291889
       .003457071742120132 -.0015384615384614886
       .003626195047814202 -.0046224961479198745
       .005245166957581305                     0
      -.008012453284861137  -.003095975232198178
      .0029392998528342193 -.0015527950310558758
      .0016977529772582616 -.0015552099533436836
       .012481315082787854  -.004672897196261738
     -.0071930215364009635  -.003129890453834161
      -.008109888624258934 -.0015698587127158659
      .0037015497987476186 -.0015723270440252124
       .004245131950873587  .0015748031496063408
       -.01316382013902603 -.0015723270440252124
      -.002255699547970582                     0
        .00939025620288736 -.0015748031496063408
       .004694470243154606   .001577287066246047
     -.0054011035127074425                     0
       .004671443015811678                     0
     -.0010580185215920497     .0047244094488188
       .007237487365698195  .0015673981191222097
       .014639933326672678  .0015649452269170805
     -.0061897790054639005  .0015624999999999112
      -.019719089057449547  .0015600624024960652
      -.008519122386445565  .0031152647975078995
       .005846889976324979                     0
      .0008467025519094847                     0
        .01389685342615629                     0
       .021578501597306062 -.0015527950310558758
       -.00859383468938192 -.0015552099533436836
       .008991888047594853                     0
        .04347040290739087  .0031152647975078995
      -.009218453367740392  .0015527950310558758
       .015235561305605378                     0
         .0239521394521279  .0015503875968991832
       .024483016705930255    .01238390092879249
      -.014804824436020688   .007645259938837912
      -.011762531734938951   .006069802731411222
       .001707812283492125   .003016591251885359
         .0384144596344394   .004511278195488799
       .026065620649810013  .0059880239520957446
       .040446359745061326   .007440476190476275
       .023102563440638275   .007385524372230501
       -.08475933451141952                     0
       .025572234040501397                     0
       -.04047955305713239                     0
      -.008231716844995048  .0014662756598240456
       .029643721022751663  .0014641288433381305
       .013891693235009642  .0014619883040936088
     -.0067611949546571865   .004379562043795415
        .02212268672188685  .0029069767441860517
        .02355279349832604  .0028985507246377384
       .007230757725513529   .004335260115607031
    end
    Here you can see the Do-File I used to run the described mode.

    Code:
    import excel "C:\Users\dbyto\Desktop\Master_Studium\1. Semester\Thesis\stata\VAR_euribor.xlsx", sheet("Tabelle1") firstrow
     
    * Old time variable = t
    tsset t
    format t %td 
    * In this setting: Gaps at weekends
    
    * Load event calendar. Caution: Event calendar file cb must be saved in the same folder and must be opened during the analyses. 
    bcal load cb
    * Define new time variable based on t but omit the weekendes. The start and end date musst be changes in the cb file (range). 
    generate t1 = bofd("cb",t)
    
    * Format new time variable
    format t1 %tbcb
    * Now tsset data using t1 rather t. This solves the gaps in the data. 
    tsset t1 
    
    dfuller logRetFr
    
    dfuller EURIBOR_ret
    
    var logRetFr EURIBOR_ret, lags(1,2,3)
    
    varsoc
    
    varstable
     
    predict error, resid
    
    summarize error
    
    varlmar 
    
    vargranger
    
    irf set irf
    
    irf create IRFlogFrEUR, step(10)
    
    irf graph irf, irf(IRFlogFrEUR) impulse(logRetFr EURIBOR_ret) response(logRetFr EURIBOR_ret)
    
    irf table fevd, irf(IRFlogFrEUR) impulse(logRetFr EURIBOR_ret) response(logRetFr EURIBOR_ret) noci
    
    translate @Results mylog.txt
    
    type mylog.txt
    Hope to hear from you and will be glad to get help.

    Kind Regards

    Dmitrij Bytov'an
Working...
X