Learn R Programming

FinancialMath (version 0.1.1)

cf.analysis: Cash Flow Analysis

Description

Calculates the present value, macaulay duration and convexity, and modified duration and convexity for given cash flows. It also plots the convexity and time diagram of the cash flows.

Usage

cf.analysis(cf,times,i,plot=FALSE,time.d=FALSE)

Arguments

cf
vector of cash flows
times
vector of the periods for each cash flow
i
interest rate per period
plot
tells whether or not to plot the convexity
time.d
tells whether or not to plot the time diagram of the cash flows

Value

Details

$pv=\sum_{k=1}^n\frac{cf_k}{(1+i)^{times_k}}$

$MAC D=\frac{\sum_{k=1}^n times_k*(1+i)^{-times_k}*cf_k}{pv}$

$MOD D=\frac{\sum_{k=1}^n times_k*(1+i)^{-(times_k+1)}*cf_k}{pv}$

$MAC C=\frac{\sum_{k=1}^n {times_k}^2*(1+i)^{-times_k}*cf_k}{pv}$

$MOD C=\frac{\sum_{k=1}^n times_k*(times_k+1)*(1+i)^{-(times_k+2)}*cf_k}{pv}$

See Also

TVM

Examples

Run this code
cf.analysis(cf=c(1,1,101),times=c(1,2,3),i=.04,time.d=TRUE)

cf.analysis(cf=c(5,1,5,45,5),times=c(5,4,6,7,5),i=.06,plot=TRUE)

Run the code above in your browser using DataLab