<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to solve for all IRR roots in SAS IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-solve-for-all-IRR-roots-in-SAS-IML/m-p/56090#M329</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a research project that calculates the internal rate of return given various cash inflows and outflows. IRR can be calculated as:&lt;/P&gt;&lt;P&gt;CFo(1+IRR)^n + CF1(1+IRR)^(n-1) + CF2 (1+IRR)^(n-2) + ...+ CFn = 0. &lt;/P&gt;&lt;P&gt;Thus, in other words, IRR is a root of high-order polynominal. In my sample, n varies&amp;nbsp; for each project and it could be as high as 168. Following are two issues that I have been struggling for a long time and hope that someone could help me to the right direction: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1) As IRRs are roots of a polynomial function, it is possible to encounter muptiple IRR. For my sample, due to many sign changes, this problem is prevalent and I am wondering if there is a way to get SAS to calculate ALL these roots, instead of giving just one IRR, along with the warnings of potential multiple IRRS.&lt;/P&gt;&lt;P&gt;(2) In Excel, one has an option of setting the seed (guess rate) as a starting point and I am hoping that SAS IML has similar function such that I could set the starting rate for IRR. Are you aware of any way that I could set the starting guess rate for IRR in SAS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help/ suggestion that you could point me to solve these problems is greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Aug 2011 18:32:21 GMT</pubDate>
    <dc:creator>tsimpson</dc:creator>
    <dc:date>2011-08-28T18:32:21Z</dc:date>
    <item>
      <title>How to solve for all IRR roots in SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-solve-for-all-IRR-roots-in-SAS-IML/m-p/56090#M329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a research project that calculates the internal rate of return given various cash inflows and outflows. IRR can be calculated as:&lt;/P&gt;&lt;P&gt;CFo(1+IRR)^n + CF1(1+IRR)^(n-1) + CF2 (1+IRR)^(n-2) + ...+ CFn = 0. &lt;/P&gt;&lt;P&gt;Thus, in other words, IRR is a root of high-order polynominal. In my sample, n varies&amp;nbsp; for each project and it could be as high as 168. Following are two issues that I have been struggling for a long time and hope that someone could help me to the right direction: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1) As IRRs are roots of a polynomial function, it is possible to encounter muptiple IRR. For my sample, due to many sign changes, this problem is prevalent and I am wondering if there is a way to get SAS to calculate ALL these roots, instead of giving just one IRR, along with the warnings of potential multiple IRRS.&lt;/P&gt;&lt;P&gt;(2) In Excel, one has an option of setting the seed (guess rate) as a starting point and I am hoping that SAS IML has similar function such that I could set the starting rate for IRR. Are you aware of any way that I could set the starting guess rate for IRR in SAS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help/ suggestion that you could point me to solve these problems is greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Aug 2011 18:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-solve-for-all-IRR-roots-in-SAS-IML/m-p/56090#M329</guid>
      <dc:creator>tsimpson</dc:creator>
      <dc:date>2011-08-28T18:32:21Z</dc:date>
    </item>
    <item>
      <title>How to solve for all IRR roots in SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-solve-for-all-IRR-roots-in-SAS-IML/m-p/56091#M330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; From a numerical analysis perspective, there are several problems with this approach (for details, see a numerical analysis book such as Conte and deBoor):&lt;/P&gt;&lt;P&gt;1) High-degree polynomials are numerically unstable. It is difficult to even evaluate a high-degree polynomial because (a) the polynomial overflows when x (=1-IRR) is modestly large (for example |x|&amp;gt;50)&lt;/P&gt;&lt;P&gt;2) Algorithms for finding the roots of polynomials (for example, the POLYROOT function in SAS/IML) tend to become less accurate as the degree grows. (This is not a problem with SAS; I am not aware of ANY algorithm that can reliably find roots of a 168-degree polynomial!)&lt;/P&gt;&lt;P&gt;3) Most of the roots of your polynomial are complex, but I assume you are only interested in real roots. Finding real roots of a high-degree polynomial is known to be difficult.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That said, here's some analysis about the way to attempt this in SAS:&lt;/P&gt;&lt;P&gt;A) No, you can't set a starting condition for the IRR function.&lt;/P&gt;&lt;P&gt;B) You can try to use POLYROOT in SAS/IML, but that tries to find ALL roots (including complex), so you'll run into problems as described above.&lt;/P&gt;&lt;P&gt;C) The most practical approach is to use Newton's method (&lt;A href="http://blogs.sas.com/content/iml/2011/08/05/using-newtons-method-to-find-the-zero-of-a-function/"&gt;http://blogs.sas.com/content/iml/2011/08/05/using-newtons-method-to-find-the-zero-of-a-function/&lt;/A&gt;) or Bisection (&lt;A href="http://blogs.sas.com/content/iml/2011/08/03/finding-the-root-of-a-univariate-function/"&gt;http://blogs.sas.com/content/iml/2011/08/03/finding-the-root-of-a-univariate-function/&lt;/A&gt;) to try to find real roots, especially if you can bound the roots (for example, you only want IRR in [0,1]).&amp;nbsp; You can use Horner's Method (sometimes called Horner's Scheme) to evaluate the polynomial efficiently. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One parting remark: Suppose you have a high-degree monomial such as x##n (n=168 in your example).&amp;nbsp; For what values of x will x##n be less than 10##(-308), which is the smallest representable double-precision value? A little algebra shows that is x &amp;lt; 10##(-1.8) = 0.16, then x##168 will evaluate to ZERO.&amp;nbsp; Thus you are going to have problems finding roots close to zero.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 12:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-solve-for-all-IRR-roots-in-SAS-IML/m-p/56091#M330</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2011-08-29T12:43:55Z</dc:date>
    </item>
  </channel>
</rss>

