<?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: How to implement  Bayesian Estimation Supersedes the t Test (BEST) in SAS? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890536#M44129</link>
    <description>&lt;A href="https://support.sas.com/kb/23/407.html" target="_blank"&gt;https://support.sas.com/kb/23/407.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; could wrote a IML code for you .&lt;BR /&gt;&lt;BR /&gt;Also could check PROC GENMOD.</description>
    <pubDate>Wed, 23 Aug 2023 11:29:19 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-08-23T11:29:19Z</dc:date>
    <item>
      <title>How to implement  Bayesian Estimation Supersedes the t Test (BEST) in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890469#M44125</link>
      <description>&lt;P&gt;Has anyone implemented the BEST approach to compare two group means and their differences?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am interested in a Bayesian approach to a two sample t test. I found this paper which describes an approach referred to as BEST.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://jkkweb.sitehost.iu.edu/articles/Kruschke2013JEPG.pdf" target="_blank" rel="noopener"&gt;Kruschke2013JEPG.pdf (iu.edu)&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;From the paper here is a visual of the model used:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="supp_0-1692732523280.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86914i7310C6560031A90F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="supp_0-1692732523280.png" alt="supp_0-1692732523280.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is my attempt to apply BEST approach described in the paper to the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_mcmc_gettingstarted02.htm" target="_self"&gt;"Behrens-Fisher Problem"&lt;/A&gt; described in the SAS MCMC procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data:&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;data behrens;
   input y ind @@;
   datalines;
121 1  94 1 119 1 122 1 142 1 168 1 116 1
172 1 155 1 107 1 180 1 119 1 157 1 101 1
145 1 148 1 120 1 147 1 125 1 126 2 125 2
130 2 130 2 122 2 118 2 118 2 111 2 123 2
126 2 127 2 111 2 112 2 121 2
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My attempt to apply the BEST method. It seems to me the main difference is the using the t distribution as the likelihood function (as opposed to a normal distribution used in the SAS documentation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
	select mean(y) into :mean_y from behrens;
quit;


/**
Get pooled data
**/
proc glm data= behrens;
	class ind;
	model y = ind;
run;

* Root MSE = 19.32394 ;

%let low_pooled_std = 19.32394 / 1000;
%put &amp;amp;=low_pooled_std. ;


%let high_pooled_std = 19.32394 * 1000;
%put &amp;amp;=high_pooled_std. ;


proc mcmc data=behrens outpost=postout2 seed=123
          nmc=40000 monitor=(_parms_ mudif)
          statistics(alpha=0.01);
   ods select PostSumInt;

   parms mu1 0 mu2 0;
   parms sig21 1;
   parms sig22 1;
   parms nu 1;

   prior mu: ~ N(&amp;amp;mean_y., sd= &amp;amp;high_pooled_std.);  				* prior assumes pooled mean and normal distribution ;
   prior sig2: ~ uniform(&amp;amp;low_pooled_std., &amp;amp;high_pooled_std.);
   prior nu: ~ expon(scale= 29);									* From Kruschke paper, exponential distribution spreads prior credibility fairly evenly over nearly normal and heavy tailed data ;
      
   mudif = mu1 - mu2;

   if ind = 1 then do;
      mu = mu1;
      s2 = sig21;
   end;
   else do;
      mu = mu2;
      s2 = sig22;
   end;
   model y ~ t(mu, var=s2, nu);

/*   model y ~ n(mu, var=s2);		Use this if a normal distribution is desired. The t distribution should handle outlier better*/
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the estimates. These match pretty close the to the example in SAS documentation:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="supp_0-1692733345060.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86915i82552DFB878EDFA9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="supp_0-1692733345060.png" alt="supp_0-1692733345060.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 'Probability difference of means if greater than 0', sum(mudif &amp;gt; 0) / count(*) as probability from postout2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="supp_1-1692733397813.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86916iDE0836E7EAADFDAD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="supp_1-1692733397813.png" alt="supp_1-1692733397813.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The priors are subjective, but I just used the approach described in the paper. These should be modified to fit the analysis being conducted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If anyone has attempted to implement the BEST approach I would appreciate any feedback on my approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 19:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890469#M44125</guid>
      <dc:creator>supp</dc:creator>
      <dc:date>2023-08-22T19:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement  Bayesian Estimation Supersedes the t Test (BEST) in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890476#M44126</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will have an in-depth look to your post tomorrow (it's 22h00 over here).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just this quick message :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bayesian t-test in proc MCMC&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709482#M34358" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/Bayesian-t-test-in-proc-MCMC/m-p/709482#M34358&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(&amp;nbsp;This is about Paired Bayesian t test , but it might give you some more inspiration. )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 19:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890476#M44126</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-08-22T19:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement  Bayesian Estimation Supersedes the t Test (BEST) in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890536#M44129</link>
      <description>&lt;A href="https://support.sas.com/kb/23/407.html" target="_blank"&gt;https://support.sas.com/kb/23/407.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; could wrote a IML code for you .&lt;BR /&gt;&lt;BR /&gt;Also could check PROC GENMOD.</description>
      <pubDate>Wed, 23 Aug 2023 11:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890536#M44129</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-08-23T11:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement  Bayesian Estimation Supersedes the t Test (BEST) in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890539#M44130</link>
      <description>&lt;P&gt;I should mention I don't have access to IML&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 11:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-implement-Bayesian-Estimation-Supersedes-the-t-Test-BEST/m-p/890539#M44130</guid>
      <dc:creator>supp</dc:creator>
      <dc:date>2023-08-23T11:59:52Z</dc:date>
    </item>
  </channel>
</rss>

