Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NumPy: financial irr method returns 'nan'. Why?

When I calculate the Internal Rate of Return (irr) using the numpy method irr, I receive nan as return.

In [45]: numpy.irr([-10, 2, 2, 2, 2])
Out[45]: nan

Shouldn't the results be at least negative? Let's say -8%? When I tried to understand the implementation better, I looked at the master branch of the NumPy repository, but the implementation did not make any sense to me.

The comments and the given literature do not help to understand under which condition nan is issued. When I calculate the irr with another program, I get -8% returned.

Why is NumPy returning nan for the array above?

like image 412
neurix Avatar asked Nov 06 '13 23:11

neurix


People also ask

What is Nan in IRR?

This item has been identified as an outstanding known issue. A workaround is provided until the issue is officially fixed.

Why is IRR not a good measure?

Limitations Of IRRIt ignores the actual dollar value of comparable investments. It does not compare the holding periods of like investments. It does not account for eliminating negative cash flows. It provides no consideration for the reinvestment of positive cash flows.

What assumptions does IRR make?

The IRR assumes that the company will reinvest cash inflows at the rate of return for the entire lifetime of the project. When the reinvestment rate is too high to be feasible, the IRR of the project will fall. If the reinvestment rate is higher than the IRR's rate of return, then the project will be feasible.


1 Answers

Just a small correction to the previous answer. The implementation does not limit IRR to (0,1], it limits 1/(1+IRR) to (0,1]. That limits IRR to [0,+Inf). It is still an incomplete implementation because it returns NaN for cash flows which have an IRR less than 0 (i.e. the investor lost money). The correct range for IRR is (-1,+Inf). The correction, however, is not trivial, because NPV(rate) can have more than one zero, but will have no more than one zero crossing where the rate is greater than zero. So limiting the range to [0,+inf) as the function is implemented means you fail on negative IRRs but also never have to deal with multiple roots being returned.

As a side note, if you're curious about the behavior of NPV(rate), it approaches either +Inf or -Inf as rate approaches -1. The sign of the infinity which it approaches is the same as the sign of the final cashflow. At the other end, as rate approaches +Inf, NPV asymptotically approaches the value of the initial cash flow in the series (usually a negative cash flow). At rate = zero, the value of NPV is the sum of the cash flows.

like image 154
user1419042 Avatar answered Nov 30 '22 21:11

user1419042