How do I get R to calculate a negative IRR scenario? -
i have been doing stochastic cash flow modeling. in of these scenarios, irr negative (cash flows out exceed cash flows in on time). r seems hate this. uniroot error. have used fincal package irr function, , tried write own uniroot irr formula. it's important formula solves both positive , negative irr scenarios.
any suggestions or ideas? there r package handles this, or simple uniroot formula?
thank you!
i ended writing own code (based upon irr fincal) errors ignored. changed range incorporate negative numbers when uniroot looking solution. fyi - errors happen because value out of range or because there 2 solutions. use irr4 solve.
irr3<-function (cf) { n <- length(cf) subcf <- cf[2:n] uniroot(function(r) -1 * pv.uneven(r, subcf) + cf[1], lower = -.2, upper = .2, tol = .000001)$root} irr4<-function (x) { out<-trycatch(irr3(x),error= function(e) null) return(out)}
Comments
Post a Comment