Announcement

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

  • Forecasting with stable VAR

    Dear all,

    I have downloaded the data set "consumption.dta" from the site https://www.stata.com/texts/s4poe/

    Then I execute the following commands to generate the variables of interest

    use "C:\Users\Documents\consumption.dta", clear
    gen date =q(1960q1)+_n-1
    format %tq date
    tsset date
    gen Y = log(inc)
    gen C = log(cons)


    Both variables are I(1) and they are not cointegrated. I use a VAR(3) in first differences of the variables for forecasting (pseudo and out-of-sample).
    I know how to plot the forecasts for the variable in first differences. But my goal is to obtain forecasts for the variables in levels and to plot them, which is something that I do not know how to do it. Could you help me with that. Here is what I have managed to do




    ************************************ pseudo-out-sample forecasting using the first 212 observations of the sample that consists of 217 observations

    varbasic D.C D.Y in 1/212, lag(3/3)
    fcast compute f_, step(5)
    fcast graph f_D_C f_D_Y, observed // I plot the forecasts for the first differences together with the observed series

    * Now I am trying to obtains the forecasts in levels but I am not sure if this is correct
    gen LC = L1.C
    gen f_C = LC + f_D_C
    gen LY = L1.Y
    gen f_Y = LY + f_D_Y
    gen fcons = exp(f_C)
    gen finc = exp(f_Y)
    list cons fcons inc finc in 213/217

    If the above forecasts in levels are correct (which I doubt!) then I want to plot them together with the observed series. I am not sure how to do this


    *************** out-sample forecasting . Now, we use the full sample (217 observations) to obtain forecasted values for the out-of-sample observations *(218,219,220,221,222).
    varbasic D.C D.Y, lag(3/3)
    fcast compute fa_, step(5)

    * I want to plot the forecasts in first difference together with the observe series but the code below does not provide me the observed series
    fcast graph fa_D_C fa_D_Y, observed

    * Now I am trying to obtains the forecasts in levels but I am not sure if this is correct
    gen LaC = L1.C
    gen fa_C = LaC + fa_D_C
    gen LaY = L1.Y
    gen fa_Y = LaY + fa_D_Y
    gen facons = exp(fa_C)
    gen fainc = exp(fa_Y)
    list cons facons inc fainc in 218/222

    If the above forecasts in levels are correct (which I doubt!) then I want to plot them together with the observed series. I am not sure how to do this

    Any help is greatly appreciated!!

    Last edited by John Andrews; 11 Jun 2024, 05:45.

  • #2
    Hi guys. Any ideas/help? Thank you

    Comment

    Working...
    X