Announcement

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

  • Rolling sd

    Hi Statalist,

    I am a frequent reader of Statalist,

    I am using Stata 15.1.
    I am trying to replicate a paper on business cycle titled:
    HTML Code:
     Macroeconomic Volatility and External Imbalances by Perri and Fogli (2014)
    . I am struggling with how to implement the formulate in the picture to get the relative volatility of GDP growth.I tried to use the following code to calculate standard deviation using a window of 40 quarters:
    So my questions are:
    1. how do I implement the following formula in Stata
    2. If I choose 40 quarters as my window, what does middle of a window mean (my understanding was the sd calculated using window=40 is placed halfway between these quarters) and I doubt this option is available in rangestat or asrol

    I would really appreciate any hint.
    Thank you in advance.
    Click image for larger version

Name:	Volatility.png
Views:	1
Size:	303.3 KB
ID:	1499809


    Code:
    rangestat (sd) sd_gdpg= gdpg, interval( time -40 0) by( ccode )
    rangestat (sum) sumsdo_gdpg= sd_gdpg (count) counto_gdpg= sd_gdpg , interval(time -40 0) by(time) excludeself
    gen meansdo_gdpg=sumsdo_gdpg/counto_gdpg
    gen rel_volgdpg = sd_gdpg - meansdo_gdpg

  • #2
    Change -interval(time -40 0)- to -interval(time -20 20)- to match the formulas shown.

    Comment


    • #3
      Dear Clyde,
      Thank you very much. But, I could not understand why the left hand side variables (for volatility and relative volatility) are in yearly
      i(t)
      instead of
      i,s(t)
      . Did I miss something in the code?

      Comment


      • #4
        I don't think you missed anything. In the excerpt from the article you show, t is time measured in years, and s(t) is time measured in quarters. Perhaps the intention is after calculating the results by quarter (since the right hand sides of the equations are all in terms of s(t)) to "smear" the result for one of the quarters in a year (not clear which one) over the observations for the entire year, but it isn't clear to me why one would want to do that as it just discards information.

        Comment


        • #5
          Clyde Schechter , thank you so much for your help. It's true the article used both yearly and quarterly data.

          Comment

          Working...
          X