Displaying 4 results from an estimated 4 matches for "coupon_r".
Did you mean:
coupon
2010 Jan 19
0
Macualay Duration code in a Functional Form - Please Help
# I have written this code in Notepad++ and copied here.
## ONS - PPA
Duration = function(par_value, coupon_rate, freq_coupon, tenure, ytm)
{
macaulay_duration = NULL
modified_duration = NULL
freq_coupon_new = NULL
if(freq_coupon <= 0)
{
freq_coupon_new = 365
}
if(freq_coupon > 0 & freq_coupon <= 1)
{
freq_coupon_new = 12
}
if(freq_coupon > 1 & freq_coupon &l...
2010 Jan 20
2
Please Please Please Help me!!
...ts for a given 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_copou...
2010 Feb 02
2
Yield to Maturity using R
...ng csv file and thus my equation will change if tenure or no_comp etc. changes. So taking into account the variable nature of the input, I am trying to write a generalized code.
## Input
price = 101 # Price of bond
tenure = 3
no_comp = 1 # no of times coupon paid in a year.
coupon_rate = 0.10 # i.e. 10%
face_value = 100
# Computations
coupon_payment = face_value * coupon_rate
cash_flow = c(rep(c(coupon_payemnt), (no_comp * tenure - 1)), face_value + coupon_payment)
cash_flow
## I am trying to customize the code as given by Mr Ellison.
f.ytm = function(ytm)
{
for...
2010 Jan 19
0
Macaulay Duration for Group
Dear R helpers
I have following csv file which is an input
id par_value coupon_rate frequency_coupon tenure ytm
1 1000 10 1 5 12
# Here frequency_coupon is coded s.t. 0 means Daily compounding, 1 means monthly compouding, 2 means Quarterly, 3 means Half yearly and 4 means only once. Thus in th...