<?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: Matrix functions in Proc MCMC in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195996#M10471</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jacob, but I think still there is problem. Please take a look at this page:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003193719.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003193719.htm"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good news is that it works in PROC MCMC. But bad news is that the page above says that CALL EXPMATRIX does not exponentiate each element of the matrix! While I need to exponentiate each element of a matrix in PROC MCMC. Do you have another suggestion or comment?&lt;/P&gt;&lt;P&gt;Thanks:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jul 2015 06:57:10 GMT</pubDate>
    <dc:creator>Mehdi_R</dc:creator>
    <dc:date>2015-07-07T06:57:10Z</dc:date>
    <item>
      <title>Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195993#M10468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have noticed that PROC MCMC is limited to apply functions on matrices. We can add, subtract, multiply matrices, or take determinant and interse of them. But if I want exponential or log of each entry of a matrix, I need to program it. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;array MAT[1000,1000] ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;array cov[1000,1000] ;&lt;/P&gt;&lt;P&gt;do i = 1 to 1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j = i+1 to 1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cov[i, j] = exp( MAT[i, j]);&lt;/P&gt;&lt;P&gt;&amp;nbsp; cov[j, i] = cov[i, j];&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cov[i,i] = exp(MAT[i, i]);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This slows down the program. Don't you know any simpler or more efficient way of applying functions on matrices? How can I take the exponential of a matrix without a loop?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Jul 2015 20:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195993#M10468</guid>
      <dc:creator>Mehdi_R</dc:creator>
      <dc:date>2015-07-05T20:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195994#M10469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can make use of the matrixfunctions in fcmp. But unfortunately they can not be called immediately from a datastep or procedure. Therefore, what you can do is to make a matrix-function which&amp;nbsp; call the fcmp's expmatrix-function. Your function can then be called from a datastep or from a procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc fcmp outlib = work.func.matrix;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subroutine matrixexp(m[*,*],t,y[*,*]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outargs y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call expmatrix(m, t, y); &lt;/P&gt;&lt;P&gt;&amp;nbsp; endsub; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;option cmplib=(work.func);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array a{2,2} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array y{2,2} _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call matrixexp(a,4,y);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't tested if the functions declared in this way can be called from PROC MCMP, but they work within some other procedures (nlmixed for instance).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made an idea on this site about making the matrix functions directly available without first declare them with PROC FCMP. To my surprise it didnt get so positive votes :smileyshocked: &lt;A _jive_internal="true" href="https://communities.sas.com/ideas/1570"&gt;https://communities.sas.com/ideas/1570&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 21:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195994#M10469</guid>
      <dc:creator>JacobSimonsen</dc:creator>
      <dc:date>2015-07-06T21:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195995#M10470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It was awesome! Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 06:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195995#M10470</guid>
      <dc:creator>Mehdi_R</dc:creator>
      <dc:date>2015-07-07T06:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195996#M10471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jacob, but I think still there is problem. Please take a look at this page:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003193719.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003193719.htm"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good news is that it works in PROC MCMC. But bad news is that the page above says that CALL EXPMATRIX does not exponentiate each element of the matrix! While I need to exponentiate each element of a matrix in PROC MCMC. Do you have another suggestion or comment?&lt;/P&gt;&lt;P&gt;Thanks:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 06:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195996#M10471</guid>
      <dc:creator>Mehdi_R</dc:creator>
      <dc:date>2015-07-07T06:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195997#M10472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I did not read your question correct. If you want to exponentiate elementwise, then change the fcmp function to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc fcmp outlib = work.func.matrix;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subroutine matrixexp(m[*,*],y[*,*]);&lt;/P&gt;&lt;P&gt;&amp;nbsp; outargs y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(m,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j=1 to dim(m,2);&lt;/P&gt;&lt;P&gt;y[i,j]=exp(m[i,j]);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; endsub;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Btw, you can not avoid the loop. Therefore hiding the matrix exponential within a function will not speed up the program. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 07:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195997#M10472</guid>
      <dc:creator>JacobSimonsen</dc:creator>
      <dc:date>2015-07-07T07:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195998#M10473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jacob for your quick reply.&lt;/P&gt;&lt;P&gt;I thought that there might be a more efficient way to calculate exponential of a matrix (matrix of exponential of entries) in PROC MCMC. Because MCMC involves heavy calculations and I wanted to avoid such loop... It seems there is no built-in function in SAS which calculates &lt;SPAN style="font-size: 13.3333330154419px;"&gt;exponential of a matrix...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Do you think writing loops in proc mcmc is faster or writing loops in proc &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;fcmp and then call the subroutine to proc mcmc?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Thanks again Jacob:)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 08:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195998#M10473</guid>
      <dc:creator>Mehdi_R</dc:creator>
      <dc:date>2015-07-07T08:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195999#M10474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, I think it will be almost same speed. Also, even if there was a built in function to make elementwise exponential, then there still is the loop;&lt;/P&gt;&lt;P&gt;Though, it could be made such that the elements are exponentiated in parallel, but don't ask me how that should be programmed&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to gain a bit, you can add m to outargs. I think some copying of values then can be avoided. It will not change much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 08:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/195999#M10474</guid>
      <dc:creator>JacobSimonsen</dc:creator>
      <dc:date>2015-07-07T08:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix functions in Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/196000#M10475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jacob. It was really helpful:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 08:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Matrix-functions-in-Proc-MCMC/m-p/196000#M10475</guid>
      <dc:creator>Mehdi_R</dc:creator>
      <dc:date>2015-07-07T08:47:53Z</dc:date>
    </item>
  </channel>
</rss>

