Announcement

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

  • #16
    Forecast error variance decomposition.

    I think I know why results are the same, I will just check with my own data before writing down about it. But I think that it is mostly because "svar" alone with cholesky decomposition is equal to a var.

    Comment


    • #17
      Originally posted by Morad Bali View Post
      Forecast error variance decomposition.

      I think I know why results are the same, I will just check with my own data before writing down about it. But I think that it is mostly because "svar" alone with cholesky decomposition is equal to a var.
      I agree. However, now what confuses me is that if -var- itself already considers cholesky decomposition.
      For example, what I have done for irf calculation is this
      Code:
      var vwretd sdvol RET, lags(1/5) 
      irf create myirf, set(myirfs, replace) step(15) order(vwretd sdvol RET)
      but I do not know if (a) -var-already consider cholesky decomposition with
      Code:
      var vwretd sdvol RET, lags(1/5)
      or (b) stata does not considers cholesky decomposition until
      Code:
      irf create myirf, set(myirfs, replace) step(15) order(vwretd sdvol RET)
      I am not sure if either (a) or (b) is correct. That -irf- wrapped in -var- suddenly considers cholesky decomposition is really confusing to me, since I do not specify the way of composition...

      Comment


      • #18
        Originally posted by Wen-Hung Hsu View Post

        I agree. However, now what confuses me is that if -var- itself already considers cholesky decomposition.
        For example, what I have done for irf calculation is this
        Code:
        var vwretd sdvol RET, lags(1/5)
        irf create myirf, set(myirfs, replace) step(15) order(vwretd sdvol RET)
        but I do not know if (a) -var-already consider cholesky decomposition with
        Code:
        var vwretd sdvol RET, lags(1/5)
        or (b) stata does not considers cholesky decomposition until
        Code:
        irf create myirf, set(myirfs, replace) step(15) order(vwretd sdvol RET)
        I am not sure if either (a) or (b) is correct. That -irf- wrapped in -var- suddenly considers cholesky decomposition is really confusing to me, since I do not specify the way of composition...

        According to your previously posts, it sounds like "var" does cholesky decomposition. It is not possible that to change the model while creating the IRF, as creating the IRF (and storing results in it) is happening on the basis of what was estimated by svar. So if you do cholesky in your svar, irf are produced using this specification. Try to change your specification slightly for it not to be Cholesky anymore (and careful about the number of restrictions if you want it all to converge). If you make some changes, and re-run your model, and store new IRF, your IRF should change (at least for the variable on which you have changed the restriction).

        I still didn't have time to make my little experiment with my data, will do soon.

        Comment


        • #19
          Originally posted by Morad Bali View Post


          According to your previously posts, it sounds like "var" does cholesky decomposition. It is not possible that to change the model while creating the IRF, as creating the IRF (and storing results in it) is happening on the basis of what was estimated by svar. So if you do cholesky in your svar, irf are produced using this specification. Try to change your specification slightly for it not to be Cholesky anymore (and careful about the number of restrictions if you want it all to converge). If you make some changes, and re-run your model, and store new IRF, your IRF should change (at least for the variable on which you have changed the restriction).

          I still didn't have time to make my little experiment with my data, will do soon.
          Thanks for the reply. I understand that IRF is based on -svar-. But what confuses me here is whether the prediction of -var- is also based on structured form ( Cholesky here). The reason that I am asking this question is that I need to predict the residual and the coefficients for further calculation. If the residuals and coefficients are in structured form, then there is no need to adjust the contemporaneous terms. If not, the adjust is necessary.

          According to your point, the model is not possible to be changed while creating IRF. Does it mean that the prediction of -var- in the first step also in structured form? Is the adjusting of contemporaneous terms not necessary?

          Comment


          • #20
            About your previous question whether var itself also consider Cholesky decomposition, your results seem to mean that it does. Again, I need to do a few tests with my data to be certain of it.
            But yes, Cholesky decomposition might be the "basic" specification that is used for var.

            For svar this is a non-question as you need to specify matrices A and B to run the svar.

            And yes, I don't see how you could run IRF or else without running your var first (no matter if structured, short term, or else). Stata must use the outcome of var/svar to create the IRF that will be used to obtain OIRF & FEVD.

            So if you want to make some adjustments to your specification (or variables even), you need two distinct codes, two separate "model" files and at least one "irf" file for each model.
            However, for what it's worth, it is possible to have multiple "irf" files for one model (that is one variable set + one particular specification). For example:

            Code:
             
             matrix A = (1,0,0,0,0,0\.,1,0,0,0,0\.,.,1,0,0,0\.,.,.,1,0,0\.,.,.,.,1,0\.,.,.,.,.,1) matrix B = (.,0,0,0,0,0\0,.,0,0,0,0\0,0,.,0,0,0\0,0,0,.,0,0\0,0,0,0,.,0\0,0,0,0,0,.) svar Lln_Oil Lln_REER Lln_CPI Lln_R Lln_GX Lln_GDP, lags(1/4) aeq(A) beq(B) exog(Lln_St) irf set, clear irf set model_sans_St irf create irf_sans_St, step(10) irf graph oirf, impulse(Lln_Oil Lln_REER Lln_CPI Lln_R Lln_GX) response(Lln_GDP)  irf set, clear irf set model_sans_St_2 irf create irf_sans_St_2, step(20) irf graph oirf, impulse(Lln_Oil Lln_REER Lln_CPI Lln_R Lln_GX) response(Lln_GDP)
            From the same model I can have two different IRF files, one with 10 steps, the other with 20 steps. Knowing that the running time depends on the number of steps, this is useful to know.

            Comment


            • #21
              Originally posted by Morad Bali View Post
              About your previous question whether var itself also consider Cholesky decomposition, your results seem to mean that it does. Again, I need to do a few tests with my data to be certain of it.
              But yes, Cholesky decomposition might be the "basic" specification that is used for var.

              For svar this is a non-question as you need to specify matrices A and B to run the svar.

              And yes, I don't see how you could run IRF or else without running your var first (no matter if structured, short term, or else). Stata must use the outcome of var/svar to create the IRF that will be used to obtain OIRF & FEVD.

              So if you want to make some adjustments to your specification (or variables even), you need two distinct codes, two separate "model" files and at least one "irf" file for each model.
              However, for what it's worth, it is possible to have multiple "irf" files for one model (that is one variable set + one particular specification). For example:

              Code:
              matrix A = (1,0,0,0,0,0\.,1,0,0,0,0\.,.,1,0,0,0\.,.,.,1,0,0\.,.,.,.,1,0\.,.,.,.,.,1) matrix B = (.,0,0,0,0,0\0,.,0,0,0,0\0,0,.,0,0,0\0,0,0,.,0,0\0,0,0,0,.,0\0,0,0,0,0,.) svar Lln_Oil Lln_REER Lln_CPI Lln_R Lln_GX Lln_GDP, lags(1/4) aeq(A) beq(B) exog(Lln_St) irf set, clear irf set model_sans_St irf create irf_sans_St, step(10) irf graph oirf, impulse(Lln_Oil Lln_REER Lln_CPI Lln_R Lln_GX) response(Lln_GDP) irf set, clear irf set model_sans_St_2 irf create irf_sans_St_2, step(20) irf graph oirf, impulse(Lln_Oil Lln_REER Lln_CPI Lln_R Lln_GX) response(Lln_GDP)
              From the same model I can have two different IRF files, one with 10 steps, the other with 20 steps. Knowing that the running time depends on the number of steps, this is useful to know.
              Thank you for your reply. However, I discovered something strange. With the specified matrix ( eg. Chelosky decomposition), and the contemporaneous terms, there should be corresponding contemporary response in the IRF function. For example,
              Code:
              matrix A1 = (1,0,0 \ .,1,0 \ .,.,1)
              matrix B1 = (.,0,0 \ 0,.,0 \ 0,0,.)
              svar v1 v2 v3, lags(1/5) aeq(A1) beq(B1)
              irf create myirf, set(myirfs, replace) step(15)
              This implies that there should be contemporaneous relationship of v1-v2 and v1-v3 ( impulse variable - response variable), and contemporaneous relationship of v2-v3. However, in the IRF file ( myirf here in this example), STATA treats the variables as there are no contemporaneous relationship. Which is, the irf for (impulse = v1, response = v2/ v3) = 0. It shouldn't be 0, since there are contemporaneous impact. How can I correctly do so that there are value for irf of v1-v2, v1-v3, v2-v3 ?
              Last edited by Wen-Hung Hsu; 21 Nov 2022, 14:59.

              Comment


              • #22
                Originally posted by Wen-Hung Hsu View Post

                Thank you for your reply. However, I discovered something strange. With the specified matrix ( eg. Chelosky decomposition), and the contemporaneous terms, there should be corresponding contemporary response in the IRF function. For example,
                Code:
                matrix A1 = (1,0,0 \ .,1,0 \ .,.,1)
                matrix B1 = (.,0,0 \ 0,.,0 \ 0,0,.)
                svar v1 v2 v3, lags(1/5) aeq(A1) beq(B1)
                irf create myirf, set(myirfs, replace) step(15)
                This implies that there should be contemporaneous relationship of v1-v2 and v1-v3 ( impulse variable - response variable), and contemporaneous relationship of v2-v3. However, in the IRF file ( myirf here in this example), STATA treats the variables as there are no contemporaneous relationship. Which is, the irf for (impulse = v1, response = v2/ v3) = 0. It shouldn't be 0, since there are contemporaneous impact. How can I correctly do so that there are value for irf of v1-v2, v1-v3, v2-v3 ?
                Clarification: The sentence of
                "Which is, the irf for (impulse = v1, response = v2/ v3) = 0"
                is when step = 0.

                Comment


                • #23
                  That's strange. Might be because of the order you do things. Usually I do:

                  Code:
                   
                   matrix A1 = (1,0,0 \ .,1,0 \ .,.,1) matrix B1 = (.,0,0 \ 0,.,0 \ 0,0,.) svar v1 v2 v3, lags(1/5) aeq(A1) beq(B1) irf set, clear irf set model1 irf create irf1, step(15)
                  Try it to see if it changes something.

                  Comment


                  • #24
                    Originally posted by Morad Bali View Post
                    That's strange. Might be because of the order you do things. Usually I do:

                    Code:
                    matrix A1 = (1,0,0 \ .,1,0 \ .,.,1) matrix B1 = (.,0,0 \ 0,.,0 \ 0,0,.) svar v1 v2 v3, lags(1/5) aeq(A1) beq(B1) irf set, clear irf set model1 irf create irf1, step(15)
                    Try it to see if it changes something.
                    I re-organized the coding and here is what I tried
                    Code:
                    gen mydate =_n
                    xtset id mydate
                    matrix A1 = (1,0,0 \ .,1,0 \ .,.,1)
                    matrix B1 = (.,0,0 \ 0,.,0 \ 0,0,.)
                    svar v1 v2 v3, lags(1/5) aeq(A1) beq(B1)
                    irf set, clear
                    irf set model1
                    irf create irf1, step(15)
                    use model1.irf,clear
                    However, the results of irf are still the same. The estimation of the contemporaneous terms ( v1-v2/ v1-v3/ v2-v3 when step = 0) are all still 0.
                    Besides, svar is way too inefficient to process the data. It takes more than 1hr just to loop through each stock in one year. Any recommendation for accomplishing the job more efficient is welcome !
                    Last edited by Wen-Hung Hsu; 22 Nov 2022, 11:47.

                    Comment


                    • #25
                      Originally posted by Wen-Hung Hsu View Post

                      I re-organized the coding and here is what I tried
                      Code:
                      gen mydate =_n
                      xtset id mydate
                      matrix A1 = (1,0,0 \ .,1,0 \ .,.,1)
                      matrix B1 = (.,0,0 \ 0,.,0 \ 0,0,.)
                      svar v1 v2 v3, lags(1/5) aeq(A1) beq(B1)
                      irf set, clear
                      irf set model1
                      irf create irf1, step(15)
                      use model1.irf,clear
                      However, the results of irf are still the same. The estimation of the contemporaneous terms ( v1-v2/ v1-v3/ v2-v3 when step = 0) are all still 0.
                      Besides, svar is way too inefficient to process the data. It takes more than 1hr just to loop through each stock in one year. Any recommendation for accomplishing the job more efficient is welcome !
                      I need to see your data. Please check this:
                      https://www.statalist.org/forums/for...-for-statalist

                      Comment


                      • #26
                        Here is the data
                        Code:
                        * Example generated by -dataex-. For more info, type help dataex
                        clear
                        input double PERMNO long date double(RET vwretd) float(size sdvol year id)
                        10006   3    .03865979239344597           4.648954e-06 71.43175  115862.5 1960 78
                        10006   4   .022332506254315376    .007798498000000001   73.027    108150 1960 78
                        10006   5                     0            -.004387099   73.027         0 1960 78
                        10006   6  -.014563106931746006   -.006302413000000001  71.9635    -50750 1960 78
                        10006   7  -.007389162667095661            -.003181282 71.43175    -30225 1960 78
                        10006  10  -.017369726672768593             -.01142776   70.191    -94050 1960 78
                        10006  11  -.005050505045801401            -.005640277  69.8365    -44325 1960 78
                        10006  12  -.005076142027974129            -.005100299   69.482    -34300 1960 78
                        10006  13   .030612245202064514    .005762501000000001   71.609     35350 1960 78
                        10006  14   .009900989942252636  .00008260490999999999   72.318    122400 1960 78
                        10006  17 -.0049019609577953815             -.00813024  71.9635    -50750 1960 78
                        10006  18                     0            -.009777954  71.9635         0 1960 78
                        10006  19  -.017241379246115685            -.002773081 70.72275    -29925 1960 78
                        10006  20   .002506265649572015             .002360102     70.9     85000 1960 78
                        10006  21   .009999999776482582             .003016103   71.609     25250 1960 78
                        10006  24  -.002475247485563159             -.01026663 71.43175  -15112.5 1960 78
                        10006  25  -.012406948022544384             .001584803  70.5455    -44775 1960 78
                        10006  26   -.01005025114864111            -.002537099  69.8365    -98500 1960 78
                        10006  27   .007614213041961193   -.009771914000000001 70.36825     39700 1960 78
                        10006  28  -.017632242292165756            -.009597647  69.1275   -117000 1960 78
                        10006  31  -.012820512987673283   .0051717510000000005 68.24125    -77000 1960 78
                        10006  32     .0181818176060915               .0155708   69.482     58800 1960 78
                        10006  33  -.010204081423580647            -.008165478   68.773   -101850 1960 78
                        10006  34   .007731958758085966           -.0005813497 69.30475     39100 1960 78
                        10006  35 -.0025575447361916304            -.004769153  69.1275    -39000 1960 78
                        10006  38 -.0025641026441007853   -.009837535000000001 68.95025    -87525 1960 78
                        10006  39    .02570694126188755    .008982898000000001 70.72275   54862.5 1960 78
                        10006  40   .002506265649572015   -.005426065000000001     70.9     20000 1960 78
                        10006  41  .0024999999441206455  -.0048993000000000005 71.07725   35087.5 1960 78
                        10006  42   .014962593093514442    .004666615000000001 72.14075   45787.5 1960 78
                        10006  45  .0024570024106651545   -.004848740000000001   72.318     76500 1960 78
                        10006  46  -.007352941203862429   -.008772124000000001 71.78625  -75937.5 1960 78
                        10006  47   .007407407276332378             .006324385   72.318    137700 1960 78
                        10006  48   .009803921915590763              .01368883   73.027    154500 1960 78
                        10006  49   .004854368977248669   .0073403600000000015  73.3815    155250 1960 78
                        10006  53   -.01690821163356304   -.004926641000000001  71.2545    -35175 1960 78
                        10006  54                     0  -.0028208350000000003  71.2545         0 1960 78
                        10006  55  -.002487562131136656             .004638512 71.07725  -55137.5 1960 78
                        10006  56   .007481296546757221    .004323939000000001   71.609     85850 1960 78
                        10006  59  -.002475247485563159            -.000621328 71.43175  -35262.5 1960 78
                        10006  60   .004962779115885496            -.001338409 71.78625     10125 1960 78
                        10006  61  -.009876543655991554   -.006937054000000001 71.07725  -75187.5 1960 78
                        10006  62  -.017456358298659325             -.01532618  69.8365   -113275 1960 78
                        10006  63  -.017766498029232025  -.0037686520000000004 68.59575 -111262.5 1960 78
                        10006  66  -.018087854608893394             -.01105556   67.355    -42750 1960 78
                        10006  67  -.010526316240429878   -.009165752000000001   66.646    -28200 1960 78
                        10006  68   .005319148767739534    .011078020000000001  67.0005     23625 1960 78
                        10006  69   .010582010261714458  -.0032073690000000007  67.7095     38200 1960 78
                        10006  70  -.007853402756154537             .007461806 67.17775  -52112.5 1960 78
                        10006  73   .013192611746490002             .001969536   68.064     24000 1960 78
                        10006  74               .015625    .007948509000000001  69.1275     39000 1960 78
                        10006  75                     0             .005396182  69.1275         0 1960 78
                        10006  76  -.015384615398943424  -.0017011849999999998   68.064    -28800 1960 78
                        10006  77              -.015625   .0008937426999999999  67.0005    -23625 1960 78
                        10006  80                     0             .001032842  67.0005         0 1960 78
                        10006  81                     0   .0036044920000000004  67.0005         0 1960 78
                        10006  82  .0026455025654286146             .007862628 67.17775     28425 1960 78
                        10006  83  .0052770450711250305   .0043164810000000005 67.53225   33337.5 1960 78
                        10006  84                     0 .000037095679999999996 67.53225         0 1960 78
                        10006  87   .007874015718698502  -.0022199610000000003   68.064     14400 1960 78
                        10006  88                     0            -.001741619   68.064         0 1960 78
                        10006  89                     0  -.0013858280000000002   68.064         0 1960 78
                        10006  90  -.013020833022892475            -.006133015 67.17775    -18950 1960 78
                        10006  91 -.0052770450711250305             .002010226 66.82325  -14137.5 1960 78
                        10006  94  -.007957560010254383             .001829586  66.2915    -60775 1960 78
                        10006  95   -.01604278013110161             .005499762   65.228    -27600 1960 78
                        10006  96   .029891304671764374    .010100050000000001 67.17775   42637.5 1960 78
                        10006  97   .018469657748937607            .0007903875  68.4185     33775 1960 78
                        10006  98    .01295336801558733  -.0019942930000000003 69.30475      9775 1960 78
                        10006 101  .0025575447361916304            -.003782535   69.482     49000 1960 78
                        10006 102   .005102040711790323   .0022702160000000002  69.8365     19700 1960 78
                        10006 103  -.005076142027974129           -.0001411817   69.482    -34300 1960 78
                        10006 104  -.005102040711790323              .00266341  69.1275    -39000 1960 78
                        10006 108  -.015384615398943424             .002326248   68.064    -96000 1960 78
                        10006 109                     0   -.007327487999999999   68.064         0 1960 78
                        10006 110              -.015625             -.01157072  67.0005    -23625 1960 78
                        10006 111   -.01587301678955555   .0033597370000000007   65.937    -23250 1960 78
                        10006 112  -.005376344081014395             -.00264063  65.5825    -32375 1960 78
                        10006 115                     0             -.01014164  65.5825         0 1960 78
                        10006 116  -.029729729518294334             .003681965 63.63275  -31412.5 1960 78
                        10006 117  -.002785515272989869            -.000160142  63.4555    -49225 1960 78
                        10006 118   -.03910614550113678   -.008444440000000001   60.974    -43000 1960 78
                        10006 119   .011627906933426857  -.0034230890000000003   61.683     34800 1960 78
                        10006 122    -.0517241396009922   -.004886028000000001  58.4925    -78375 1960 78
                        10006 123   .027272727340459824    .013756659999999999 60.08775     76275 1960 78
                        10006 124   .044247787445783615             .004162762  62.7465    119475 1960 78
                        10006 125  -.005649717524647713  -.0031448550000000002   62.392   -127600 1960 78
                        10006 126   .014204545877873898  -.0009699778000000001 63.27825     53550 1960 78
                        10006 129  -.014005602337419987   .0010128420000000001   62.392    -39600 1960 78
                        10006 131  -.019886363297700882             .002443152 61.15125  -38812.5 1960 78
                        10006 132  -.011594203300774097             .005493488 60.44225    -34100 1960 78
                        10006 133    .03812316805124283             .009154771  62.7465     17700 1960 78
                        10006 136   .005649717524647713  -.0005380566000000001   63.101     71200 1960 78
                        10006 137    .01123595517128706   .0039008540000000005    63.81      9000 1960 78
                        10006 138                     0             .000320771    63.81         0 1960 78
                        10006 139   .008333333767950535             .004453865 64.34175   31762.5 1960 78
                        10006 140    .01652892492711544             .002158872 65.40525     46125 1960 78
                        10006 143    .01084010861814022  -.0006362553000000001 66.11425   32637.5 1960 78
                        10006 144  -.013404825702309608           -.0004946725 64.34175  -22687.5 1960 78
                        10006 145  -.011019283905625343           -.0001997464 63.63275    -26925 1960 78
                        end
                        format %td date

                        Comment

                        Working...
                        X