<?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 Posterior outcome for &amp;quot;each subject&amp;quot; by Proc MCMC in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Posterior-outcome-for-quot-each-subject-quot-by-Proc-MCMC/m-p/603834#M29387</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;say I have a data set comprised of blood pressure measurements from N subjects. I would like to assign a status (1, 2, or 3) to each subject based on his/her blood pressure level, and the probability of being 1, 2, or 3 is a dirichlet distribution.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data BP;
input ID BP;
datalines;
1 90
2 120
3 80
4 75
5 ...
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified the SAS official Example 75.1-Simulating Samples From a Known Density to perform the analysis:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mcmc data=BP outpost=simout seed=1234 nmc=30000 monitor=(z p);&lt;BR /&gt;
     array ref_p[3] (0.3 0.4 0.3);&lt;BR /&gt;
     array ref_mu[3] (70 100 130);
&lt;BR /&gt;     parm z p mu;
&lt;BR /&gt;     prior z ~ table(p);&lt;BR /&gt;&lt;BR /&gt;     hyperprior p ~ dirich(ref_p);&lt;BR /&gt;&lt;BR /&gt;     prior mu ~ normal(ref_mu[z], prec = 0.05);&lt;BR /&gt;&lt;BR /&gt;     prior tau ~ gamma(0.1, iscale=0.1);&lt;BR /&gt;&lt;BR /&gt;     model BP ~ normal(mu, prec = tau);&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The desired outcome would be like this:&lt;/P&gt;&lt;PRE&gt;ID p1     p2    p3    z
1  0.2    0.3   0.5   3
2  0.4    0.5   0.1   2
3  0.6    0.3   0.1   1
4 ...
...&lt;/PRE&gt;&lt;P&gt;but I only obtained an overall summary of z (mean of 2 since the second ref_p is the highest) for the whole group instead of for each subject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to modify the code so that I can assign which variables should be estimated for the whole group and which are by subject?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 00:13:06 GMT</pubDate>
    <dc:creator>csfcgua1</dc:creator>
    <dc:date>2019-11-14T00:13:06Z</dc:date>
    <item>
      <title>Posterior outcome for "each subject" by Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Posterior-outcome-for-quot-each-subject-quot-by-Proc-MCMC/m-p/603834#M29387</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;say I have a data set comprised of blood pressure measurements from N subjects. I would like to assign a status (1, 2, or 3) to each subject based on his/her blood pressure level, and the probability of being 1, 2, or 3 is a dirichlet distribution.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data BP;
input ID BP;
datalines;
1 90
2 120
3 80
4 75
5 ...
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified the SAS official Example 75.1-Simulating Samples From a Known Density to perform the analysis:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc mcmc data=BP outpost=simout seed=1234 nmc=30000 monitor=(z p);&lt;BR /&gt;
     array ref_p[3] (0.3 0.4 0.3);&lt;BR /&gt;
     array ref_mu[3] (70 100 130);
&lt;BR /&gt;     parm z p mu;
&lt;BR /&gt;     prior z ~ table(p);&lt;BR /&gt;&lt;BR /&gt;     hyperprior p ~ dirich(ref_p);&lt;BR /&gt;&lt;BR /&gt;     prior mu ~ normal(ref_mu[z], prec = 0.05);&lt;BR /&gt;&lt;BR /&gt;     prior tau ~ gamma(0.1, iscale=0.1);&lt;BR /&gt;&lt;BR /&gt;     model BP ~ normal(mu, prec = tau);&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The desired outcome would be like this:&lt;/P&gt;&lt;PRE&gt;ID p1     p2    p3    z
1  0.2    0.3   0.5   3
2  0.4    0.5   0.1   2
3  0.6    0.3   0.1   1
4 ...
...&lt;/PRE&gt;&lt;P&gt;but I only obtained an overall summary of z (mean of 2 since the second ref_p is the highest) for the whole group instead of for each subject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to modify the code so that I can assign which variables should be estimated for the whole group and which are by subject?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 00:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Posterior-outcome-for-quot-each-subject-quot-by-Proc-MCMC/m-p/603834#M29387</guid>
      <dc:creator>csfcgua1</dc:creator>
      <dc:date>2019-11-14T00:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Posterior outcome for "each subject" by Proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Posterior-outcome-for-quot-each-subject-quot-by-Proc-MCMC/m-p/604366#M29388</link>
      <description>&lt;P&gt;Found the solution.&lt;/P&gt;&lt;P&gt;Just use the random statement for z, then everything works out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;random z ~ table(p) subject = id;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 01:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Posterior-outcome-for-quot-each-subject-quot-by-Proc-MCMC/m-p/604366#M29388</guid>
      <dc:creator>csfcgua1</dc:creator>
      <dc:date>2019-11-15T01:10:41Z</dc:date>
    </item>
  </channel>
</rss>

