Displaying 3 results from an estimated 3 matches for "frequency_copoun".
2010 Jan 20
2
Please Please Please Help me!!
...n single set of data. I just wish to wish to use it for multiple data.)
I have defined a function (as given below) which helps me calculate Macaulay Duration and Modified Duration and its working fine with given set of data.
My Code -
## ONS - PPA
duration = function(par_value, coupon_rate, frequency_copoun, tenure, ytm)
{
macaulay_duration = NULL
modified_duration = NULL
freq_coupon_new = NULL
if(frequency_copoun <= 0)
{
freq_coupon_new = 365
}
if(frequency_copoun > 0 & frequency_copoun <= 1)
{
freq_coupon_new = 12
}
if(frequency_copoun > 1 & freque...
2010 Jan 19
0
Macualay Duration code in a Functional Form - Please Help
...#}
# Added code
ONS = read.csv('instrument details.csv')
n = length(ONS$par_value)
par_value = matrix(data = ONS$par_value, nrow = n, ncol = 1, byrow = TRUE)
coupon_rate = matrix(data = ONS$coupon_rate, nrow = n, ncol = 1, byrow = TRUE)
freq_coupon = matrix(data = ONS$frequency_copoun, nrow = n, ncol = 1, byrow = TRUE)
tenure = matrix(data = ONS$tenure, nrow = n, ncol = 1, byrow = TRUE)
ytm = matrix(data = ONS$ytm, nrow = n, ncol = 1, byrow = TRUE)
result = matrix(data = NA, nrow = n, ncol = 2, byrow = TRUE)
result = Duration(par_value, coupo...
2010 Jan 19
0
Macaulay Duration for Group
...1 means, total number of times compounding is done = 12.
My R Code for calcualting Macaulay Duration is as follows -
## INPUT
ONS = read.csv('instrument details..csv')
par_value = ONS$par_value
coupon = ONS$coupon_rate*par_value/100
freq_coupon = ONS$frequency_copoun
tenure = ONS$tenure
ytm = ONS$ytm
# _________________________________________________________________________________________________
## COMPUTATIONS
macaulay_duration = NULL
modified_duration = NULL
freq_coupon_new = NULL
if(freq_coupon <= 0)
{
freq_...