Announcement

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

  • Hodrick prescott filter

    Hi, I am trying to apply a Hodrick-Prescott filter in a time-series variable.


    Code:
     
    
    format date %tm
    
    tsset date
            time variable:  date, 3116m9 to 3707m8, but with gaps
                    delta:  1 month
    
    . tsfilter hp lind_hp = lind, smooth(129600)
    
    Number of gaps in sample:  232
    sample may not contain gaps
    r(498);

    Could you please help me with that? I cannot understand why it mentions this note about gaps..

    Thanks

    Nikos


  • #2
    I'd back up. Look at what Stata is telling you about your data. It says you have monthly dates from 3116m9 to 3707m8.

    But it's now 2017m9. Those dates are in the next millennium and are nonsense.

    So, what happened to change your data so that you now see nonsense? We can make some guesses.

    Code:
    . di ym(3116,9)
    13880
    
    . di %td ym(3116,9)
    01jan1998
    
    . di ym(3707,8)
    20971
    
    . di %td ym(3707,8)
    01jun2017
    Here's my series of guesses. You have monthly data that come with daily dates 1 Jan 1998, 1 Feb 1998, .... which numerically are thus daily dates 30 or so days apart, such as 13880, 13911, ... where we count days as days since 1 Jan 1960.

    So, you told Stata that they should be given a monthly display format. That didn't convert them to monthly dates that make sense. It just instructed Stata to display them as monthly dates (which don't make sense). The gaps remain.

    What you need to do is convert your daily dates to monthly dates, then redo tsset and then try again.

    Code:
    gen mdate = mofd(date)
    format mdate %tm
    All explained at

    Code:
    help datetime
    More at e.g. https://www.statalist.org/forums/for...rs-from-a-date

    Comment


    • #3
      Great, thank you!

      Comment

      Working...
      X