Announcement

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

  • fcast command destroys data set

    Hey statalist!

    I am working on an assignment where I try to explain stock returns by changes in oil prices. For this purpose, I use the SVAR model. I have identified the model by using cholesky decomposition. For now, I will compute the forecast for the variables in the model. However, when using the fcast command in stata. My data set gets destroyed. I have uploaded a photo of my command and the data set after the execution of the fcast command. Before i execute the command, my dataset looks normal with 118 observation running from 2013 to 2022. Can anyone see what I am doing wrong?

    Best regards
    Alexander

    Click image for larger version

Name:	Skærmbillede 2023-02-11 kl. 15.17.12.png
Views:	2
Size:	87.5 KB
ID:	1701215

    Click image for larger version

Name:	Skærmbillede 2023-02-11 kl. 15.17.31.png
Views:	1
Size:	94.0 KB
ID:	1701217
    Attached Files

  • #2
    Your question really isn't clear without more detail, or at a minimum it is too difficult to guess at a good answer from what you have shared. Please help us help you by providing sufficient information to reproduce your problem.

    Most importantly, stop showing pictures of code and data. Please take a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. It is particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

    Show example data using the dataex command after you have created your numeric values.
    Code:
    dataex qdate clcrudeoil-cinterestrate, count(120)
    Show your code by copying it from the Do-file Editor window and pasting it into your Statalist post using CODE delimiters as explained in the FAQ.

    Comment


    • #3
      Alexander:
      as an aside to William's helpful advice, please take duly note of https://www.statalist.org/forums/help#adviceextras #4. Thanks.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Thanks for the answers! I'm a new user to both Stata and Statalist, so I apologize for the lack of information I provided. I will give it another try.
        I'm trying to forecast the variables in an SVAR model and afterwards make a graph. I have identified the model and used the 'fcast compute' function in Stata 17.0 to forecast. When I do that, I get error r(198). When I look at the data set after running 'fcast compute' I see that there are no observations of the variables I include in the 'fcast graph' code. All codes are illustrated below.

        Code:
        clear
        clear results
        log using example1.log, replace
        
        //Load K&L ch2 data
        import delimited "data.white.noise.csv", rowrange(2:119) clear
        
        destring v2, dpcomma force generate(clcrudeoil)
        destring v3, dpcomma force generate(dax)
        destring v4, dpcomma force generate(ftse)
        destring v6, dpcomma force generate(eurostocks)
        destring v10, dpcomma force generate(mscieuropeenergy)
        destring v11, dpcomma force generate(cinterestrate)
        
        gen qdate=date(v1,"DMY")
        format qdate %tq
        tsset qdate
        tsreport
        
        dataex qdate clcrudeoil-cinterestrate, count(120)
        
        //Estimate SVAR(4) with Cholesky
        matrix A = (.,0,0,0,0,0\.,.,0,0,0,0\.,.,.,0,0,0\.,.,.,.,0,0\.,.,.,.,.,0\.,.,.,.,.,.)
        matrix B = (1,0,0,0,0,0\0,1,0,0,0,0\0,0,1,0,0,0\0,0,0,1,0,0\0,0,0,0,1,0\0,0,0,0,0,1)
        svar cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy, lags(1 2 3 4 5 6) aeq(A) beq(B)
        matlist e(A)
        matlist e(B)
        
        
        fcast compute f_, step(6)
        fcast graph f_cinterestrate f_clcrudeoil f_dax f_ftse f_eurostocks f_mscieuropeenergy
        
        
        log close

        Prior to point where I used the 'fcast compute' function, my data set looked as follows. In the data set, I have more variables in the set which I do not use as input in the SVAR model.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input double clcrudeoil str12 v3 double dax str12 v4 double ftse str12(v5 v6) double eurostocks str12(v7 v8 v9 v10) double mscieuropeenergy str7 v11 double cinterestrate
         .054747398 "0,006924836"   .006924836 "0,008006842"   .008006842 "0,002261617"  "-0,00361869"   -.00361869 "-0,037702149" "-0,036588208" "0,022230053"  "0,005952803"   .005952803 "-0,032" -.032
        -.039545769 "0,01518862"     .01518862 "0,002866617"   .002866617 "0,033587749"  "0,033528708"   .033528708 "0,063005051"  "0,093159012"  "0,009451307"  "0,008946812"   .008946812 "-0,003" -.003
          -.0160711 "0,054984325"   .054984325 "0,023789603"   .023789603 "0,023812796"  "0,021253687"   .021253687 "-0,011687849" "0,02662387"   "0,034121631"  "0,008378718"   .008378718 "-0,013" -.013
          .04870214 "-0,046667561" -.046667561 "-0,055843077" -.055843077 "-0,0531025"   "-0,060314698" -.060314698 "-0,067050453" "-0,114720043" "-0,051708955" "-0,058786872" -.058786872 "-0,007" -.007
         .084081447 "0,039796613"   .039796613 "0,06525492"     .06525492 "0,067875397"  "0,063613554"   .063613554 "0,08640035"   "0,081570127"  "0,073188427"  "0,03648937"     .03648937 "0,012"   .012
           .0246392 "-0,020882144" -.020882144 "-0,031434544" -.031434544 "-0,014754464" "-0,016899373" -.016899373 "-0,01694453"  "0,012125698"  "-0,018604148" "0,009369011"   .009369011 "-0,005" -.005
        -.050682339 "0,060624572"   .060624572 "0,007686034"   .007686034 "0,053297337"  "0,063122618"   .063122618 "0,10802726"   "0,045116924"  "0,033036674"  "-0,001336052" -.001336052 "0,005"   .005
        -.059904174 "0,051140277"   .051140277 "0,041659058"   .041659058 "0,037758481"  "0,060418575"   .060418575 "0,078575239"  "0,109932629"  "0,045343007"  "0,042951697"   .042951697 "0,01"     .01
        -.038714512 "0,041109507"   .041109507 "-0,012012306" -.012012306 "-0,0010884"   "0,006092016"   .006092016 "-0,007095348" "-0,017054991" "0,011813635"  "-0,008236565" -.008236565 "0,016"   .016
         .059659836 "0,0156146"       .0156146 "0,014813768"   .014813768 "0,000172285"  "0,007244123"   .007244123 "0,008040579"  "-0,002826804" "0,01321397"   "0,014431586"   .014431586 "-0,038" -.038
        -.009494227 "-0,025719837" -.025719837 "-0,035360323" -.035360323 "-0,030314599" "-0,030569315" -.030569315 "0,00035294"   "0,023757744"  "-0,037183603" "-0,04301436"   -.04301436 "0,02"     .02
         .050990653 "0,041433496"   .041433496 "0,045966171"   .045966171 "0,058179618"  "0,044881153"   .044881153 "0,019556057"  "0,052737258"  "0,030218431"  "0,053642802"   .053642802 "0,01"     .01
        -.009893797 "-0,014049616" -.014049616 "-0,031033673" -.031033673 "-0,003761275" "0,003927944"   .003927944 "0,022374483"  "0,061123419"  "0,01171777"   "0,000665513"   .000665513 "-0,013" -.013
        -.018279865 "0,004951909"   .004951909 "0,027531042"   .027531042 "0,021835364"  "0,011636513"   .011636513 "0,011459794"  "0,004216316"  "-0,006597059" "0,063913275"   .063913275 "-0,01"   -.01
         .029342683 "0,03540892"     .03540892 "0,009510282"   .009510282 "0,007171206"  "0,014447894"   .014447894 "0,032479205"  "-0,007054461" "0,016627138"  "0,005250985"   .005250985 "0,021"   .021
         .025568482 "-0,011082873" -.011082873 "-0,014693528" -.014693528 "-0,021402479" "-0,005042224" -.005042224 "0,011556947"  "-0,016027954" "0,014587068"  "0,036191779"   .036191779 "-0,023" -.023
        -.070777296 "-0,043281498" -.043281498 "-0,00205073"   -.00205073 "-0,039951705" "-0,034919956" -.034919956 "-0,019801346" "-0,03346469"  "-0,021444996" "-0,040808978" -.040808978 "-0,008" -.008
        -.022769232 "0,006663846"   .006663846 "0,013319247"   .013319247 "0,031770031"  "0,018334077"   .018334077 "0,002017334"  "-0,005848581" "0,021865493"  "0,009384972"   .009384972 "0,008"   .008
        -.051315234 "0,000436106"   .000436106 "-0,028891088" -.028891088 "0,008034622"  "0,016799942"   .016799942 "0,009013124"  "0,021594593"  "0,01938857"   "-0,021570694" -.021570694 "0"          0
        -.123862249 "-0,015561044" -.015561044 "-0,011513396" -.011513396 "-0,041471931" "-0,034907763" -.034907763 "-0,032118609" "-0,053040119" "-0,023317662" "-0,073487488" -.073487488 "-0,013" -.013
        end
        ------------------ copy up to and including the previous line ------------------

        Listed 20 out of 118 observations



        After I run the 'fcast compute' command, My data look as

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input double clcrudeoil str12 v3 double dax str12 v4 double ftse str12(v5 v6) double eurostocks str12(v7 v8 v9 v10) double mscieuropeenergy str7 v11 double cinterestrate
         .054747398 "0,006924836"   .006924836 "0,008006842"   .008006842 "0,002261617"  "-0,00361869"   -.00361869 "-0,037702149" "-0,036588208" "0,022230053"  "0,005952803"   .005952803 "-0,032" -.032
        -.039545769 "0,01518862"     .01518862 "0,002866617"   .002866617 "0,033587749"  "0,033528708"   .033528708 "0,063005051"  "0,093159012"  "0,009451307"  "0,008946812"   .008946812 "-0,003" -.003
          -.0160711 "0,054984325"   .054984325 "0,023789603"   .023789603 "0,023812796"  "0,021253687"   .021253687 "-0,011687849" "0,02662387"   "0,034121631"  "0,008378718"   .008378718 "-0,013" -.013
          .04870214 "-0,046667561" -.046667561 "-0,055843077" -.055843077 "-0,0531025"   "-0,060314698" -.060314698 "-0,067050453" "-0,114720043" "-0,051708955" "-0,058786872" -.058786872 "-0,007" -.007
         .084081447 "0,039796613"   .039796613 "0,06525492"     .06525492 "0,067875397"  "0,063613554"   .063613554 "0,08640035"   "0,081570127"  "0,073188427"  "0,03648937"     .03648937 "0,012"   .012
           .0246392 "-0,020882144" -.020882144 "-0,031434544" -.031434544 "-0,014754464" "-0,016899373" -.016899373 "-0,01694453"  "0,012125698"  "-0,018604148" "0,009369011"   .009369011 "-0,005" -.005
        -.050682339 "0,060624572"   .060624572 "0,007686034"   .007686034 "0,053297337"  "0,063122618"   .063122618 "0,10802726"   "0,045116924"  "0,033036674"  "-0,001336052" -.001336052 "0,005"   .005
        -.059904174 "0,051140277"   .051140277 "0,041659058"   .041659058 "0,037758481"  "0,060418575"   .060418575 "0,078575239"  "0,109932629"  "0,045343007"  "0,042951697"   .042951697 "0,01"     .01
        -.038714512 "0,041109507"   .041109507 "-0,012012306" -.012012306 "-0,0010884"   "0,006092016"   .006092016 "-0,007095348" "-0,017054991" "0,011813635"  "-0,008236565" -.008236565 "0,016"   .016
         .059659836 "0,0156146"       .0156146 "0,014813768"   .014813768 "0,000172285"  "0,007244123"   .007244123 "0,008040579"  "-0,002826804" "0,01321397"   "0,014431586"   .014431586 "-0,038" -.038
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
                  . ""                       . ""                       . ""             ""                       . ""             ""             ""             ""                       . ""           .
        end
        ------------------ copy up to and including the previous line ------------------

        Listed 20 out of 3303 observations



        I also notice that I now have 3303 observation, instead of the original 118. My purpose of the first code i illustrated, is to forecast and graph the forecasts. I hope this make sense to you. Otherwise, please let me know. Thank you!

        Alexander

        Comment


        • #5
          That is very close to what is wanted, thank you - you are a quick study.

          We both made mistakes on the dataex command.

          I did not realize that destring would order the created variable immediately following the one that it was created from. So the destring command I should have requested was
          Code:
          dataex qdate cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy, count(120)
          which - in my defense - is what I wanted to write, but wasn't sure I'd get it typed correctly since I couldn't copy and paste from the displayed code.

          The output you provided does not include qdate and includes only 20 out of 118 observations rather than the full 118 observations. (Specifying 120 instead of 118 was a small trap on my part to be sure there actually were exactly 118 observations. I take nothing for granted. ) I think perhaps the command you showed isn't the command you ran.

          So if you were to run and post the output of the dataex command above, I'd be able to recreate your experience and I hope figure out what you are seeing.

          Comment


          • #6
            Yes I see I made a mistake! I have corrected it now. The output of the dataex command is shown below.

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input float qdate double(cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy)
            19361  -.032  .054747398  .006924836  .008006842  -.00361869  .005952803
            19362  -.003 -.039545769   .01518862  .002866617  .033528708  .008946812
            19363  -.013   -.0160711  .054984325  .023789603  .021253687  .008378718
            19364  -.007   .04870214 -.046667561 -.055843077 -.060314698 -.058786872
            19365   .012  .084081447  .039796613   .06525492  .063613554   .03648937
            19366  -.005    .0246392 -.020882144 -.031434544 -.016899373  .009369011
            19367   .005 -.050682339  .060624572  .007686034  .063122618 -.001336052
            19368    .01 -.059904174  .051140277  .041659058  .060418575  .042951697
            19369   .016 -.038714512  .041109507 -.012012306  .006092016 -.008236565
            19370  -.038  .059659836    .0156146  .014813768  .007244123  .014431586
            19724    .02 -.009494227 -.025719837 -.035360323 -.030569315  -.04301436
            19725    .01  .050990653  .041433496  .045966171  .044881153  .053642802
            19726  -.013 -.009893797 -.014049616 -.031033673  .003927944  .000665513
            19727   -.01 -.018279865  .004951909  .027531042  .011636513  .063913275
            19728   .021  .029342683   .03540892  .009510282  .014447894  .005250985
            19729  -.023  .025568482 -.011082873 -.014693528 -.005042224  .036191779
            19730  -.008 -.070777296 -.043281498  -.00205073 -.034919956 -.040808978
            19731   .008 -.022769232  .006663846  .013319247  .018334077  .009384972
            19732      0 -.051315234  .000436106 -.028891088  .016799942 -.021570694
            19733  -.013 -.123862249 -.015561044 -.011513396 -.034907763 -.073487488
            19734   .038 -.196829065  .070117842  .026907631  .044200403 -.078495726
            19735  -.018  -.21655157 -.017563634 -.023284077 -.032144648 -.018921125
            20089   -.02 -.099184769  .090639485   .02791768  .065156384  .021479353
            20090   .013  .031022896  .066141653  .029226302  .073866756  .090256182
            20091      0 -.044378687  .049511212 -.024993306  .027335371 -.043123939
            20092  -.021  .225326042 -.042769742  .027696573  -.02212107  .076366217
            20093   .011  .011173301 -.003541004  .003419231 -.012393551 -.039891863
            20094 -.0105  -.01386012 -.041077396 -.066354735  -.04102185  -.05981732
            20095  .0335 -.232774444  .033259114  .026882462  .051511258 -.002629657
            20096  -.028  .043196084 -.092804928 -.066953592 -.091943489 -.104584737
            20097 -.0132 -.087233131 -.058387089  -.02982263 -.051675572 -.070914445
            20098  .0182  .032725433  .123151741  .049406016  .102416574  .122105819
            20099   .096 -.112084557   .04903992 -.000786029  .025808679  .022046132
            20100   .028 -.117302959  -.05615947 -.017899369 -.068140142 -.112151685
            20454   .092 -.096877282 -.087954866 -.025396007 -.068073034 -.018070206
            20455    .01  .003859289 -.030894734  .002186137  -.03262301  .009509554
            20456  -.062   .12751332  .049509236  .012761826   .02008996  .000261666
            20457  -.007  .180407014  .007371424  .010848759  .007747269  .079700035
            20458    .03  .066958283  .022290135 -.001778308  .011647145 -.030689711
            20459   -.01 -.015806549 -.056773337  .043901335 -.064873934  .085319113
            20460  -.008 -.149952319  .067913625  .033838996  .043990031 -.040764625
            20461   .087  .071873334  .024685852  .008488452  .010823336 -.014005602
            20462  -.064  .076215051 -.007710034  .017373712 -.006910057  .006493506
            20463  -.023 -.029024119  .014650338  .007955845  .017656816  .029758065
            20464   .191   .05359538 -.002316922 -.024507421 -.001191392  .032265643
            20465   .053  .083025559  .079016569  .052926167  .078289821  .100978681
            20820   .048 -.017084805  .004725173 -.006115223 -.018185576 -.055264609
            20821  -.066  .022468648  .025929082  .023142207  .027526713 -.012035011
            20822   .335 -.065217638  .040429561  .008188957  .054620874  .012033961
            20823  -.066 -.025419161  .010163349 -.016247617  .016755548 -.025459586
            20824   .195 -.020686862  .014234592  .043866273 -.001404656  .006138184
            20825  -.028  -.04833497  -.02298364 -.027557364 -.031708298 -.056543412
            20826   .143  .085906655 -.016784421  .008106423  .002173231  .015298478
            20827  -.044 -.060387955 -.005150084  .007951709 -.008085558 -.018097087
            20828   .011  .089848058  .064119962 -.007786699  .050674125  .085745926
            20829    .03  .051119097  .031235043  .016319533    .0220037  .054932245
            20830   .155  .054047864 -.015540188 -.022208491 -.028312851 -.018508287
            20831   .127  .051275873 -.008164939  .049285692 -.018479354   .02265691
            21185   .201  .068904597  .021044092 -.020060434  .030060275  .005366726
            21186   .045 -.048913762  -.05713872 -.040039556 -.047192107 -.047289899
            21187   .114  .052152756 -.027269547 -.024239793 -.022524252 -.004166367
            21188   .003  .054391355  .042604902    .0641512  .052066042  .127461588
            21189   .122 -.022565665 -.000572466   .02249211 -.036722541  .023928343
            21190   .013  .100800612 -.023712226 -.005374958 -.003243656  .004873782
            21191   .139 -.075467888  .040589956  .014643319  .038252444  .007275215
            21192   .036  .015011829 -.034472688 -.040824596 -.037608956 -.038273968
            21193   .178  .048244238 -.009489601  .010464963  .001856819  .054047115
            21194   .082 -.114733084 -.065259869 -.050877473 -.059334549 -.049144388
            21195   .113 -.248693023 -.016621082 -.020743256 -.007624683 -.067055207
            21196   .128 -.114719796 -.062029414 -.036117669 -.054113761 -.051005698
            21550  -.038  .169355231  .058162925  .035778143  .052645081  .064163773
            21551   .018  .061815911  .030657561  .015193325   .04394147  .027122561
            21552   .037   .04977169   .00090312  .028900043  .016205514  .020582396
            21553  -.023  .060800666  .070973205  .019099653   .04860504  .002464172
            21554  -.066  -.17779419 -.050002916 -.034578376 -.066633093 -.053043535
            21555  -.181  .088832148  .057301029  .036851534  .058913008  .029988387
            21556  -.187  .001879539 -.016917766  .021701862 -.001969088   -.0155193
            21557   .098 -.061243625 -.020490539 -.050034402 -.011563812 -.082794395
            21558  -.146 -.018870213  .040940492  .027893018  .041639916  .062724936
            21559    -.4  .002032333  .035299902 -.021574712  .009794226 -.025571912
            21560   .105  .018107491  .028724336  .013540957  .027513518   -.0000709
            21561  -.174   .10143766  .000954188  .026667012  .011224275  .017094623
            21915    .09 -.169110809 -.020155468 -.033998282 -.027833331 -.077062557
            21916  -.124 -.141431295 -.084087392 -.096815678 -.085533562 -.153846154
            21917 -1.406 -.781866083 -.164377836 -.138079904 -.162964899 -.156724415
            21918   .051 -.083466531  .093177829  .040418127  .050604614 -.036429101
            21919    .04  .633268698  .066768002  .029721023  .041759878 -.035388504
            21920      0  .101209902  .062491531   .01532765  .060281293 -.000455737
            21921  -.033  .025145906  .000197386 -.044082895 -.018475172 -.088681181
            21922   -.01  .056482193  .051327988  .011158474  .030932609  .021013133
            21923  -.012 -.057724583 -.014263776 -.016344237 -.024109934 -.125444077
            21924    .01  -.11669586  -.09437156 -.049237142 -.073709689 -.069897745
            21925  -.003   .23652112   .15010453  .123522799  .180626122  .328915663
            21926  -.025  .067786439  .032173264  .031012465  .017208106  .019832276
            22281      0  .073106411 -.020840774 -.008212961 -.020041434  .020224469
            22282  -.026   .16395468  .026310089  .011856492  .044521807   .09846422
            22283  -.017 -.038791537  .088642412  .035505897  .077760117  .014179474
            22284  -.003  .072053318  .008499941  .038158195  .014168672 -.035979664
            22285  -.005  .042192555  .018843928  .007575529  .016282826   .02484787
            22286   .043  .102385649  .007127234  .002116022  .006149337  .030677882
            22287  -.002   .00651203  .000859569 -.000734639  .006151121 -.033605377
            22288  -.011 -.076555444  .018701281  .012428366  .026192747  .014803775
            22289   .018  .091054288  -.03627387 -.004674354  -.03534688  .127178383
            22290   .003   .10779657  .028051156  .021329529  .050018774   .03595935
            22291    .05 -.233306302 -.037519831  -.02461047 -.044111835  -.07042844
            22292   -.05  .127905898  .051968427   .04605033  .057924323  .054388022
            22646  -.015  .158755708 -.026041149  .010810423 -.028803674  .130025663
            22647    .02  .082387354 -.065294224 -.000819895 -.059974608 -.014988645
            22648   .086   .04653901 -.003199636  .007700198 -.005532296  .050107593
            22649   .223  .043037329 -.021982344  .003841302 -.025537345  .034543326
            22650    .35  .091054836  .020603807  .008364979 -.003589404  .102716469
            22651   .358 -.080886062 -.111519389 -.057623501  -.08823739 -.110469592
            22652  1.111 -.069898295  .054778833  .035449864  .073299642  .034833405
            22653   .147 -.096476952 -.048137614 -.018762216 -.051468407  .027597742
            22654   .402 -.119165901 -.056143533 -.053587584 -.056592508 -.052967107
            22655   .892  .084859947  .094052018  .029115975   .09021156  .119521627
            22656    .33 -.071488926  .086262444  .067449147  .095971295   .04464914
            22657   .044 -.001117804 -.032885232 -.016018645 -.043155633 -.060131039
            end
            format %tq qdate
            ------------------ copy up to and including the previous line ------------------

            Listed 118 out of 118 observations


            With the corresponding code I ran.

            Code:
            clear
            clear results
            log using example1.log, replace
            
            //Load K&L ch2 data
            import delimited "data.white.noise.csv", rowrange(2:119) clear
            
            destring v2, dpcomma force generate(clcrudeoil)
            destring v3, dpcomma force generate(dax)
            destring v4, dpcomma force generate(ftse)
            destring v6, dpcomma force generate(eurostocks)
            destring v10, dpcomma force generate(mscieuropeenergy)
            destring v11, dpcomma force generate(cinterestrate)
            
            gen qdate=date(v1,"DMY")
            format qdate %tq
            tsset qdate
            tsreport
            
            dataex qdate cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy, count(120)
            
            //Estimate SVAR(4) with Cholesky
            matrix A = (.,0,0,0,0,0\.,.,0,0,0,0\.,.,.,0,0,0\.,.,.,.,0,0\.,.,.,.,.,0\.,.,.,.,.,.)
            matrix B = (1,0,0,0,0,0\0,1,0,0,0,0\0,0,1,0,0,0\0,0,0,1,0,0\0,0,0,0,1,0\0,0,0,0,0,1)
            svar cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy, lags(1 2 3 4 5 6) aeq(A) beq(B)
            matlist e(A)
            matlist e(B)
            
            
            fcast compute f_, step(6)
            fcast graph f_cinterestrate f_clcrudeoil f_dax f_ftse f_eurostocks f_mscieuropeenergy
            
            
            log close

            Thanks a lot for the help! I really appreciate it.

            Comment


            • #7
              Your problem is not anything I anticipated. It is clear that you lack a thorough understanding of Stata dates and times.

              Stata's "date and time" variables are complicated and there is a lot to learn. If you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

              All Stata manuals are included as PDFs in the Stata installation and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

              In the code below, I start with a dataex of your data where I have reconstructed the original v1 string variable. I then go though your creation of qdate from v1 and show that Stata gave you in the output of tsset and tsreport sufficient information to inform you that the results were not correct. (Had you included in your original post the output copied from Stata's Results window you would have had this answer in post #2, but I didn't expect so obvious a problem.) I next drop qdate and create a Stata monthly date mdate. The listed observations and the the output of tsset and tsreport show that mdate is what you need for svar. The results of svar are what I would have expected. There are now 6 additional observations with values for mdate (2023m1 to 2023m6) and values for all the created f_ variables.

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input str10 v1 double(cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy)
              "03.01.2013"  -.032  .054747398  .006924836  .008006842  -.00361869  .005952803
              "04.01.2013"  -.003 -.039545769   .01518862  .002866617  .033528708  .008946812
              "05.01.2013"  -.013   -.0160711  .054984325  .023789603  .021253687  .008378718
              "06.01.2013"  -.007   .04870214 -.046667561 -.055843077 -.060314698 -.058786872
              "07.01.2013"   .012  .084081447  .039796613   .06525492  .063613554   .03648937
              "08.01.2013"  -.005    .0246392 -.020882144 -.031434544 -.016899373  .009369011
              "09.01.2013"   .005 -.050682339  .060624572  .007686034  .063122618 -.001336052
              "10.01.2013"    .01 -.059904174  .051140277  .041659058  .060418575  .042951697
              "11.01.2013"   .016 -.038714512  .041109507 -.012012306  .006092016 -.008236565
              "12.01.2013"  -.038  .059659836    .0156146  .014813768  .007244123  .014431586
              "01.01.2014"    .02 -.009494227 -.025719837 -.035360323 -.030569315  -.04301436
              "02.01.2014"    .01  .050990653  .041433496  .045966171  .044881153  .053642802
              "03.01.2014"  -.013 -.009893797 -.014049616 -.031033673  .003927944  .000665513
              "04.01.2014"   -.01 -.018279865  .004951909  .027531042  .011636513  .063913275
              "05.01.2014"   .021  .029342683   .03540892  .009510282  .014447894  .005250985
              "06.01.2014"  -.023  .025568482 -.011082873 -.014693528 -.005042224  .036191779
              "07.01.2014"  -.008 -.070777296 -.043281498  -.00205073 -.034919956 -.040808978
              "08.01.2014"   .008 -.022769232  .006663846  .013319247  .018334077  .009384972
              "09.01.2014"      0 -.051315234  .000436106 -.028891088  .016799942 -.021570694
              "10.01.2014"  -.013 -.123862249 -.015561044 -.011513396 -.034907763 -.073487488
              "11.01.2014"   .038 -.196829065  .070117842  .026907631  .044200403 -.078495726
              "12.01.2014"  -.018  -.21655157 -.017563634 -.023284077 -.032144648 -.018921125
              "01.01.2015"   -.02 -.099184769  .090639485   .02791768  .065156384  .021479353
              "02.01.2015"   .013  .031022896  .066141653  .029226302  .073866756  .090256182
              "03.01.2015"      0 -.044378687  .049511212 -.024993306  .027335371 -.043123939
              "04.01.2015"  -.021  .225326042 -.042769742  .027696573  -.02212107  .076366217
              "05.01.2015"   .011  .011173301 -.003541004  .003419231 -.012393551 -.039891863
              "06.01.2015" -.0105  -.01386012 -.041077396 -.066354735  -.04102185  -.05981732
              "07.01.2015"  .0335 -.232774444  .033259114  .026882462  .051511258 -.002629657
              "08.01.2015"  -.028  .043196084 -.092804928 -.066953592 -.091943489 -.104584737
              "09.01.2015" -.0132 -.087233131 -.058387089  -.02982263 -.051675572 -.070914445
              "10.01.2015"  .0182  .032725433  .123151741  .049406016  .102416574  .122105819
              "11.01.2015"   .096 -.112084557   .04903992 -.000786029  .025808679  .022046132
              "12.01.2015"   .028 -.117302959  -.05615947 -.017899369 -.068140142 -.112151685
              "01.01.2016"   .092 -.096877282 -.087954866 -.025396007 -.068073034 -.018070206
              "02.01.2016"    .01  .003859289 -.030894734  .002186137  -.03262301  .009509554
              "03.01.2016"  -.062   .12751332  .049509236  .012761826   .02008996  .000261666
              "04.01.2016"  -.007  .180407014  .007371424  .010848759  .007747269  .079700035
              "05.01.2016"    .03  .066958283  .022290135 -.001778308  .011647145 -.030689711
              "06.01.2016"   -.01 -.015806549 -.056773337  .043901335 -.064873934  .085319113
              "07.01.2016"  -.008 -.149952319  .067913625  .033838996  .043990031 -.040764625
              "08.01.2016"   .087  .071873334  .024685852  .008488452  .010823336 -.014005602
              "09.01.2016"  -.064  .076215051 -.007710034  .017373712 -.006910057  .006493506
              "10.01.2016"  -.023 -.029024119  .014650338  .007955845  .017656816  .029758065
              "11.01.2016"   .191   .05359538 -.002316922 -.024507421 -.001191392  .032265643
              "12.01.2016"   .053  .083025559  .079016569  .052926167  .078289821  .100978681
              "01.01.2017"   .048 -.017084805  .004725173 -.006115223 -.018185576 -.055264609
              "02.01.2017"  -.066  .022468648  .025929082  .023142207  .027526713 -.012035011
              "03.01.2017"   .335 -.065217638  .040429561  .008188957  .054620874  .012033961
              "04.01.2017"  -.066 -.025419161  .010163349 -.016247617  .016755548 -.025459586
              "05.01.2017"   .195 -.020686862  .014234592  .043866273 -.001404656  .006138184
              "06.01.2017"  -.028  -.04833497  -.02298364 -.027557364 -.031708298 -.056543412
              "07.01.2017"   .143  .085906655 -.016784421  .008106423  .002173231  .015298478
              "08.01.2017"  -.044 -.060387955 -.005150084  .007951709 -.008085558 -.018097087
              "09.01.2017"   .011  .089848058  .064119962 -.007786699  .050674125  .085745926
              "10.01.2017"    .03  .051119097  .031235043  .016319533    .0220037  .054932245
              "11.01.2017"   .155  .054047864 -.015540188 -.022208491 -.028312851 -.018508287
              "12.01.2017"   .127  .051275873 -.008164939  .049285692 -.018479354   .02265691
              "01.01.2018"   .201  .068904597  .021044092 -.020060434  .030060275  .005366726
              "02.01.2018"   .045 -.048913762  -.05713872 -.040039556 -.047192107 -.047289899
              "03.01.2018"   .114  .052152756 -.027269547 -.024239793 -.022524252 -.004166367
              "04.01.2018"   .003  .054391355  .042604902    .0641512  .052066042  .127461588
              "05.01.2018"   .122 -.022565665 -.000572466   .02249211 -.036722541  .023928343
              "06.01.2018"   .013  .100800612 -.023712226 -.005374958 -.003243656  .004873782
              "07.01.2018"   .139 -.075467888  .040589956  .014643319  .038252444  .007275215
              "08.01.2018"   .036  .015011829 -.034472688 -.040824596 -.037608956 -.038273968
              "09.01.2018"   .178  .048244238 -.009489601  .010464963  .001856819  .054047115
              "10.01.2018"   .082 -.114733084 -.065259869 -.050877473 -.059334549 -.049144388
              "11.01.2018"   .113 -.248693023 -.016621082 -.020743256 -.007624683 -.067055207
              "12.01.2018"   .128 -.114719796 -.062029414 -.036117669 -.054113761 -.051005698
              "01.01.2019"  -.038  .169355231  .058162925  .035778143  .052645081  .064163773
              "02.01.2019"   .018  .061815911  .030657561  .015193325   .04394147  .027122561
              "03.01.2019"   .037   .04977169   .00090312  .028900043  .016205514  .020582396
              "04.01.2019"  -.023  .060800666  .070973205  .019099653   .04860504  .002464172
              "05.01.2019"  -.066  -.17779419 -.050002916 -.034578376 -.066633093 -.053043535
              "06.01.2019"  -.181  .088832148  .057301029  .036851534  .058913008  .029988387
              "07.01.2019"  -.187  .001879539 -.016917766  .021701862 -.001969088   -.0155193
              "08.01.2019"   .098 -.061243625 -.020490539 -.050034402 -.011563812 -.082794395
              "09.01.2019"  -.146 -.018870213  .040940492  .027893018  .041639916  .062724936
              "10.01.2019"    -.4  .002032333  .035299902 -.021574712  .009794226 -.025571912
              "11.01.2019"   .105  .018107491  .028724336  .013540957  .027513518   -.0000709
              "12.01.2019"  -.174   .10143766  .000954188  .026667012  .011224275  .017094623
              "01.01.2020"    .09 -.169110809 -.020155468 -.033998282 -.027833331 -.077062557
              "02.01.2020"  -.124 -.141431295 -.084087392 -.096815678 -.085533562 -.153846154
              "03.01.2020" -1.406 -.781866083 -.164377836 -.138079904 -.162964899 -.156724415
              "04.01.2020"   .051 -.083466531  .093177829  .040418127  .050604614 -.036429101
              "05.01.2020"    .04  .633268698  .066768002  .029721023  .041759878 -.035388504
              "06.01.2020"      0  .101209902  .062491531   .01532765  .060281293 -.000455737
              "07.01.2020"  -.033  .025145906  .000197386 -.044082895 -.018475172 -.088681181
              "08.01.2020"   -.01  .056482193  .051327988  .011158474  .030932609  .021013133
              "09.01.2020"  -.012 -.057724583 -.014263776 -.016344237 -.024109934 -.125444077
              "10.01.2020"    .01  -.11669586  -.09437156 -.049237142 -.073709689 -.069897745
              "11.01.2020"  -.003   .23652112   .15010453  .123522799  .180626122  .328915663
              "12.01.2020"  -.025  .067786439  .032173264  .031012465  .017208106  .019832276
              "01.01.2021"      0  .073106411 -.020840774 -.008212961 -.020041434  .020224469
              "02.01.2021"  -.026   .16395468  .026310089  .011856492  .044521807   .09846422
              "03.01.2021"  -.017 -.038791537  .088642412  .035505897  .077760117  .014179474
              "04.01.2021"  -.003  .072053318  .008499941  .038158195  .014168672 -.035979664
              "05.01.2021"  -.005  .042192555  .018843928  .007575529  .016282826   .02484787
              "06.01.2021"   .043  .102385649  .007127234  .002116022  .006149337  .030677882
              "07.01.2021"  -.002   .00651203  .000859569 -.000734639  .006151121 -.033605377
              "08.01.2021"  -.011 -.076555444  .018701281  .012428366  .026192747  .014803775
              "09.01.2021"   .018  .091054288  -.03627387 -.004674354  -.03534688  .127178383
              "10.01.2021"   .003   .10779657  .028051156  .021329529  .050018774   .03595935
              "11.01.2021"    .05 -.233306302 -.037519831  -.02461047 -.044111835  -.07042844
              "12.01.2021"   -.05  .127905898  .051968427   .04605033  .057924323  .054388022
              "01.01.2022"  -.015  .158755708 -.026041149  .010810423 -.028803674  .130025663
              "02.01.2022"    .02  .082387354 -.065294224 -.000819895 -.059974608 -.014988645
              "03.01.2022"   .086   .04653901 -.003199636  .007700198 -.005532296  .050107593
              "04.01.2022"   .223  .043037329 -.021982344  .003841302 -.025537345  .034543326
              "05.01.2022"    .35  .091054836  .020603807  .008364979 -.003589404  .102716469
              "06.01.2022"   .358 -.080886062 -.111519389 -.057623501  -.08823739 -.110469592
              "07.01.2022"  1.111 -.069898295  .054778833  .035449864  .073299642  .034833405
              "08.01.2022"   .147 -.096476952 -.048137614 -.018762216 -.051468407  .027597742
              "09.01.2022"   .402 -.119165901 -.056143533 -.053587584 -.056592508 -.052967107
              "10.01.2022"   .892  .084859947  .094052018  .029115975   .09021156  .119521627
              "11.01.2022"    .33 -.071488926  .086262444  .067449147  .095971295   .04464914
              "12.01.2022"   .044 -.001117804 -.032885232 -.016018645 -.043155633 -.060131039
              end
              // code you ran 
              gen qdate=date(v1,"DMY")
              format qdate %tq
              tsset qdate
              tsreport
              
              // those results should have been a clue that you got your date very wrong
              drop qdate
              
              // code you should have run
              gen mdate=mofd(date(v1,"MDY"))
              // the result is a monthly date not a quarterly date
              format mdate %tm
              list v1 mdate in 1/5
              list v1 mdate in -4/l
              tsset mdate
              tsreport
              
              //Estimate SVAR(4) with Cholesky
              matrix A = (.,0,0,0,0,0\.,.,0,0,0,0\.,.,.,0,0,0\.,.,.,.,0,0\.,.,.,.,.,0\.,.,.,.,.,.)
              matrix B = (1,0,0,0,0,0\0,1,0,0,0,0\0,0,1,0,0,0\0,0,0,1,0,0\0,0,0,0,1,0\0,0,0,0,0,1)
              svar cinterestrate clcrudeoil dax ftse eurostocks mscieuropeenergy, lags(1 2 3 4 5 6) aeq(A) beq(B)
              matlist e(A)
              matlist e(B)
              
              
              fcast compute f_, step(6)
              fcast graph f_cinterestrate f_clcrudeoil f_dax f_ftse f_eurostocks f_mscieuropeenergy
              Selected output
              Code:
              . // code you ran 
              . gen qdate=date(v1,"DMY")
              
              . format qdate %tq
              
              . tsset qdate
              
              Time variable: qdate, 6800q2 to 7624q2, but with gaps
                      Delta: 1 quarter
              
              . tsreport
              
              Time variable: qdate
              ------------------------
              Starting period = 6800q2
              Ending period   = 7624q2
              Number of obs   =    118
              Number of gaps  =      9
              
              . 
              . // those results should have been a clue that you got your date very wrong
              . drop qdate
              
              . 
              . gen mdate=mofd(date(v1,"MDY"))
              
              . // the result is a monthly date not a quarterly date
              . format mdate %tm
              
              . list v1 mdate in 1/5
              
                   +---------------------+
                   |         v1    mdate |
                   |---------------------|
                1. | 03.01.2013   2013m3 |
                2. | 04.01.2013   2013m4 |
                3. | 05.01.2013   2013m5 |
                4. | 06.01.2013   2013m6 |
                5. | 07.01.2013   2013m7 |
                   +---------------------+
              
              . list v1 mdate in -4/l
              
                   +----------------------+
                   |         v1     mdate |
                   |----------------------|
              115. | 09.01.2022    2022m9 |
              116. | 10.01.2022   2022m10 |
              117. | 11.01.2022   2022m11 |
              118. | 12.01.2022   2022m12 |
                   +----------------------+
              
              . tsset mdate
              
              Time variable: mdate, 2013m3 to 2022m12
                      Delta: 1 month
              
              . tsreport
              
              Time variable: mdate
              -------------------------
              Starting period =  2013m3
              Ending period   = 2022m12
              Number of obs   =     118
              Number of gaps  =       0
              
              .

              Comment

              Working...
              X