I am having difficulty transitioning a bond value function into a par value function. I believe it should be based around modifying the bond value function, but I am not seeing the process. Any help would be appreciated. After writing the correct par value function, I will have to verify it works with some known inputs.
> bond_value <- function(par, c_rate, ttm, y) {
+ cf <- c(rep(par*c_rate, ttm - 1), par*(1+c_rate))
+ cf <- data.frame(cf)
+ cf$t <- as.numeric(rownames(cf))
+ cf$pv_factor <- 1 / (1 + y)^cf$t
+ cf$pv <- cf$cf * cf$pv_factor
+ sum(cf$pv)
+ }
Can you please describe more about what you want the modified function to calculate?
Given a beginning function
par <- function(bond_value, c, ttm, y) {
determine a function for par value, such that a given set of values will return a correct answer.
Par = Bond Price * 1/ bond price
Firstly, note our homework policy FAQ: Homework Policy.
Be sure to tag a homework question with homework (how? FAQ: How do I edit my topic or reply?), and be sure to not quote your homework verbatim.
A good way to start approaching this question would be to write out the equation for par_value giving bond_value and other parameters (I think that's coupon rate, ttm is time to maturity and y is yield.
It looks like you're maybe taking Ang's datacamp course? The chapter 1 slides walk through this process to create the bond_value function.
Thank you. For the assistance.