## Understanding the Interest-Rate Term Structure

### Introduction

The interest-rate term structure represents the evolution of interest rates through time. In MATLAB®, the interest-rate environment is encapsulated in a structure called `RateSpec` (rate specification). This structure holds all information required to completely identify the evolution of interest rates. Several functions included in Financial Instruments Toolbox™ software are dedicated to the creating and managing of the `RateSpec` structure. Many others take this structure as an input argument representing the evolution of interest rates.

Before looking further at the `RateSpec` structure, examine three functions that provide key functionality for working with interest rates: `disc2rate`, its opposite, `rate2disc`, and `ratetimes`. The first two functions map between discount factors and interest rates. The third function, `ratetimes`, calculates the effect of term changes on the interest rates.

### Interest Rates Versus Discount Factors

Discount factors are coefficients commonly used to find the current value of future cash flows. As such, there is a direct mapping between the rate applicable to a period of time, and the corresponding discount factor. The function `disc2rate` converts discount factors for a given term (period) into interest rates. The function `rate2disc` does the opposite; it converts interest rates applicable to a given term (period) into the corresponding discount factors.

#### Calculating Discount Factors from Rates

As an example, consider these annualized zero-coupon bond rates.

From

To

Rate

15 Feb 2000

15 Aug 2000

0.05

15 Feb 2000

15 Feb 2001

0.056

15 Feb 2000

15 Aug 2001

0.06

15 Feb 2000

15 Feb 2002

0.065

15 Feb 2000

15 Aug 2002

0.075

To calculate the discount factors corresponding to these interest rates, call `rate2disc` using the syntax

```Disc = rate2disc(Compounding, Rates, EndDates, StartDates, ValuationDate) ```

where:

• `Compounding` represents the frequency at which the zero rates are compounded when annualized. For this example, assume this value to be 2.

• `Rates` is a vector of annualized percentage rates representing the interest rate applicable to each time interval.

• `EndDates` is a vector of dates representing the end of each interest-rate term (period).

• `StartDates` is a vector of dates representing the beginning of each interest-rate term.

• `ValuationDate` is the date of observation for which the discount factors are calculated. In this particular example, use February 15, 2000 as the beginning date for all interest-rate terms.

Next, set the variables in MATLAB.

```StartDates = ['15-Feb-2000']; EndDates = ['15-Aug-2000'; '15-Feb-2001'; '15-Aug-2001';... '15-Feb-2002'; '15-Aug-2002']; Compounding = 2; ValuationDate = ['15-Feb-2000']; Rates = [0.05; 0.056; 0.06; 0.065; 0.075]; ```

Finally, compute the discount factors.

```Disc = rate2disc(Compounding, Rates, EndDates, StartDates,... ValuationDate)```
```Disc = 0.9756 0.9463 0.9151 0.8799 0.8319 ```

By adding a fourth column to the rates table (see Calculating Discount Factors from Rates) to include the corresponding discounts, you can see the evolution of the discount factors.

From

To

Rate

Discount

15 Feb 2000

15 Aug 2000

0.05

0.9756

15 Feb 2000

15 Feb 2001

0.056

0.9463

15 Feb 2000

15 Aug 2001

0.06

0.9151

15 Feb 2000

15 Feb 2002

0.065

0.8799

15 Feb 2000

15 Aug 2002

0.075

0.8319

#### Optional Time Factor Outputs

The function `rate2disc` optionally returns two additional output arguments: `EndTimes` and `StartTimes`. These vectors of time factors represent the start dates and end dates in discount periodic units. The scale of these units is determined by the value of the input variable `Compounding`.

To examine the time factor outputs, find the corresponding values in the previous example.

```[Disc, EndTimes, StartTimes] = rate2disc(Compounding, Rates,... EndDates, StartDates, ValuationDate); ```

Arrange the two vectors into a single array for easier visualization.

`Times = [StartTimes, EndTimes]`
```Times = 0 1 0 2 0 3 0 4 0 5 ```

Because the valuation date is equal to the start date for all periods, the `StartTimes` vector is composed of 0s. Also, since the value of `Compounding` is 2, the rates are compounded semiannually, which sets the units of periodic discount to six months. The vector `EndDates` is composed of dates separated by intervals of six months from the valuation date. This explains why the `EndTimes` vector is a progression of integers from 1 to 5.

#### Alternative Syntax (rate2disc)

The function `rate2disc` also accommodates an alternative syntax that uses periodic discount units instead of dates. Since the relationship between discount factors and interest rates is based on time periods and not on absolute dates, this form of `rate2disc` allows you to work directly with time periods. In this mode, the valuation date corresponds to 0, and the vectors `StartTimes` and `EndTimes` are used as input arguments instead of their date equivalents, `StartDates` and `EndDates`. This syntax for `rate2disc` is:

```Disc = rate2disc(Compounding, Rates, EndTimes, StartTimes)```

Using as input the `StartTimes` and `EndTimes` vectors computed previously, you should obtain the previous results for the discount factors.

`Disc = rate2disc(Compounding, Rates, EndTimes, StartTimes)`
```Disc = 0.9756 0.9463 0.9151 0.8799 0.8319```

#### Calculating Rates from Discounts

The function `disc2rate` is the complement to `rate2disc`. It finds the rates applicable to a set of compounding periods, given the discount factor in those periods. The syntax for calling this function is:

```Rates = disc2rate(Compounding, Disc, EndDates, StartDates, ValuationDate) ```

Each argument to this function has the same meaning as in `rate2disc`. Use the results found in the previous example to return the rate values you started with.

`Rates = disc2rate(Compounding, Disc, EndDates, StartDates,ValuationDate)`
```Rates = 0.0500 0.0560 0.0600 0.0650 0.0750```

#### Alternative Syntax (disc2rate)

As in the case of `rate2disc`, `disc2rate` optionally returns `StartTimes` and `EndTimes` vectors representing the start and end times measured in discount periodic units. Again, working with the same values as before, you should obtain the same numbers.

```[Rates, EndTimes, StartTimes] = disc2rate(Compounding, Disc,... EndDates, StartDates, ValuationDate); ```

Arrange the results in a matrix convenient to display.

`Result = [StartTimes, EndTimes, Rates]`
```Result = 0 1.0000 0.0500 0 2.0000 0.0560 0 3.0000 0.0600 0 4.0000 0.0650 0 5.0000 0.0750 ```

As with `rate2disc`, the relationship between rates and discount factors is determined by time periods and not by absolute dates. So, the alternate syntax for `disc2rate` uses time vectors instead of dates, and it assumes that the valuation date corresponds to time = 0. The time-based calling syntax is:

```Rates = disc2rate(Compounding, Disc, EndTimes, StartTimes);```

Using this syntax, you again obtain the original values for the interest rates.

`Rates = disc2rate(Compounding, Disc, EndTimes, StartTimes)`
```Rates = 0.0500 0.0560 0.0600 0.0650 0.0750 ```