dmdl

Type: Package

Title: Duration gap analysis

Version: 0.1.5

Description: The package aids in the measurement and observation of interest rate risk on the net worth of a financial intermediator.

Depends: R (>= 3.5)

License: GPL-3

Encoding: UTF-8

LazyData: true

RoxygenNote: 6.1.1

Suggests: knitr, rmarkdown

VignetteBuilder: knitr

URL: https://github.com/Nyeley/dmdl

Repository: GitHub

Author: Tetteng Gaduel tettet@usi.ch, Phoebe Staenz phoebe.staenz@usi.ch

Maintainer: Tetteng Gaduel tettet@usi.ch, Phoebe Staenz phoebe.staenz@usi.ch

R Topics Documented

change

data

deltaE

differenceE

duration

ladg

Duration Model Introduction

This vignette explains the formulae applied in the functions from the "dmdl" package and reveals the analysis power of the results. The package is created for economists, who need to measure and manage interest rate risk exposures of financial intermediaries. There are two popular approaches to measure interest rate risk: the repricing model and the duration model. The formulae used in the package are the formulae applied in the duration model. The duration model is used to evaluate the financial intermediary's overall ineterst rate exposure, in other words the duration gap. The duration gap analysis aids in comprehending the impact on the financial intermediary's net worth and if the financial intermediary will become insolvent, when the interest rate changes.

The formulae were taken from the book A. Saunders and M. Cornett, Financial Institution Management, 8th International Edition, McGraw Hill.

Getting Started

Prior to commencing with the analysis of the financial statements, an excel file with the necessary data is required. The excel file should contain from the consolidated balance sheet: all financial assets and liabilities. Additionally, the excel file should contain duration and yield of both assets and liabilities. Save the excel file as .csv, import the file to R, download the package "dmdl" from github.com, and analize away!

To recapitulate, the excel file will contain four columns:

  1. Asset or liability description
  2. Asset or liability monetary value
  3. Asset or liability duration
  4. Asset or liability yield

The package is intently written to avoid time consuming calculations in excel and overly crowded excel sheets. The functions are created, such that the user is simply required to provide a file with three numerical columns: the asset or liability value, duration in years, and the yield.mThese will be the only inputs necessary for any of the functions in the package.

In order to explain the functions and their results, the remainder of the vignette includes examples. The examples contain data prepared from the 2018 annual report from Deutsche Bank AG.

Data

Firstly, load package's installed data into your session as follows.

````r library(dmdl) data(Assets) data(Liabilities)

***

Document Type: Data

Name: Assets

Usage: Assets

Description: Data set containg three numerical columns, value, duration, and yield of consolidated balance sheet assets. The data set is  used in the examples provided in the vignette.

Format: A data frame with 4 columns

* Deutsche. Descritption of the assets in the asset portfolio

* Asset. Values of the assets from the assetportfolio

* Duration. The durations of the assets from the asset portfolio

* Yield. The yields of the assets from the asset portfolio

Keyword: datasets

***

Document Type: Data

Name: Liabilities

Usage: Liabilities

Description: A data set containing the consolidated balance sheet liabilities values, liabilities durations, and liabilities yields.

Format: A data frame with 4 columns

* Deutsche. Descritption of the liabilities
* Liabilities. Value of the liabilities
* Duration. The duration of the liabilities
* Yield. The yield of the liabilities

Keyword: Datasets

*** 

  Below is a snapshot of the data prepared from Deutsche Bank AG, 2018 AR.

