Announcement

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

  • Time Series Rare and not evenly recurring events

    Hi,

    I am looking at the outcome of the FOMC meetings (eight meetings each year) spread out over 10 years of daily data. When searching for similar topics I have not encountered any similar posts regarding rare unevenly distributed time series data.

    I am only interested in the FOMC meetings and the response to those meetings as well as how the response to FOMC meetings have changed over time. However, I am struggling to declare the dataset to be time series data (the dataset consists of thousands of trading days, only some of which are FOMC-days). The reason I want to declare the dataset as time series is to create a moving average (but only for days when the meeting have occurred meeting 1, meeting 2… meeting n and not for the “regular” days actually being in between) of the response to those meetings for the past 12 months.

    When declaring the Date variable as time series, of course all dates are included and not only the ones of interest. I have also tried to number the FOMC meetings using
    Code:
    gen MeetingID = _n
    and then tried to declare the dataset to be time series unit. Is that the best way to work with Time Series for this kind of task? But when using the meetingID as the Time Series and creating the moving average, and presenting it in a time series line graph, the x-axis (the Time unit) is presenting the MeetingID and not the years/dates.

    Extremely grateful for help. Thanks beforehand!

    /Axel

  • Phil Bromiley
    replied
    Welcome to Statalist. You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - code in code delimiters, Stata results and data using dataex. Knowing the exact format of your data is essential to helping you. We want your code partially to see that you've made an effort to solve your problem before asking Statalist.

    You can refer to previous observations with [_n-1] etc. and you can easily identify the dates for the meetings. So, you can generate a variable that has the appropriate lag values if there is a meeting.

    g usedata= data if FOMC==1
    replace usedata= data[_n-1] if FOMC[_n+1]==1

    etc,

    This can be done in a loop. Something like
    g usedata=.
    forvalues i=1/10 {
    replace usedata= data[_n-`i'] if FOMC[_n+`i']==1
    }

    If you have only trading days, this avoids the problem of weekends. You can also use it to delete any observations you want, or to create wide data just for those observations:

    g usedata=.
    forvalues i=1/10 {
    replace usedata`i'= data[_n-`i'] if FOMC[_n+`i']==1
    }
    keep if usedata1<. & usedata2<. etc.

    Leave a comment:

Working...
X