<?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: Parameterization of Gamma distribution used in PROC FMM in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507771#M26067</link>
    <description>&lt;P&gt;As discussed in &lt;A href="http://support.sas.com/kb/24166" target="_self"&gt;this note&lt;/A&gt;, the parameterization of the gamma distribution that you are used to is directly used by PROC NLMIXED, so this is much easier in that procedure as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc nlmixed; 
model y~gamma(a,lambda);
run;
data replot;
     do x=0 to 250 by 1;
          density = PDF("GAMMA",x,9.9931,10.0051);
     output;
     end;
run;
proc sgplot data=replot;
  series x=x y=density;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See also &lt;A href="http://support.sas.com/kb/33068" target="_self"&gt;this note&lt;/A&gt; on the gamma in GENMOD and the functions like PDF.&lt;/P&gt;</description>
    <pubDate>Fri, 26 Oct 2018 14:59:25 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2018-10-26T14:59:25Z</dc:date>
    <item>
      <title>Parameterization of Gamma distribution used in PROC FMM</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/196666#M10513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to figure out the parameterization of Gamma distribution used in PROC FMM.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;When I think of the typical Gamma(shape=alpha , rate=beta) parameterization, I at first assumed alpha = (FMM's scale) and beta = &lt;SPAN style="font-size: 13.3333330154419px;"&gt;(FMM's scale) / (FMM's intercept) based on the likelihood shown in the documentation. But that does not seem true and the documentation says that by default a log-link function is used. However, it is not clear at all from the documentation whether this means I need to use exp(FMM's intercept) and perhaps some other transformation on FMM's scale?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is an example of what I might be doing:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp; do i=1 to 1000000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp; y = 10*rangam(123,10);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;proc fmm;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp; model y = / dist=gamma k=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080; font-size: 10pt; line-height: 1.5em;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gave me:&lt;/P&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Fmm: Parameter Estimates for 'Gamma' Model"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Intercept&lt;/TH&gt;&lt;TD class="r data"&gt;4.6050&lt;/TD&gt;&lt;TD class="r data"&gt;0.000316&lt;/TD&gt;&lt;TD class="r data"&gt;14557.2&lt;/TD&gt;&lt;TD class="r data"&gt;&amp;lt;.0001&lt;/TD&gt;&lt;TD class="r data"&gt;99.9813&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="l rowheader" scope="row"&gt;Scale Parameter&lt;/TH&gt;&lt;TD class="r data"&gt;9.9931&lt;/TD&gt;&lt;TD class="r data"&gt;0.01390&lt;/TD&gt;&lt;TD class="r data"&gt; &lt;/TD&gt;&lt;TD class="r data"&gt; &lt;/TD&gt;&lt;TD class="r data"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I now wanted to use the PDF function to simply re-plot the density, what are the shape and scale???&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;data replot;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do x=0 to 100 by 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; density = PDF("GAMMA",x,&lt;SPAN style="color: #ff0000;"&gt;shape&lt;/SPAN&gt;,&lt;SPAN style="color: #ff0000;"&gt;scale&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;proc sgplot data=replot;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;&amp;nbsp; series x=x y=density;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #800080;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I would be grateful, if anyone could tell me exactly how PROC FMM really parameterizes the gamma distribution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Björn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 16:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/196666#M10513</guid>
      <dc:creator>BjoernHolzhauer</dc:creator>
      <dc:date>2015-08-11T16:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterization of Gamma distribution used in PROC FMM</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/196667#M10514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The parameterization is in terms of the mean and dispersion, not the standard shape and scale parameters for the gamma distribution.&lt;/P&gt;&lt;P&gt;This is &lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_genmod_details01.htm"&gt;the same as GENMOD does&lt;/A&gt;, and the doc says&lt;/P&gt;&lt;P&gt;"Probability distributions of the response &lt;SPAN class=" AAmathtext"&gt;Y&lt;/SPAN&gt; in generalized linear models are usually parameterized in terms of the mean &lt;IMG alt="$\mu $" class="math jiveImage" height="11" src="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/images/statug_genmod0013.png" width="9" /&gt; and dispersion parameter &lt;IMG alt="$\phi $" class="math jiveImage" height="15" src="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/images/statug_genmod0015.png" width="7" /&gt; instead of the &lt;EM&gt;natural parameter&lt;/EM&gt; &lt;IMG alt="$\theta $" class="math jiveImage" height="11" src="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/images/statug_genmod0171.png" width="8" /&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But that's okay, because you can convert between the two parameters.&amp;nbsp; If alpha, beta are the shape and scale parameters, respectively, for the gamma distribution, then&lt;/P&gt;&lt;P&gt;intercept = mean = alpha*beta&lt;/P&gt;&lt;P&gt;dispersion = alpha;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is some interesting geometry in the conversion.&amp;nbsp; If you like math, you might enjoy reading &lt;A class="active_link" href="http://blogs.sas.com/content/iml/2014/06/13/geometry-lognormal-distribution.html"&gt;an article I wrote about converting between mean/std and the mu/sigma parameters for the lognormal distribution.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other important aspect of this problem is that the DIST= option activates the LINK= option.&amp;nbsp; In your code, you were implicitly using LINK=LOG, which is the default link function for the gamma distribution. The following code should show you how to convert to the standard gamma parameters:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let shape = 11;&amp;nbsp; /* gamma shape */&lt;BR /&gt;%let scale = 4;&amp;nbsp;&amp;nbsp; /* gamma scale */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Sim;&lt;BR /&gt;call streaminit(12345);&lt;BR /&gt;do i = 1 to 10000;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; y = &amp;amp;scale * rand("Gamma", &amp;amp;shape);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods graphics off;&lt;BR /&gt;proc fmm data=Sim ITDETAILS;&lt;BR /&gt;&amp;nbsp; model y = / dist=gamma k=1 link=identity;&amp;nbsp; /* note LINK= ! */&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* convert intercept/dispersion estimates to shape/scale estimates */&lt;BR /&gt;data Params;&lt;BR /&gt;fmm_int = 44.1356;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* COPY/PASTE from the PROC FMM output */&lt;BR /&gt;fmm_scale = 10.9620;&lt;BR /&gt;call symputx("gam_scale", fmm_int / fmm_scale);&lt;BR /&gt;call symputx("gam_shape", fmm_scale);&lt;BR /&gt;run;&lt;BR /&gt;%put gam_scale= &amp;amp;gam_scale;&lt;BR /&gt;%put gam_shape= &amp;amp;gam_shape;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you read the article &lt;A href="http://communities.sas.com/"&gt;"How to overlay a custom density curve on a histogram in SAS"&lt;/A&gt; you can overlay the estimated gamma density on the simulated data.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="gammafit.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/11362_gammafit.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 19:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/196667#M10514</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-08-11T19:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterization of Gamma distribution used in PROC FMM</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/196668#M10515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! That gets me around having to understand exactly how the model is parameterized in case of the log-link function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2015 06:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/196668#M10515</guid>
      <dc:creator>BjoernHolzhauer</dc:creator>
      <dc:date>2015-08-12T06:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterization of Gamma distribution used in PROC FMM</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507612#M26059</link>
      <description>I'm quite lost with the maths behind this conversion.&lt;BR /&gt;For the weibull estimates from proc fmm the mapping goes as well like this? &lt;BR /&gt;intercept = mean = alpha*beta&lt;BR /&gt;&lt;BR /&gt;dispersion = alpha;&lt;BR /&gt;&lt;BR /&gt;I'd like to understand it but I don't know where to start.</description>
      <pubDate>Thu, 25 Oct 2018 22:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507612#M26059</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2018-10-25T22:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterization of Gamma distribution used in PROC FMM</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507732#M26061</link>
      <description>&lt;P&gt;See my response &lt;A href="https://blogs.sas.com/content/iml/2011/09/23/modeling-finite-mixtures-with-the-fmm-procedure.html" target="_self"&gt;in the comments of this blog post.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 13:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507732#M26061</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-10-26T13:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Parameterization of Gamma distribution used in PROC FMM</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507771#M26067</link>
      <description>&lt;P&gt;As discussed in &lt;A href="http://support.sas.com/kb/24166" target="_self"&gt;this note&lt;/A&gt;, the parameterization of the gamma distribution that you are used to is directly used by PROC NLMIXED, so this is much easier in that procedure as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc nlmixed; 
model y~gamma(a,lambda);
run;
data replot;
     do x=0 to 250 by 1;
          density = PDF("GAMMA",x,9.9931,10.0051);
     output;
     end;
run;
proc sgplot data=replot;
  series x=x y=density;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See also &lt;A href="http://support.sas.com/kb/33068" target="_self"&gt;this note&lt;/A&gt; on the gamma in GENMOD and the functions like PDF.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 14:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Parameterization-of-Gamma-distribution-used-in-PROC-FMM/m-p/507771#M26067</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2018-10-26T14:59:25Z</dc:date>
    </item>
  </channel>
</rss>

