Announcement

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

  • VAR Residuals

    Dear Stata users,
    I have a VAR(1) model and need to get the residuals from each equation in the var. I have tried several things including estimating each equation of VAR separately and then getting the residuals. Even though the residuals from VAR using OLS can be easily computed, it seems like they are not correct (I am replicating the paper so I can compare the estimated values with those estimated by the authors in the original paper).
    Any ideas how to do that?I looked on SATALIST etc. and its seems like there has been no answer to this problem..
    Many thanks!

  • #2
    I think you'll need something like this for each of your variables:

    Code:
    predict resid_var_name , residuals equation(var_name)
    Last edited by Justin Niakamal; 26 May 2019, 13:30.

    Comment


    • #3
      The code works, however it generates 74 missing values for each of 4 var_name residuals- every 11 observations, there is one missing value. I have no missing values in my data set. Why this might be the case?

      Comment


      • #4
        I'm not sure if you're missing any data (it's tough to say without seeing an example). A priori, missing values are expected when you're dealing with lags.

        Comment


        • #5
          Here is my example data:

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input long Date double(R_Me TY PE VS)
          192812 -.0005809628  -.63 3.2207675 1.8571141
          192901   .047326726  -.75 3.2885226 1.8517692
          192902 -.0051605997  -.85 3.2902403 1.8416018
          192903  -.012909596  -.72 3.3042084 1.8296557
          192904   .012861431  -.85 3.2948188 1.8084725
          192905  -.062034141  -.81  3.306277 1.8335974
          192906   .089804462 -1.01 3.3217432 1.9047829
          192907   .039766262  -.79 3.4036583 1.8825641
          192908    .07562698   -.7 3.4555554 1.8568828
          192909  -.055435702  -.65  3.491234 1.8646432
          192910   -.22402302  -.76 3.3760604 1.8180527
          192911   -.13487817  -.65 3.0651417 1.7906505
          192912   .013495591  -.14 3.0983275 1.7723598
          193001   .050306074  -.21 3.1068586 1.7823571
          193002   .022537928  -.39 3.1618017 1.7658294
          193003   .070728177  -.36  3.193036 1.7566879
          193004  -.024022458  -.16 3.2488439  1.746514
          193005  -.015993871  -.16 3.1815688 1.7606415
          193006   -.17418238  -.08 3.0693161 1.9953584
          end
          I have estimated the VAR(1) model of the form: zt+1=a + Γzt+ ut+1
          Where zt+1 is m-by-1 state vector with R_Me as the first element (log excess market return), TY as second then PE and VS , a and Γ are m-by-1 vector and m-by-m matrix of constant parameters and ut+1 an i.i.d. m-by-1 vector of shocks. I have 876 monthly observations.
          Codes you provided above generate in total 74 missing values, however I believe the residuals produced by them are correct ( their correlations with the other vaiables in the data set are almost the same as reported by the authors of the original paper).

          I cannot have any missing values in my residuals estimation as I need to fit the equation: NDR, t+1=e1'λut+1 where λ is 4 by 4 matrix,ut+1 is 4 by 876 matrix of shocks and e1' picks the first element of the created matrix product (so that I should get 876 estimations for NDR
          With missing values of the residuals, I will be also missing some of my NDR, t+1 values and won't be able to compute necessary calculations for my problem. How can I treat these missing values?
          Last edited by Emilia Kosinska; 27 May 2019, 14:08.

          Comment


          • #6
            I think the problem was with Date, which was not coded as Stata date variable. After transforming it to such, the residuals have just 1 missing value each (because of the lag) and I can compute my calculations.

            Comment

            Working...
            X