<?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 Re: NLPTR can not optimize my function in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412970#M3823</link>
    <description>&lt;P&gt;Thanks for the quick response. I appreciate it.&lt;/P&gt;&lt;P&gt;I am working with log-likelihood but it cannot be simplified so much. The following shows how it is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tmp_final = -log( w_0 * tmp_0 + w_1 * tmp_1 + w_2 * tmp_2 + w_3 * tmp_3 + w_4 * tmp_4 );
        f = f + tmp_final;
        end;
   return ( f );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;tmp's contain exponential.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure why par[2] and tc[1] do not work either. Specifically par[2] should control this overflow problem!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2017 17:36:26 GMT</pubDate>
    <dc:creator>Mina_Juli</dc:creator>
    <dc:date>2017-11-13T17:36:26Z</dc:date>
    <item>
      <title>NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412901#M3821</link>
      <description>&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I have a code to obtain MLE. In my code NLPTR is used and I get the correct answers when I implement the code using some of the datasets I have; however, for one of the datasets with 268 subjects, I get zeros for all parameters. I run the same code with the first 75 subjects and get the estimates without any problem but it works with just the first 75 subjects in the dataset I have. I don't see any problem with my data. My function is a complicated function and my data is longitudinal with 4 specific time points. I need to estimate 35 parameters. The Error is "Overflow error in *&amp;#157;. I also try to resolve the problem by controlling overflow but cannot.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con = { .  .  .  .  .  .  .  .  .  .  1e-4  1e-4    1e-4      1e-4      1e-4        . . . . . . . . . . . . . . . . . . . .  ,  /* lower bounds */
        .  .  .  .  .  .  .  .  .  .    .     .     0.99     0.99      0.48        . . . . . . . . . . . . . . . . . . . .  }; /* upper bounds */
p   = { 6.46 0.65 0.34 0.2 0.13 5 0.2 0.3 0.2 0.1  1     1     0.5       0.6       0.4         0 0 0 0 6 9 0.4 0.4 1.09 0.5 0.2 0.5 0.5 0.3 0.06 0.1 0.9 0.7 0.3 1.1  };/* initial guess for solution*/ 
opt = {1  4};  

tc=repeat(.,1,13);
*tc[1] = 2;
tc[12]=1E-3;
par=repeat(.,1,10);
par[2]=1E-3;

DO MC=1 TO N_MC;
call NLPTR(rc, result, "LogLik", p, opt, con, tc, par) ;
print result;
*print rc;
Results_all[MC,]=result;
END&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 14:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412901#M3821</guid>
      <dc:creator>Mina_Juli</dc:creator>
      <dc:date>2017-11-13T14:02:50Z</dc:date>
    </item>
    <item>
      <title>NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412702#M3825</link>
      <description>&lt;P&gt;I have a code to obtain MLE. In my code NLPTR is used and I get the correct answers when I implement the code using some of the datasets I have; however, for one of the datasets with 268 subjects, I get zeros for all parameters. I run the same code with the first 75 subjects and get the estimates without any problem but it works with just the first 75 subjects in the dataset I have. I don't see any problem with my data. My function is a complicated function and my data is longitudinal with 4 specific time points. I need to estimate 35 parameters. The Error is "Overflow error in *."&amp;#157;. I also try to resolve the problem by controlling overflow but cannot.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con = { .  .  .  .  .  .  .  .  .  .  1e-4  1e-4    1e-4      1e-4      1e-4        . . . . . . . . . . . . . . . . . . . .  ,  /* lower bounds */
        .  .  .  .  .  .  .  .  .  .    .     .     0.99     0.99      0.48        . . . . . . . . . . . . . . . . . . . .  }; /* upper bounds */
p   = { 6.46 0.65 0.34 0.2 0.13 5 0.2 0.3 0.2 0.1  1     1     0.5       0.6       0.4         0 0 0 0 6 9 0.4 0.4 1.09 0.5 0.2 0.5 0.5 0.3 0.06 0.1 0.9 0.7 0.3 1.1  };/* initial guess for solution*/ 
optn = {1    /* maximum   */
      4};   
