Dear all,
By following the method of Bry and Boschan (1971), full reference placed below, I want to identify Peaks and Troughs for my quarterly time series data-set. I want to identify peaks and troughs in the earnings data. I'd start by creating a dummy variable earnings_point which is 1 for a peak (local maximum) and -1 for a trough (local minimum)
I'd like to define a peak as a case where yt−2 ,yt-1< yt >yt+1,yt+2. Similarly, for a trough this would be the case where yt−2, yt−1, > yt < yt+1,yt+2.
In theory, I understand this, unfortunately I am not that experienced with Stata so I have no clue how to code this. If someone could help me, I would be very grateful.
I am also aware that there is a package available in Stata (sbbq), but I am interested in writing it as a code so I am able to understand better the process behind it and improve my knowledge of Stata. My data looks as follows:
yearQ deflated_seasonal_earnings
1947q1 8.743261
1947q2 8.92267
1947q3 8.990711
1947q4 9.064721
1948q1 9.124517
1948q2 9.198627
1948q3 9.39039
1948q4 9.590679
1949q1 9.667767
1949q2 9.713504
1949q3 9.758883
1949q4 9.680266
1950q1 9.902534
1950q2 10.07589
1950q3 10.0649
1950q4 10.25335
1951q1 10.16216
1951q2 10.30928
1951q3 10.42188
1951q4 10.46898
1952q1 10.59212
1952q2 10.67364
1952q3 10.67226
1952q4 10.96858
1953q1 11.17539
1953q2 11.29197
1953q3 11.38358
1953q4 11.40842
1954q1 11.37225
1954q2 11.4531
1954q3 11.41521
1954q4 11.49819
1955q1 11.6033
1955q2 11.71379
1955q3 11.87905
1955q4 11.87453
1956q1 11.84568
1956q2 12.01675
1956q3 11.99835
1956q4 12.23063
1957q1 12.19279
1957q2 12.15003
1957q3 12.22509
1957q4 12.3208
Thank you very much in advance!
Rajendra
Reference: Bry, Gerhard and Charlotte Boschan, 1971. Cyclical Analysis of Time Series: Procedures and Computer Programs, New York, NBER.
Related Posts with Identifying peaks and throughs within a time series
How to expand yscale range in marginsplot with addplotUsing Stata/SE 16.1 I made two related Figures that should be easily comparable. This means that the…
How to perform firstage regression and overidentification testsHey everyone! I have panel data between 2014 and 2018 on multiple socioeconomic and demography fact…
Combining mlabel margins and mlabel p values in one coefplotDear Statalists, My question is about combining 2 types of mlabels in one coefplot in Stata 15. I …
graph bar with error barsHi everyone, I am beginning with STATA and I am creating a graph bar but I can't find how to add er…
Varlist required errorHello everyone, This might seem a very simplistic problem, but I am getting an error "varlist requi…
Subscribe to:
Post Comments (Atom)
0 Response to Identifying peaks and throughs within a time series
Post a Comment