<?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 Simulation using PROC MCMC in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/835988#M41406</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I want to simulate my data (a 6 by 6 matrix) using PROC MCMC.&lt;/P&gt;&lt;P&gt;The codes are given below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;N=50000;&lt;BR /&gt;Mean = {0.673 0.663 0.625 0.651 0.680 0.704};&lt;BR /&gt;cov = {0.003368 0.000770 0.000460 0.0001367 0.000609 0.000474,&lt;BR /&gt;0.000770 0.003885 0.000716 -0.00021 0.000540 0.000602,&lt;BR /&gt;0.000460 0.000716 0.002478 0.001006 0.001013 0.000737,&lt;BR /&gt;0.0001367 -0.00021 0.001006 0.005104 0.001282 0.000681,&lt;BR /&gt;0.000609 0.000540 0.001013 0.001282 0.002611 0.001241,&lt;BR /&gt;0.000474 0.000602 0.000737 0.000681 0.001241 0.003422};&lt;BR /&gt;call randseed(1);&lt;BR /&gt;x=Randnormal(N,Mean,Cov);&lt;BR /&gt;SampleMean=x[:,];&lt;BR /&gt;n=nrow(x);&lt;BR /&gt;y= x-repeat(SampleMean, n);&lt;BR /&gt;SampleCov = y`* y / (n-1);&lt;BR /&gt;print SampleMean Mean, SampleCov Cov;&lt;BR /&gt;cname={"x1", "x2", "x3", "x4", "x5", "x6"};&lt;BR /&gt;create inputdata from x [colname=cname];&lt;BR /&gt;append from x;&lt;BR /&gt;close inputdata;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc corr data=inputdata plots(maxpoints=NONE)=matrix(histogram);&lt;BR /&gt;var x:;&lt;BR /&gt;run;&lt;BR /&gt;proc mcmc data=inputdata seed=17 nmc=50000 diag=none ;&lt;BR /&gt;ods select PostSumInt;&lt;BR /&gt;array data[6] x1 x2 x3 x4 x5 x6;&lt;BR /&gt;array mu[6] (0 0 0 0 0 0);&lt;BR /&gt;array Sigma[2,2,2,2,2,2];&lt;BR /&gt;array mu0[6] (0 0 0 0 0 0);&lt;BR /&gt;array Sigma0 [6,6] (100 0 0 0 0 100);&lt;BR /&gt;array S[6,6] (1 0 0 0 0 1);&lt;BR /&gt;parm mu Sigma ;&lt;BR /&gt;prior mu ~ mvn(mu0, Sigma0);&lt;BR /&gt;&lt;U&gt;prior Sigma ~ iwish(6,S);&lt;/U&gt;&lt;BR /&gt;rho = sigma[1,2]/sqrt(sigma[1,1]*sigma[2,2]);&lt;BR /&gt;model data ~ mvn(mu, Sigma);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR: In the inverse Wishart distribution, Sigma must be a 2-dimensional array. A 6-dimensional array was specified.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thannks&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2022 04:01:03 GMT</pubDate>
    <dc:creator>JOADUTWUM</dc:creator>
    <dc:date>2022-09-30T04:01:03Z</dc:date>
    <item>
      <title>Simulation using PROC MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/835988#M41406</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I want to simulate my data (a 6 by 6 matrix) using PROC MCMC.&lt;/P&gt;&lt;P&gt;The codes are given below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;N=50000;&lt;BR /&gt;Mean = {0.673 0.663 0.625 0.651 0.680 0.704};&lt;BR /&gt;cov = {0.003368 0.000770 0.000460 0.0001367 0.000609 0.000474,&lt;BR /&gt;0.000770 0.003885 0.000716 -0.00021 0.000540 0.000602,&lt;BR /&gt;0.000460 0.000716 0.002478 0.001006 0.001013 0.000737,&lt;BR /&gt;0.0001367 -0.00021 0.001006 0.005104 0.001282 0.000681,&lt;BR /&gt;0.000609 0.000540 0.001013 0.001282 0.002611 0.001241,&lt;BR /&gt;0.000474 0.000602 0.000737 0.000681 0.001241 0.003422};&lt;BR /&gt;call randseed(1);&lt;BR /&gt;x=Randnormal(N,Mean,Cov);&lt;BR /&gt;SampleMean=x[:,];&lt;BR /&gt;n=nrow(x);&lt;BR /&gt;y= x-repeat(SampleMean, n);&lt;BR /&gt;SampleCov = y`* y / (n-1);&lt;BR /&gt;print SampleMean Mean, SampleCov Cov;&lt;BR /&gt;cname={"x1", "x2", "x3", "x4", "x5", "x6"};&lt;BR /&gt;create inputdata from x [colname=cname];&lt;BR /&gt;append from x;&lt;BR /&gt;close inputdata;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc corr data=inputdata plots(maxpoints=NONE)=matrix(histogram);&lt;BR /&gt;var x:;&lt;BR /&gt;run;&lt;BR /&gt;proc mcmc data=inputdata seed=17 nmc=50000 diag=none ;&lt;BR /&gt;ods select PostSumInt;&lt;BR /&gt;array data[6] x1 x2 x3 x4 x5 x6;&lt;BR /&gt;array mu[6] (0 0 0 0 0 0);&lt;BR /&gt;array Sigma[2,2,2,2,2,2];&lt;BR /&gt;array mu0[6] (0 0 0 0 0 0);&lt;BR /&gt;array Sigma0 [6,6] (100 0 0 0 0 100);&lt;BR /&gt;array S[6,6] (1 0 0 0 0 1);&lt;BR /&gt;parm mu Sigma ;&lt;BR /&gt;prior mu ~ mvn(mu0, Sigma0);&lt;BR /&gt;&lt;U&gt;prior Sigma ~ iwish(6,S);&lt;/U&gt;&lt;BR /&gt;rho = sigma[1,2]/sqrt(sigma[1,1]*sigma[2,2]);&lt;BR /&gt;model data ~ mvn(mu, Sigma);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR: In the inverse Wishart distribution, Sigma must be a 2-dimensional array. A 6-dimensional array was specified.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thannks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 04:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/835988#M41406</guid>
      <dc:creator>JOADUTWUM</dc:creator>
      <dc:date>2022-09-30T04:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation using PROC MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/836095#M41408</link>
      <description>&lt;P&gt;In general, if you are using code that you copied from somewhere, please provide a link to the original source. That is helpful in trying to determine what the code is doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, it appears that you copied &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_mcmc_details20.htm" target="_self"&gt;code from the PROC MCMC documentation.&lt;/A&gt;&amp;nbsp;The documentation example is for a bivariate distribution, so the covariance parameters are 2 x 2. Your example uses 6 x 6 covariance matrices. Thus, you need to modify the PROC MCMC code to use 6 x 6 matrices.&amp;nbsp; However, the example runs on a simulated data set that contains N=50,000 observations, which is quite large. In the following statements, I set N=10,000 and reduced NMC=5000 so that it runs faster.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
