Guest User

Untitled

a guest
Feb 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. get.yield.equation <-function(t, power, flow, PV){
  2. sum(flow/((1+t)^power)) - PV # t is a parameter to be calculated
  3. }
  4.  
  5. power<-c(0.01549014, 1.01549014)
  6. flow<-c(0.5, 100.5)
  7. PV<-67.07738
  8.  
  9. f.ytm<-function(t) {0.5/ (1+t)^(0.01549014) + 100.5/ (1+t)^(1.01549014) - 67.07738 }
  10. uniroot(f.ytm, interval=c(-1,1), tol= 0.000000000000000001)$root
  11. [1] 0.5
  12.  
  13. 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)
  14. Error in uniroot(get.yield.equation(t, c(0.01549014, 1.01549014), c(0.5, :
  15. could not find function "f"
  16.  
  17. uniroot(get.yield.equation(c(0.01549014, 1.01549014), c(0.5, 100.5), 67.07738), interval=c(-1,1), tol= 0.000000000000000001)
  18. Error in get.yield.equation(c(0.01549014, 1.01549014), c(0.5, 100.5), :
  19. argument "PV" is missing, with no default
Add Comment
Please, Sign In to add comment