```r
library(knitr)

kable(Assets[1:3,1:4], caption = "Assets")
library(knitr)

kable(Liabilities[1:3,1:4], caption = "Liabilities")

For the analysis to be efficient and seemless,the user may chose to save the selected columns from the data set as vectors or directly place the selected columns from data set into the parameter fields. In order to avoid confusion, this vignette will include the selected columns from the data set directly into the functions (see example below).

duration(Assets$Asset, Assets$Duration)

duration(Liabilities$Liability, Liabilities$Duration)

Duration


Name: duration

Title: Computes the duration of assets or liabilities

Usage: duration (x, y)

Arguments:

Value: aggregate duration of assets or liabilities

Description: Takes the positions of assets or liabilities, computes their porportions relative to the total liability portfolio or asset portfolio, and returns the aggregate duration.


The first part of the analysis is determining the duration of the assets and the liabilities. The "duration" function implements the formulae depicted below. The formulae are summations of the proportion and duration of assets or liabilities in the asset or liability portfolio at market values. The result is a weighted duration of assets or liabilities.

![](/Users/Phoebe/Desktop/Programming II/Package Project/dmdl/vignettes/duration_aa.png)

Before executing the summation, the function calculates the propotions (weights) of each element in the asset or liability vector. The proportions are calculated by dividing the individual asset or liability value by the total asset or liability value. Each element from the resulting proportion vector is multipled by the duration element in the same position. The result is a single number, namely the weighted duration of assets or liabilities.

The "length(x)" determines the number of elements in the asset or liability value vector. When calculationg the proportion vector, the function is dividing the first element in the value vector by the sum of all the elemements in the value vector. The function executes the porportion calculation for all elements in the value vector and the resulting vector will have 15 elements as well. In the final step the function multiples each element in the porportion vector by each element in the duration vector (15 multiplications) and sums the multiplications, returning the weighted duration.

Executing the function with our asset value and asset durations will result in a weighted duration of 5.2 years.

duration <- function(x,y){

  u <- length(x)

  p <- x[1:u]/sum(x[1:u])

  return(sum(p[1:u]*y[1:u]))
}
duration(Assets$Asset, Assets$Duration)

Executing the function with our liabilities values and liabilities durations will result in a weighted duration of 1.9 years.

duration(Liabilities$Liability, Liabilities$Duration)

Change


Name: change

Title: Computes the aggregate change in assets or liabilities, due to a respective predicted change in interest rate level

Usage: change (x, y, z, r)

Arguments:

Value: aggregate change in assets or liabilities

Description: Takes the positions of assets or liabilities together with the respective durations and yields and computes the expected overall change in the value of assets or liabilities resulting from the predicted change in interest rate level


In the previous section we looked at the duration and there was no mention of the interest rate. It was not relevant for the calculation of the duration of assets and liabilities. Starting in this section the interest rate gains relevancy. This section deals with the interest rate exposure of the assets and liabilities. We assume a predicted shock in the level of interest rate.

The duration approximation from the previous section is used to determine the effect the change in interest rate has on the individual assets or liabilities and ultimately on the total asset or liabilities position of the financial intermediary. The functions are identical for the assets and liabilities. Assets will use the asset vector, asset duration vector, asset yield vector, and the specific predicted change in interest rate specific to assets. The liabilities will use the respective vectors for their calculation.

![](/Users/Phoebe/Desktop/Programming II/Package Project/dmdl/vignettes/change_assets.png)

The "change" function applies the formula depicted above. The number of elements used in the computation is determined by the length(x), the number of values in the value vector. First, the shock in the level of the interest rate is determined by dividing the potential change in interest rate by one plus the existing yield found in the yield vector. The shock is computed element by element, which implies that each asset or liability from the value vector experiences a different interest rate shock. The function proceeds to compute the effect the interest rate change has on the individual asset's or liabilities' value, then aggregates the individual changes.

In the examples following, the predicted interest rate change is 0.0015 for assets and 0.0025 for liabilities.

Executing the function with our predetermined vectors of asset value, asset duration, asset yield, and rise in interest rate of 0.0015 will result in an overall change in assets of EURm -9843.87.

change <- function(x, y, z, r){
    u <- length(x)

    r_shock <- r/(1 + z[1:u])

    individualDelta <- -y[1:u] * x[1:u] * r_shock

    return(sum(individualDelta))
}
change(Assets$Asset, Assets$Duration, Assets$Yield, 0.0015)

![](/Users/Phoebe/Desktop/Programming II/Package Project/dmdl/vignettes/change_liabilities.png)

The execution for the "change" function using liabilities values is identical to the execution of the "change" function for assets.

Executing the function with our vectors of liability value, liabilities durations, liabilities yields, and an increase in interest rate level of 0.0025 will result in an overall change in liabilities of EURm -5918.691.

change(Liabilities$Liability, Liabilities$Duration, Liabilities$Yield, 0.0025)

Difference in Equity

differenceE

Name: differenceE

Title: Computes the change in equity

Usage: differenceE (x, y, z, r1, h, i, j, r2)

Arguments:

Value: The change in equity

Description: Takes the aggregare changes in assets and liabilities, subtracting liabilities from assets, returning the change in equity. Note: used when the predicted change in interest level for assets and liabilities asre different. (spread > 0)


When analizing the effect of interest rate, equity is also to be considered. Considering the change in equity, will help determine whether the financial intermediary will become insolvent. Due to different changes in interest rate for assets and liabilities (spread in i.r. > 0), the simplest way of calculating the effect of the predicted interest rate changes on equity is to subtract the aggregate change in assets by the aggregate change in liabilities.

The formulae depicted below have been used seperately in the previous sections, computing either duration of the assets and liabilities or the change in assets and liabilities, when experiencing a shock in the level of interest rate. In this section the individual formulae come together to compute the effect the change in interest rate for assets and liabilities has on the equity position of the financial intermediary.

![](/Users/Phoebe/Desktop/Programming II/Package Project/dmdl/vignettes/simple_E.png)

As with the formulae from above, the function below includes elements of functions from the previous sections' functions. The "differenceE" function is constructed, such that the input parameters are split into assets and liabilities. The inputs assosciated with the assets (asset value, asset duration, asset yield, change in interest rate for assets) come first and are followed by the inputs assosciated with the liabilities (liability value, liability duration, liability yield, change in interest rate for liabilities). Similarily, the functions coherent construction is: asset computation first and liabilities computation second.

Familiar are the "r_shock" executions of the potential interest rate changes for liabilities and assets and the "Delta_A" and "Delta_L" calculation and its summation. The newly added execution within the function is in the last line, where the sum of individual changes in liabilities is subtracted from the sum of individual changes in assets.

By placing both summations of the "Delta_A" and "Delta_L" within the same function, we eliminate the need to save results from the previous functions. The user has the liberty to decide, whether the previous steps serve any value to their analysis or whether they wish to only observe the change in equity. Again, the only inputs required by the user are the columns from the prepared excel file and the desired change in interest rates.

Note that the shock for the asset part of the function uses "r1" and therefore the liabilities part uses the "r2". Executing the function with our predetermined vectors of asset value, asset duration, asset yield, change in interest rate for assets (0.0015), liability value, liability duration, liability yield, and change in interest rate for liabilities (0.0025) will result in an overall change in equity of EURm -3925.2.

differenceE <- function(x, y, z, r1, h, i, j, r2){

  u <- length(x)

  r1_shock <- r1/(1 + z[1:u])

  Delta_A <- sum(-y[1:u] * x[1:u] * r1_shock)

  n <- length(h)

  r2_shock <- r2/(1 + j[1:n])

  Delta_L <- sum(-i[1:n] * h[1:n] * r2_shock)

  return(Delta_A - Delta_L)
  }
differenceE(Assets$Asset, Assets$Duration, Assets$Yield, 0.0015, Liabilities$Liability, Liabilities$Duration, Liabilities$Yield, 0.0025)

Leverage Adjusted Duration Gap

ladg

Name: ladg

Title: Computes the leverage adjusted duration gap

Usage: ladg (x, y, z, w)

Arguments:

Value: leverage adjusted duration gap

Description: Takes the duration of assets and the scaled duration of liabilities, subtracting the scaled duration of liabilities from the duration of assets


The leverage adjusted duration gap uses the ratio between the total assets and the total liabilities to scale the duration of liabilities and to determine the gap between the scaled duration of liabilities and duration of assets. The larger the gap, the greater the duration mismatch.

In the formula depicted below are the duration of assets and liabilities, as well as the factor "k". "k" represents the market measure of risk, which in turn is the ratio between asets and liabilities.

![](/Users/Phoebe/Desktop/Programming II/Package Project/dmdl/vignettes/ladg.png)

The function below is constructed in such a manner that elements of functions from the previous sections are being reused and the user will not need to save previously obtained results. Recognizeable are the proportion vectors and its summation from the duration section. The additional computations this function under takes are in the last two lines. "k" is the ratio between asets and liabilities. The penultimate line executes the summation of liability value and divides it by the summation of the asset values. The last line is the insertion of the levergage adjusted duration gap formula from the image above. In the lines leading up to "k", the function computes the duration of assets and liabilities. The command in the last line tells the function to combine the duration results with the market measure risk and return the LADG.

Executing the function with the vectors of asset value, asset duration, liability value, and liability duration, the result reaveals that the leverage adjusted duration gap is 3.36 years.

ladg <- function(x, y, z, w){

  u <- length(x)

  proporAssets <- x[1:u]/sum(x[1:u])

  durationAssets <- (sum(proporAssets[1:u]*y[1:u]))

  n <- length(z)

  proporLiabilities <- z[1:n]/sum(z[1:n])

  durationLiabilities <- sum(proporLiabilities[1:n]*w[1:n])

  k <- sum(z)/sum(x)

  return(durationAssets - (durationLiabilities*k))
}
ladg(Assets$Asset, Assets$Duration, Liabilities$Liability, Liabilities$Duration)

Change In Equity And The LADG

deltaE

Name: deltaE

Title: Computes the change in equity

Usage: deltaE (x, y, z, w, r)

Arguments:

Value: leverage adjusted duration gap

Description: Takes the duration of assets and the duration of liabilities, applies them to the leverage adjusted duration gap computation, ultimately applies the multiplication of negative ladg and total assets and the predicted change in interest rate level


The LADG is used to calculate the change in equity, when the expected interest rate shock for assets and liabilities is the same (spread = 0). The formula from the aggregate change in equity simplifies, due to the interest rate shock being the same for both assets and liabilites. Instead of calculating the difference between change in assets and the change in liabilities, the individual changes are replaced wtih the negative LADG.

![](/Users/Phoebe/Desktop/Programming II/Package Project/dmdl/vignettes/delta_e.png)

The "deltaE" function includes familiar computations before applying the formula depicted above. The lines, leading up to the formula depicted above in the last line, are the computations done for the duration of assets and liabilites. Once the durations are computed the function computes the market measure of risk "k" and the LADG. The penultimate and ultimate line of the function are new insertions. Penultimately, the function computes the total asset value of the financial intermediary and inserts it into the formula in the last line of code, returning the change in equity due to a predicted change in interest rate.

For the example below we will assume that the interest rate across both assets and liabilities has declined by 30bps. Executing the function with our vectors of asset values, asset durations, liability values, liability durations, and interest rate decline of -0.0030, resuls in a change in equity f EURm 13571.34.

deltaE <- function(x,y,z,w,r){

  u <- length(x)

  proporAssets <- x[1:u]/sum(x[1:u])

  durationAssets <- (sum(proporAssets[1:u]*y[1:u]))

  n <- length(z)

  proporLiabilities <- z[1:n]/sum(z[1:n])

  durationLiabilities <- sum(proporLiabilities[1:n]*w[1:n])

  k <- sum(z)/sum(x)

  ladg <- durationAssets - (durationLiabilities*k)

  A <- sum(x)

  return(-ladg * A * r)
  }
deltaE(Assets$Asset, Assets$Duration, Liabilities$Liability, Liabilities$Duration, -0.0030)

Conclusion

Based on a predicted change in interest rate, the duration gap model can be used to predict the effect on the financial intermediary's net worth. If the effect is too large, corrections from the managers shall be considered. The duration gap can be used to restructure the balance sheet to limit losses or immunize completely against interest rate risk, meaning that the predicted change in Equity = 0. For example, if the Leverage adj. duration gap is positive (DA > DL*k), then the manager will need to make decisions to either lower the duration of assets, increase the duration of liabilities, or increase measure of market leverage. To maintain interest rate immunization, a portfolio needs to be constantly rebalanced. In practice, most institutions rebalance at discrete intervals: quarterly, semiannually. For the purpose of the periodical rebalancing act, this package can make quick and clean calculations, providing managers with the necessary results to make educated corrections to their portfolios.



Nyeley/dmdl documentation built on June 5, 2019, 12:40 a.m.