<?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: Bayesian t-test in proc MCMC in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709481#M34357</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt;&amp;nbsp;: I thought of that syntax but rejected it because I decided that it corresponds to an ordinary two-sample t test, not a paired t test. The long-form data does not allow the procedure to know which observations are pre/post, so it just compares the mean of the "pre" and "post" groups. Useful, to be sure, but not a paired t test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jan 2021 19:14:57 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2021-01-05T19:14:57Z</dc:date>
    <item>
      <title>Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709262#M34333</link>
      <description>&lt;P&gt;Is there any way yo perform Paired Bayesian t test in Proc MCMC ? I found the following documents to perform analysis in R and bugs. I am just wondering can we do the same Bayesian paired t-test in SAS?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &lt;A href="http://www.sumsar.net/blog/2014/02/bayesian-first-aid-one-sample-t-test/" target="_blank"&gt;Bayesian First Aid: One Sample and Paired Samples t-test - Publishable Stuff (sumsar.net)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;&lt;A href="https://jkkweb.sitehost.iu.edu/BEST/" target="_blank"&gt;BEST: Bayesian estimation of groups (iu.edu)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/rasmusab/bayesian_first_aid" target="_blank"&gt;3. GitHub - rasmusab/bayesian_first_aid: Inside every classical test there is a Bayesian model trying to get out.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 18:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709262#M34333</guid>
      <dc:creator>nobel1154</dc:creator>
      <dc:date>2021-01-04T18:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709298#M34337</link>
      <description>&lt;P&gt;Yes, you can model the pairs of differences by using a t distribution. For example,&lt;/P&gt;
&lt;P&gt;MODEL diff = t(mean, sd, dof);&lt;/P&gt;
&lt;P&gt;where the three distribution parameters (mean, sd, and dof) are defined by using programming statements and assigned different prior distributions.&amp;nbsp;Once that is done, you can compute a t-statistic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't done this myself, but perhaps&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256681"&gt;@MichaelL_SAS&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;have additional comments or can direct you to a worked example.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709298#M34337</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-01-04T19:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709462#M34354</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256681" target="_blank"&gt;@MichaelL_SAS&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633" target="_blank"&gt;@StatDave_sas&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;any suggestions or sample exmple?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 16:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709462#M34354</guid>
      <dc:creator>nobel1154</dc:creator>
      <dc:date>2021-01-05T16:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709478#M34356</link>
      <description>&lt;P&gt;One way I have done Bayesian paired t is to use PROC GENMOD with a BAYES statement.&amp;nbsp; Try something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=yourdatainlongform;
class pair;
model response=pair;
bayes seed=1 coeffprior=normal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here 'pair' would take on values like 'Pre' and 'Post'.&amp;nbsp; This is the simplest paired-t model.&amp;nbsp; Other covariates/factors can be added to reach the desired model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 19:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709478#M34356</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-01-05T19:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709481#M34357</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt;&amp;nbsp;: I thought of that syntax but rejected it because I decided that it corresponds to an ordinary two-sample t test, not a paired t test. The long-form data does not allow the procedure to know which observations are pre/post, so it just compares the mean of the "pre" and "post" groups. Useful, to be sure, but not a paired t test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 19:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709481#M34357</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-01-05T19:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709482#M34358</link>
      <description>&lt;P&gt;Ulp, you are spot on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;.&amp;nbsp; To get this to be a paired t-test, it has to be a GEE type model.&amp;nbsp; How about this instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=for_stats_in_long_format ;
class pair studyid;
			model result_n = 
					pair
					/  type3;
			repeated subject=subjectid  / type = un printmle ;
			bayes statistics=all seed=1;
            lsmeans pair/diff;
			run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 19:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709482#M34358</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-01-05T19:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709544#M34359</link>
      <description>&lt;P&gt;PROC MCMC is a bit out of my wheelhouse, but I believe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;is pretty much correct. The t-distribution is one of the &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_mcmc_details17.htm&amp;amp;locale=en" target="_self"&gt;standard distributions&lt;/A&gt; recognized by PROC MCMC so it should just be a matter of specifying the the desired prior for the model parameters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on the links you provided here's my quick attempt at mimicking the analysis of the new world data. I did just a quick scan of the link so I might not be matching the prior they used exactly but the results look to be in the same ballpark. I used PROC UNIVARIATE to compute the median absolute deviation of the difference and just by hand used that to determine the prior distribution for the mean and standard deviation based on my quick reading of the link.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data exData;
  input y80 y01;
  datalines;
  9139	14620
  7686	8767
  9996	8729
  5488	8231
  5920	7740
  4096	7264
  4566	6408
  4965	6283
  5487	5740
  5227	5116
  2347	4124
  3089	3240
  1938	2789
;

data exData;
   set exData;
   diff = y01-y80;
run;

proc mcmc data=exData nMC=10000 seed=123456;
  parms mu sigma dfm1 ;
  prior mu ~ normal(1469.8, var=1134225000000);
  prior sigma ~ uniform(1.065,1065000);
  prior dfm1 ~ expon(scale=29);
  df =dfm1 +1 ; 
  model diff ~ t(mu, sd=sigma, df);
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt;&amp;nbsp;I don't think PROC GENMOD supports the REPEATED statement for a Bayesian analysis. While that analysis also probably could be programed in PROC MCMC another alternative would be to use the relatively new &lt;A href="https://support.sas.com/rnd/app/stat/procedures/bglimm.html" target="_self"&gt;BGLIMM procedure&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 02:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709544#M34359</guid>
      <dc:creator>MichaelL_SAS</dc:creator>
      <dc:date>2021-01-06T02:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bayesian t-test in proc MCMC</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709605#M34361</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256681"&gt;@MichaelL_SAS&lt;/a&gt;&amp;nbsp; - you are absolutely right about the REPEATED statement not being supported for Bayesian analysis in GENMOD.&amp;nbsp; There was a note in the log that should have let me know, had I looked closely enough (it was buried amongst several pages of notes regarding compression and decompression of temp files for the analysis I had run).&amp;nbsp; Later today I will give BGLIMM a shot, when I get access to our SAS/STAT 15.1 machine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 12:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709605#M34361</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-01-06T12:18:29Z</dc:date>
    </item>
  </channel>
</rss>

