# duration: Functions to evaluate duration and convexity In spedygiorgio/lifecontingencies: Financial and Actuarial Mathematics for Life Contingencies

## Description

These functions evaluate the duration or the convexity of a series of cash flows

## Usage

 1 2 3 duration(cashFlows, timeIds, i, k = 1, macaulay = TRUE) convexity(cashFlows, timeIds, i, k = 1) 

## Arguments

 cashFlows A vector representing the cash flows amounts. timeIds Cash flows times i APR interest, i.e. nominal interest rate compounded m-thly. k Compounding frequency for the nominal interest rate i. macaulay Is the macaulay duration (default value) or the effective duration to be evaluated?

## Details

The Macaulay duration is defined as ∑\limits_t^{T} \frac{t*CF_{t}≤ft( 1 + \frac{i}{k} \right)^{ - t*k}}{P}, while ∑\limits_{t}^{T} t*≤ft( t + \frac{1}{k} \right) * CF_t ≤ft(1 + \frac{y}{k} \right)^{ - k*t - 2}

## Value

A numeric value representing either the duration or the convexity of the cash flow series

## Note

Vectorial interest rate are not handled yet.

## Author(s)

Giorgio A. Spedicato

## References

Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.

annuity
 1 2 3 4 5 6 7 #evaluate the duration of a coupon payment cf=c(10,10,10,10,10,110) t=c(1,2,3,4,5,6) duration(cf, t, i=0.03) #and the convexity convexity(cf, t, i=0.03)