MATLAB Answers

Internal rate of return

14 views (last 30 days)
superkevin2009
superkevin2009 on 12 Oct 2017
Commented: superkevin2009 on 17 Oct 2017
Does anyone know why MATLAB's IRR function gives a different answer from Excel's IRR? This is the cash flow I am interested in computing the internal rate of return for:
-$0 initial investment -the following investments over the following 46 years: [-$1,959.68, -$2,176.69, -$2,572.15, -$3,332.49, -$4,071.79, -$4,005.07, -$4,426.26, -$4,853.17, -$5,078.16, -$5,259.00, -$5,719.65, -$5,778.16, -$5,778.78, -$6,709.74, -$6,406.67, -$6,061.45, -$6,162.63, -$7,278.67, -$8,162.80, -$8,043.16, -$7,873.71, -$8,514.61, -$8,895.17, -$8,871.94, -$10,229.43, -$9,468.29, -$10,131.22, -$9,839.06, -$9,430.92, -$10,078.02, -$10,711.78, -$10,997.18, -$11,463.98, -$11,059.54, -$10,232.35, -$11,112.26, -$11,150.95, -$10,579.02, -$10,990.76, -$11,256.92, -$11,982.57, -$10,209.69, -$10,858.31, -$11,420.19, -$11,180.92, -$9,809.15] -the following payouts after the above investments: [$20,038.39, $20,163.46, $20,289.30, $20,415.93, $20,418.00, $20,420.07, $20,422.14, $20,424.21, $20,426.28, $20,424.21, $20,422.14, $20,420.07, $20,418.00, $20,415.93, $20,357.94, $14,448.15]
so amalgamating the above vector gives us
vec=[0.00, -1959.68, -2176.69, -2572.15, -3332.49, -4071.79, -4005.07, -4426.26, -4853.17, -5078.16, -5259.00, -5719.65, -5778.16, -5778.78, -6709.74, -6406.67, -6061.45, -6162.63, -7278.67, -8162.80, -8043.16, -7873.71, -8514.61, -8895.17, -8871.94, -10229.43, -9468.29, -10131.22, -9839.06, -9430.92, -10078.02, -10711.78, -10997.18, -11463.98, -11059.54, -10232.35, -11112.26, -11150.95, -10579.02, -10990.76, -11256.92, -11982.57, -10209.69, -10858.31, -11420.19, -11180.92, -9809.15, 20038.39, 20163.46, 20289.30, 20415.93, 20418.00, 20420.07, 20422.14, 20424.21, 20426.28, 20424.21, 20422.14, 20420.07, 20418.00, 20415.93, 20357.94, 14448.15];
and then computing the irr:
>> irr(vec)
ans =
Inf
The answer is an infinte ROR! Plugging this into Excel and using their IRR function, however, gives an IRR of -0.58%.
Why is there this discrepancy? I'd imagine MATLAB is numerically solving the equating the discounted sum of initial investment plus discounted cash flows to zero, but maybe it's not properly searching for the zero of the associated function to compute the IRR.
Is this the case and if so, is there a way to rectify this?

  3 Comments

jean claude
jean claude on 12 Oct 2017
i don't know why it's inf , i just tried to check the rate making VAN=0 i find that i=-0.0058 is the best answer it makes 74 actual value
x0=zeros(1);
j=fsolve(@(i) pvvar(vec,i),x0);
superkevin2009
superkevin2009 on 12 Oct 2017
Thanks. Yeah, I have no idea either. Maybe it's a bug.
what you've essentially coded above is what the IRR function is supposed to be doing with an initial guess of zero as the IRR, right?
jean claude
jean claude on 12 Oct 2017
yes exactly! since the definition of TRI is the rate making actual value of the CF equal zero

Sign in to comment.

Answers (1)

Kawee Numpacharoen
Kawee Numpacharoen on 17 Oct 2017
If you remove zero at the beginning, you will get this
>> vec=[-1959.68, -2176.69, -2572.15, -3332.49, -4071.79, -4005.07, -4426.26, -4853.17, -5078.16, -5259.00, -5719.65, -5778.16, -5778.78, -6709.74, -6406.67, -6061.45, -6162.63, -7278.67, -8162.80, -8043.16, -7873.71, -8514.61, -8895.17, -8871.94, -10229.43, -9468.29, -10131.22, -9839.06, -9430.92, -10078.02, -10711.78, -10997.18, -11463.98, -11059.54, -10232.35, -11112.26, -11150.95, -10579.02, -10990.76, -11256.92, -11982.57, -10209.69, -10858.31, -11420.19, -11180.92, -9809.15, 20038.39, 20163.46, 20289.30, 20415.93, 20418.00, 20420.07, 20422.14, 20424.21, 20426.28, 20424.21, 20422.14, 20420.07, 20418.00, 20415.93, 20357.94, 14448.15];
>> irr(vec)
Warning: Multiple rates of return
> In irr (line 172)
ans =
-0.005793443616722

  1 Comment

superkevin2009
superkevin2009 on 17 Oct 2017
Yes, that would work because mathematically, removing the zero element of the vector and finding the IRR of this new vector is the same as what keepinng the zero because a favor of 1/(1+r) cancels in each term in the equation. However, what I am looking to model specifically excludes an initial cash flow, and it's preferable not to have to tweak the real world situation to get the function to work properly.

Sign in to comment.

Sign in to answer this question.