<?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: Grid Search Macro Program Problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266859#M310374</link>
    <description>&lt;P&gt;The innermost DO loop (i=1 to 200) does not contribute to the number of observations in dataset LIKELY. It populates the array MLE. The number of observations is a product of six integers (hence probably quite large): The number of observations in ONET and the numbers of iterations of the five "outer" DO loops. From your initial post, we know only one of these six factors (51) and that three of them are equal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, a useful check (in addition to looking at a couple of observations) would be to compare the number of observations in LIKELY to the product of the number of observations in ONET and the &lt;U&gt;expected&lt;/U&gt; numbers of iterations of the five "outer" DO loops (derived from the start, end and step size values). Due to the PROC SORT step, the values of the index variables in the first 50 observations of dataset LIKELY are hard to predict (at least for me) and most likely not representative for the dataset.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2016 20:47:28 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-04-27T20:47:28Z</dc:date>
    <item>
      <title>Grid Search Macro Program Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266806#M310369</link>
      <description>&lt;P&gt;The assignment I'm working on is to code from scratch a medthod to use commingling analysis methods to maximize a likelihood equation for a biallelic SNP. I am only given the phenotypes and am attemping to do a grid search method to find the parameters (mu1, mu2, mu3, q, and std.dev.) as well as the Log Lilkihood to run a LR test. When I look at 20-50 observations, it seems that my program is not running through any of the variables other than mu1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a suggestion on how to fix it? I've been playing around with different options and can't seem to find a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%Macro likelihood(qstep,mu1step,mu2step,mu3step);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data likely;&lt;BR /&gt;set onet; *transposed data set for horizontal array;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;array aQTp (200) COL1-COL200;&lt;BR /&gt;array MLE (200) MLE1-MLE200;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do q=0.0 to 0.5 by &amp;amp;qstep;&lt;BR /&gt;do mu1=&amp;amp;trtmin to &amp;amp;trtmax by &amp;amp;mu1step;&lt;BR /&gt;do mu2=&amp;amp;trtmin to &amp;amp;trtmax by &amp;amp;mu2step;&lt;BR /&gt;do mu3=&amp;amp;trtmin to &amp;amp;trtmax by &amp;amp;mu3step;&lt;BR /&gt;do sd=&amp;amp;sdmin to &amp;amp;sdmax by &amp;amp;sdstep;&lt;BR /&gt;do i=1 to 200;&lt;BR /&gt;MLE(i)=log(((1-q)**2)*(1/sqrt(2*CONSTANT('PI')*sd))*(EXP((-0.5)*((aQTp(i)-mu1)/sd)**2))+(2*q*(1-q))*(1/sqrt(2*CONSTANT('PI')*sd))*(EXP((-0.5)*((aQTp(i)-mu2)/sd)**2))+(q**2)*(1/sqrt(2*CONSTANT('PI')*sd))*(EXP((-0.5)*((aQTp(i)-mu3)/sd)**2)));&lt;BR /&gt;If MLE(i) =. then MLE(i)=0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;end; *End of QTp Loop;&lt;BR /&gt;logMLEtot=0;&lt;BR /&gt;LogMLEtot=sum(of MLE1-MLE200);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end; *End of SD Loop;&lt;BR /&gt;end; *End of Mu3 Loop;&lt;BR /&gt;end; *End of Mu2 Loop;&lt;BR /&gt;end; *End of Mu1 Loop;&lt;BR /&gt;end; *End of q Loop;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;[... Deleted Code to Check Work and Create Macro Variable Below]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Let MLEtotmax=&amp;amp;MLEtotmax;&lt;/P&gt;&lt;P&gt;Proc sort data=likely;&lt;BR /&gt;by DESCENDING logMLEtot;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Data likely; set likely;&lt;BR /&gt;keep mu1 mu2 mu3 sd q logMLEtot;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;PRoc print data=likely (obs=10);&lt;BR /&gt;run&lt;/P&gt;&lt;P&gt;%MEND likelihood;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%liklihood(0.01,0.01,0.01,0.01)&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 18:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266806#M310369</guid>
      <dc:creator>briggsc</dc:creator>
      <dc:date>2016-04-27T18:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Grid Search Macro Program Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266812#M310370</link>
      <description>&lt;P&gt;Notice that your innermost loop goes from 1 to 200. &amp;nbsp;So the first 200 observations (before sorting) must use the initial values of q, mu1, mu2, mu3, and sd. &amp;nbsp;So when you say you are searching 20 to 50 observations, that may not be enough.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 18:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266812#M310370</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-27T18:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Grid Search Macro Program Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266815#M310371</link>
      <description>Does the i loop correspond to the arrays from the beginning?&lt;BR /&gt;&lt;BR /&gt;When I sort the data set to find the largest LogMLE q=0 and mu2=mu3=trtmin.&lt;BR /&gt;Should the i loop refer to the number of iterations I'd like?&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 27 Apr 2016 18:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266815#M310371</guid>
      <dc:creator>briggsc</dc:creator>
      <dc:date>2016-04-27T18:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Grid Search Macro Program Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266823#M310372</link>
      <description>&lt;P&gt;The innermost loops change first. &amp;nbsp;To begin, the order would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the initial values of q, mu1, mu2, mu3, and sd, let i loop from 1 to 200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Increment sd. &amp;nbsp;For the initial values of q, mu1, mu2, mu3, and the second value for sd, let i loop from 1 to 200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't see the starting and stopping points for the loops, but that's how nested loops work ... innermost increments first.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 19:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266823#M310372</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-27T19:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Grid Search Macro Program Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266829#M310373</link>
      <description>&lt;P&gt;Also not showing values for your TRTMIN TRTMAX SDMIN and SDMAX macro variables could make it hard to determine specific problems with loop counts.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 19:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266829#M310373</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-27T19:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Grid Search Macro Program Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266859#M310374</link>
      <description>&lt;P&gt;The innermost DO loop (i=1 to 200) does not contribute to the number of observations in dataset LIKELY. It populates the array MLE. The number of observations is a product of six integers (hence probably quite large): The number of observations in ONET and the numbers of iterations of the five "outer" DO loops. From your initial post, we know only one of these six factors (51) and that three of them are equal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, a useful check (in addition to looking at a couple of observations) would be to compare the number of observations in LIKELY to the product of the number of observations in ONET and the &lt;U&gt;expected&lt;/U&gt; numbers of iterations of the five "outer" DO loops (derived from the start, end and step size values). Due to the PROC SORT step, the values of the index variables in the first 50 observations of dataset LIKELY are hard to predict (at least for me) and most likely not representative for the dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 20:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grid-Search-Macro-Program-Problem/m-p/266859#M310374</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-27T20:47:28Z</dc:date>
    </item>
  </channel>
</rss>