N=10000;
Mean = {0.673 0.663 0.625 0.651 0.680 0.704};
cov = {0.003368 0.000770 0.000460 0.0001367 0.000609 0.000474,
0.000770 0.003885 0.000716 -0.00021 0.000540 0.000602,
0.000460 0.000716 0.002478 0.001006 0.001013 0.000737,
0.0001367 -0.00021 0.001006 0.005104 0.001282 0.000681,
0.000609 0.000540 0.001013 0.001282 0.002611 0.001241,
0.000474 0.000602 0.000737 0.000681 0.001241 0.003422};
call randseed(1);
x=Randnormal(N,Mean,Cov);

cname={"x1", "x2", "x3", "x4", "x5", "x6"};
create inputdata from x [colname=cname];
append from x;
close inputdata;
quit;
/*
proc corr data=inputdata plots(maxpoints=NONE)=matrix(histogram);
var x:;
run;
*/
proc mcmc data=inputdata seed=17 nmc=5000 diag=none ;
*ods select PostSumInt;
array data[6] x1 x2 x3 x4 x5 x6;
array mu[6] (0 0 0 0 0 0);
array Sigma[6,6];
array mu0[6] (0 0 0 0 0 0);
array Sigma0 [6,6] (100  0   0   0   0   0
                    0  100   0   0   0   0
                    0    0 100   0   0   0
                    0    0   0 100   0   0
                    0    0   0   0 100   0
                    0    0   0   0   0 100);
array S[6,6] (1 0 0 0 0 0
              0 1 0 0 0 0
              0 0 1 0 0 0
              0 0 0 1 0 0
              0 0 0 0 1 0
              0 0 0 0 0 1);
parm mu Sigma ;
prior mu ~ mvn(mu0, Sigma0);
prior Sigma ~ iwish(6,S);
rho = sigma[1,2]/sqrt(sigma[1,1]*sigma[2,2]);  /* ?? not used */
model data ~ mvn(mu, Sigma);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 14:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/836095#M41408</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-09-30T14:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simulation using PROC MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/836208#M41414</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It did work.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 19:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulation-using-PROC-MCMC/m-p/836208#M41414</guid>
      <dc:creator>JOADUTWUM</dc:creator>
      <dc:date>2022-09-30T19:58:53Z</dc:date>
    </item>
  </channel>
</rss>

