[R-SIG-Finance] IRR - Calculation in R

Thomas Etheber etheber at gmx.de
Thu Nov 27 15:12:09 CET 2008


Hi there,

can anyone recommend a comfortable package for the calculations of the internal rate of return (IRR)? I had a quick look at google and the history of this newsgroup, but couldnt find something usefull.

Is polyroot the right choice?
The polyroot function returns all values including the complex ones.

Is there a possibility to filter for real-numbers only?
Here is a piece of code:

> p <- c(-10000, 1322, -1200, 12000)
> p
[1] -10000   1322  -1200  12000
> 1/polyroot(p) - 1
[1]  0.06936167+0.000000i -1.46858084-0.950051i -1.46858084+0.950051i
> a <- 1/polyroot(p) - 1
> is.complex(a)
[1] TRUE
> is.complex(a[1])
[1] TRUE
> is.complex(a[2])
[1] TRUE
> is.complex(a[3])
[1] TRUE
> is.complex(a[4])
[1] TRUE

Why are all of those TRUE, I expected that  is.complex(a[1]) would bring a FALSE?

Thx in advance 
Thomas






-- 
Sensationsangebot nur bis 30.11: GMX FreeDSL - Telefonanschluss + DSL 
für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a



More information about the R-SIG-Finance mailing list