tc=repeat(.,1,13);
*tc[1] = 2;
tc[12]=1E-3;
par=repeat(.,1,10);
par[2]=1E-3;
DO MC=1 TO N_MC;
call NLPTR(rc, result, "LogLik", p, optn, con,tc,par) ;
print result;
*print rc;
Results_all[MC,]=result;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2017 16:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412702#M3825</guid>
      <dc:creator>Mina_Juli</dc:creator>
      <dc:date>2017-11-12T16:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412777#M3826</link>
      <description>Please share the full code.</description>
      <pubDate>Mon, 13 Nov 2017 00:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412777#M3826</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-11-13T00:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412878#M3827</link>
      <description>&lt;P&gt;It looks like IML code. Post it at IML forum. Rick is there .&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 13:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412878#M3827</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-13T13:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412885#M3828</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 13:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412885#M3828</guid>
      <dc:creator>Mina_Juli</dc:creator>
      <dc:date>2017-11-13T13:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412886#M3829</link>
      <description>&lt;P&gt;Thank you so much. I will.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 13:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412886#M3829</guid>
      <dc:creator>Mina_Juli</dc:creator>
      <dc:date>2017-11-13T13:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412907#M3822</link>
      <description>&lt;P&gt;Since the program works&amp;nbsp;for some data but not for other data, we can assume it is the data.&lt;/P&gt;
&lt;P&gt;Most likely the objective function has either an exponential&amp;nbsp;function call (EXP(v)) or a ratio (1/v) that is overflowing when v is either large or close to zero.&amp;nbsp; You need to &lt;A href="https://blogs.sas.com/content/iml/2015/11/04/trap-cap-division-by-zero.html" target="_self"&gt;trap and cap the bad value before you attempt&amp;nbsp;to evaluate the function.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you are performing MLE, &lt;A href="https://blogs.sas.com/content/iml/2017/06/12/log-likelihood-function-in-sas.html" target="_self"&gt;make sure you are working with the log-likelihood function.&lt;/A&gt; Never work directly with the likelihood&amp;nbsp;function since it tends to overflow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, you can debug your problem by removing the loop and concentrating on the single set of data that is causing the problem. Follow the tips in the article &lt;A href="https://blogs.sas.com/content/iml/2016/05/11/tips-before-optimization.html" target="_self"&gt;"Ten tips before you run an optimization,"&lt;/A&gt;&amp;nbsp;especially #6, #7, #9, and #10.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 14:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412907#M3822</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-11-13T14:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412970#M3823</link>
      <description>&lt;P&gt;Thanks for the quick response. I appreciate it.&lt;/P&gt;&lt;P&gt;I am working with log-likelihood but it cannot be simplified so much. The following shows how it is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tmp_final = -log( w_0 * tmp_0 + w_1 * tmp_1 + w_2 * tmp_2 + w_3 * tmp_3 + w_4 * tmp_4 );
        f = f + tmp_final;
        end;
   return ( f );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;tmp's contain exponential.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure why par[2] and tc[1] do not work either. Specifically par[2] should control this overflow problem!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 17:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/412970#M3823</guid>
      <dc:creator>Mina_Juli</dc:creator>
      <dc:date>2017-11-13T17:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/413005#M3824</link>
      <description>&lt;P&gt;There's not much else I can say without having seeing the LogLik function and data. Can you describe the distribution that you are trying to fit? Have you tried a different optimization algorithm, such as quasi-Newton (NLPQN)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code that shows the log-likelihood seems to have been cut off. There is an END statement, but not DO statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The quantity inside the LOG function looks like&amp;nbsp;the matrix product T*w, where&amp;nbsp;&lt;/P&gt;
&lt;P&gt;T = tmp_0 || tmp_1 || ... || tmp_4&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;w = w0 // w1 // ... // w_4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 18:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/413005#M3824</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-11-13T18:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: NLPTR can not optimize my function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/413865#M3830</link>
      <description>&lt;P&gt;Thank you so much for the response.&lt;/P&gt;&lt;P&gt;I had NLPNRA in my basic codes that I changed to NLPTR. I will continue working on code to&amp;nbsp;find the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 02:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/NLPTR-can-not-optimize-my-function/m-p/413865#M3830</guid>
      <dc:creator>Mina_Juli</dc:creator>
      <dc:date>2017-11-16T02:43:37Z</dc:date>
    </item>
  </channel>
</rss>

