Dear All,
I (yet again) have a weird filtering problem, thatI would like to solve in Stata. Consider the following representative data:
My Datastream yield data seems corrupted in that some bond yields start increasing exponentially towards maturity date (going into the gazillions). I assume the Datastream algorithm breaks down here. To avoid bias in the data I would like to drop all observations from where on the YieldChange is always positive for all following observations.
In the example above, this would mean:
This is to be computed on 12,000 bonds and T= 4*365 so computationally efficiency may be important, but at first I would like to understand how to tackle something like this in Stata.
Thanks in advance!
Best,
I (yet again) have a weird filtering problem, thatI would like to solve in Stata. Consider the following representative data:
Code:
clear ssc install dataex input float (bondid date yield) 1 1 1.2 1 2 0.8 1 3 1.1 1 4 0.9 1 5 1 1 6 1.1 1 7 1.2 2 1 1 2 2 1.1 2 3 1.2 2 4 1.3 2 5 1.4 2 6 1.5 2 7 1.6 2 8 1.7 2 9 1.8 3 1 1.2 3 2 0.8 3 3 1.1 3 4 0.9 3 5 1 3 6 1.1 3 7 1.2 3 8 1.3 3 9 1.4 3 10 1.5 3 11 1.6 end bys bondid (date): gen YieldChange =( yield-yield[_n-1])/yield[_n-1]
In the example above, this would mean:
- Bond 1: Drop 5-7
- Bond 2: Drop all
- Bond 3: Drop 5-11
This is to be computed on 12,000 bonds and T= 4*365 so computationally efficiency may be important, but at first I would like to understand how to tackle something like this in Stata.
Thanks in advance!
Best,
Comment