Displaying 2 results from an estimated 2 matches for "internal_rate_of_return".
2008 Jul 31
3
Code to calculate internal rate of return
Hi all.
I am an R newbie and trying to grasp how the simple optimization routines in
R work. Specifically, I would like some guidance on how to set up a code to
calculate the internal rate of return on an investment project
(http://en.wikipedia.org/wiki/Internal_rate_of_return).
My main problem (I think) is that I want a generic code where N (number of
periods) can be easily changed and set within the code,
Hope this makes sense - any help appreciated !!!
Thomas
--
View this message in context: http://www.nabble.com/Code-to-calculate-internal-rate-of-return-tp1875796...
2010 Aug 25
4
Secant Method Convergence (Method to replicate Excel XIRR/IRR)
...tial date so I could do checks in Excel. This code seems to only converge when my initial guess is very close to the correct IRR.
Maybe I have some basic errors in my coding/logic? Any help would be greatly appreciated.
The Wikipedia article to secant method and IRR: http://en.wikipedia.org/wiki/Internal_rate_of_return#Numerical_solution
Thanks!
ANXIRR <- function (cashFlow, cfDate, guess){
cfDate<-as.Date(cfDate,format="%m/%d/%Y")
irrprev <- c(0); irr<- guess
pvPrev<- sum(cashFlow)
pv<- sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,"2010-...