duration {termstrc} | R Documentation |
The function calculates the Macauly duration, modified duration and duration based weights.
duration(cf_p, m_p, y)
cf_p |
cashflows matrix including the prices of the bonds. |
m_p |
maturity matrix, the first row is filled with zeros. |
y |
yields of the bonds. |
The duration vector is calculated using the following formula:
bm{d}= frac{bm{iota}'(bm{C}cdotbm{M}cdotbm{D})}{bm{iota}'(bm{C}cdotbm{D})},
whereas bm{C} is the cashflow matrix and bm{M} is the maturity matrix. bm{iota} is a column vector filled with ones. (cdot) denotes a elementwise matrix mulitplication and " ' " the transpose of a vector (matrix).
The weight omega_j for one bond j is defined as
omega_j=frac{frac{1}{d_j}}{sum_{i=1}^mfrac{1}{d_i}},
where d_j is the duration of the j-th bond.
The function returns a matrix with three columns, i.e. duration, modified duration and duration based weights.