Why does the YEARFRAC function no longer return integer results when time period spans a leap year as of MATLAB 7.3 (R2006b)?

2 views (last 30 days)
When I perform the following in MATLAB 7.2 (R2006a):
yearfrac(datenum('06/01/06'), datenum('06/01/08'))
I receive the following output
ans =
2
If I enter the same statement in MATLAB 7.3 (R2006b), I receive a different output as follows:
ans =
2.0027
These irregularities occur when using the actual/actual convention, which is the default basis input (0).

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This is expected behavior of the YEARFRAC function in MATLAB 7.3 (R2006b) when the inputted time period spans a leap year. There has been a design change of the YEARFRAC function between MATLAB 7.3 (R2006b) and MATLAB 7.2 (R2006a).
In MATLAB 7.2 the YEARFRAC function aligned with the paradigm that years to date should always be an integer number of years. That is, two dates with the same month and day but different years should be separated by an integer number in years. Thus the YEARFRAC function would produce an integer when executing the following code:
yearfrac(datenum('11/30/06'), datenum('11/30/08'))
The method for calculating the year fraction has been altered in MATLAB 7.3 (R2006b) to align with the interest accumulation functions, and the conventional practice of using the numerical representation of the dates for calculating year fractions. Executing the above YEARFRAC statement will no longer produce an integer year. This is because the numerator consists of all the days between the dates 11/30/2006 and 11/30/2007, which includes an additional leap day, while the denominator consists of the number of days in the year between 11/30/2006 and 11/30/2007. In the example given above, the year fraction yf is therefore:
yf = (365 + 366) / 365
The reference book "Money Market and Bond Calculations" by Stigum and Robinson states that for the actual/actual convention, “if interest is paid annually, then the denominator of the day-count fraction equals the actual number of days, 365 or 366, in the relevant 1-year period.”
The "relevant 1-year period" means "the year in which the coupon starts." The YEARFRAC function is designed to work directly with our interest accrual functions and the dates are supposed to be aligned to coupon dates. If the coupon starts in a non-leap year like 2006, then the denominator for the actual/actual basis is 365. If the coupon starts in a leap year like 2008, then the denominator for the actual/actual basis is 366.
There may be multiple relevant 1-year periods for a coupon, but this does not align with the convention referenced above, and is not supported by the YEARFRAC function.

More Answers (0)

Categories

Find more on Data Preprocessing in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2006b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!