<?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: Optimizing Pseudo-data not returning correct parameters in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125485#M970</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I would need to see sample data to understand what you mean. It seems like the optimization requires a vector.&lt;/P&gt;&lt;P&gt;If you want to apply this optimization to several predator vectors that are stored in a data base, use the GLOBAL statement so that the predator vector is considered a parameter in the problem:&lt;/P&gt;&lt;P&gt;start qfasa(y) global(predator);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to ncol(big_matrix);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; predator = big_matrix[, i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call nlpqn(rc,xr,"qfasa",y,optn,c) ;&amp;nbsp; /* solve for this column */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; /* store or do something with xr */&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jul 2013 10:35:32 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2013-07-03T10:35:32Z</dc:date>
    <item>
      <title>Optimizing Pseudo-data not returning correct parameters</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125482#M967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am a graduate student (in ecology, so not a great background in mathematics or coding languages) attempting an optimization for a part of my thesis.&amp;nbsp; Currently I have the coding below in an attempt to get the "program" to work with pseudo-data.&amp;nbsp; This has been constructed based on publications, which use other programming languages, but the functions are "...local minimizer for smooth non-linear functions subject to bound-constrained parameters, and uses a quasi-newton method". Thus I believe the correct call is NLPQN, however when running this I do not get the expected optimization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc IML;&lt;/P&gt;&lt;P&gt;start qfasa(y);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; prey={17 41 5, 40 30 25}; /*pseudo-profile of three prey items with 2 variables each*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; predator={13.4, 29.5}; /*pseudo-profile of one predator with 2 variables that are the proportional addition of the prey items*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; predic=(prey#y);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; diet=predic[,+];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; KL1=((predator-diet)#log10(predator/diet));&amp;nbsp; /*Kulback-Liebler Distance*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; KL=KL1[+,];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return(KL);&amp;nbsp; /*currently must be a scalar, possible to get this for each predator column when more are added? (do loops?)*/&lt;/P&gt;&lt;P&gt;finish qfasa;&lt;/P&gt;&lt;P&gt;y={.5 .25 .25};&amp;nbsp; /* Initial guess at proportions*/&lt;/P&gt;&lt;P&gt;c={0 0 0, 1 1 1}; /*Constraints on parameters*/&lt;/P&gt;&lt;P&gt;optn={0 2};&lt;/P&gt;&lt;P&gt;call nlpqn(rc,xr,"qfasa",y,optn,c) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*/Answer should be { .25 .15 .60}*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 18:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125482#M967</guid>
      <dc:creator>ahappel</dc:creator>
      <dc:date>2013-07-02T18:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing Pseudo-data not returning correct parameters</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125483#M968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From your starting conditions and your answer, I'm guessing that you expect that the parameters sum to one? (Are they proportions?).&amp;nbsp; You have not constrained the parameter sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two ways you can do this:&lt;/P&gt;&lt;P&gt;1) Leave the constraint matrix as it is and add a penalty term to the objective function. For example, add&lt;/P&gt;&lt;P&gt; return( KL + 1000*(sum(y)-1)##2)&lt;/P&gt;&lt;P&gt;2) Incorporate the constraints into the matrix:&lt;/P&gt;&lt;P&gt;c={0 0 0 . .,&amp;nbsp; /* 0 &amp;lt;= p1, p2, p3 &amp;lt;=1 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1 1 1 . .,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1 1 1 0 1}; /* p1 + p2 + p3 = 1 */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/default/viewer.htm#imlug_nonlinearoptexpls_sect015.htm" title="http://support.sas.com/documentation/cdl/en/imlug/65547/HTML/default/viewer.htm#imlug_nonlinearoptexpls_sect015.htm"&gt;SAS/IML(R) 12.1 User's Guide&lt;/A&gt; for specifying constraints.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 19:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125483#M968</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-07-02T19:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing Pseudo-data not returning correct parameters</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125484#M969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick, the constraints issue got it to do what I wanted!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you (anyone) give me some starting points on getting this to work column-wise on a dataset?&amp;nbsp; Specifically, I have been trying to get column (sample) specific parameter estimates for the "predator" matrix.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 21:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125484#M969</guid>
      <dc:creator>ahappel</dc:creator>
      <dc:date>2013-07-02T21:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing Pseudo-data not returning correct parameters</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125485#M970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I would need to see sample data to understand what you mean. It seems like the optimization requires a vector.&lt;/P&gt;&lt;P&gt;If you want to apply this optimization to several predator vectors that are stored in a data base, use the GLOBAL statement so that the predator vector is considered a parameter in the problem:&lt;/P&gt;&lt;P&gt;start qfasa(y) global(predator);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to ncol(big_matrix);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; predator = big_matrix[, i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call nlpqn(rc,xr,"qfasa",y,optn,c) ;&amp;nbsp; /* solve for this column */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; /* store or do something with xr */&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 10:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Optimizing-Pseudo-data-not-returning-correct-parameters/m-p/125485#M970</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-07-03T10:35:32Z</dc:date>
    </item>
  </channel>
</rss>

