Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- get.yield.equation <-function(t, power, flow, PV){
- sum(flow/((1+t)^power)) - PV # t is a parameter to be calculated
- }
- power<-c(0.01549014, 1.01549014)
- flow<-c(0.5, 100.5)
- PV<-67.07738
- f.ytm<-function(t) {0.5/ (1+t)^(0.01549014) + 100.5/ (1+t)^(1.01549014) - 67.07738 }
- uniroot(f.ytm, interval=c(-1,1), tol= 0.000000000000000001)$root
- [1] 0.5
- t<-uniroot(get.yield.equation(t, c(0.01549014, 1.01549014), c(0.5, 100.5), 67.07738), interval=c(-1,1), tol= 0.000000000000000001)
- Error in uniroot(get.yield.equation(t, c(0.01549014, 1.01549014), c(0.5, :
- could not find function "f"
- uniroot(get.yield.equation(c(0.01549014, 1.01549014), c(0.5, 100.5), 67.07738), interval=c(-1,1), tol= 0.000000000000000001)
- Error in get.yield.equation(c(0.01549014, 1.01549014), c(0.5, 100.5), :
- argument "PV" is missing, with no default
Add Comment
Please, Sign In to add comment