Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-26 Thread Berend Hasselman
I couldn't resist the temptation. Here is the example using the R package nleqslv. library(nleqslv) npv <- function (irr, cashFlow, times) sum(cashFlow / (1 + irr)^times) CF <- c(-1000,500,500,500,500,500) dates <- c("1/1/2001","2/1/2002","3/1/2003","4/1/2004","5/1/2005","6/1/2006") cfDate <-

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Adrian Ng
--- From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] Sent: Wednesday, August 25, 2010 7:24 PM To: Adrian Ng Cc: r-help@r-project.org Subject: RE: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR) The secant method converges just fine. Your problem might have occurred due to improper

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Ravi Varadhan Date: Wednesday, August 25, 2010 10:51 pm Subject: Re: [R] Secant Method Convergence

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
is helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message --

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
uot;1/1/2001","2/1/2002","3/1/2003","4/1/2004","5/1/2005","6/1/2006") ANXIRR(CF, dates, guess=0.1) > ANXIRR(CF, dates, guess=0.1) $irr [1] 0.4106115 $npv [1] 2.984279e-13 Ravi. -Original Message- From: Adrian Ng [mailto:a...@hamil

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
: Adrian Ng; r-help@r-project.org Subject: RE: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR) Another approach is to use `uniroot' to find the zero of the NPV function: npv <- function (cashFlow, irr) { n <- length(cashFlow) sum(cashFlow / (1 + i

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
Convergence (Method to replicate Excel XIRR/IRR) Hi, I am new to R, and as a first exercise, I decided to try to implement an XIRR function using the secant method. I did a quick search and saw another posting that used the Bisection method but wanted to see if it was possible using the secant metho

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
To: r-help@r-project.org Subject: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR) Hi, I am new to R, and as a first exercise, I decided to try to implement an XIRR function using the secant method. I did a quick search and saw another posting that used the Bisection method but wanted to

[R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Adrian Ng
Hi, I am new to R, and as a first exercise, I decided to try to implement an XIRR function using the secant method. I did a quick search and saw another posting that used the Bisection method but wanted to see if it was possible using the secant method. I would input a Cash Flow and Date vect