<?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: proc fmm questions in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790502#M40160</link>
    <description>&lt;P&gt;1. You can use the OUTHIST= option on the HISTOGRAM statement in PROC UNIVARIATE to get the histogram information in a SAS data set, which you can then graph:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=sashelp.cars;
   var mpg_city;
   histogram mpg_city / grid vscale=proportion ENDPOINTS OUTHIST=OutHist;
run;

proc sgplot data=OutHist;
   series x=_MINPT_ y=_OBSPCT_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. It sounds like you want to renormalize the gamma distribution by truncating the tail and then dividing by the area under the curve on [0, b], where b is the truncation point. (Maybe you want b=4.2? I'm not sure.) This is called a truncated gamma distribution.&amp;nbsp; I have shown how to &lt;A href="https://blogs.sas.com/content/iml/2013/07/24/the-truncated-normal-in-sas.html" target="_self"&gt;form the truncated NORMAL distribution&lt;/A&gt;, and maybe that article can guide you.&amp;nbsp; The main idea is to divide the PDF and CDF by the areas under the CDF up to the cutoff point. For example, here is the computation for X_max = 4.2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* rescale the PDF so that it is a density on [0, b], where b=4.2 */
data Gamma;
alpha = 3; beta = 0.5;
Denom = cdf('gamma', 4.2, alpha, beta);  /* scaling factor = AUC on [0, 4.2] */
do x = 0 to 4.2 by 0.1;
   PDF = pdf('gamma', x, alpha, beta) / Denom;
   CDF = cdf('gamma', x, alpha, beta) / Denom;
   output;
end;
run;

title "Rescaled PDF and CDF for Gamma(3, 0.5)";
proc sgplot data=Gamma;
   series x=x y=PDF / curvelabel;
   series x=x y=CDF / curvelabel;
   refline 1 / axis=y;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Jan 2022 12:24:31 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-01-17T12:24:31Z</dc:date>
    <item>
      <title>proc fmm questions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790437#M40159</link>
      <description>&lt;P&gt;I have a couple of questions regarding the proc fmm output:&lt;/P&gt;&lt;P&gt;1) How could I convert histogram (the empirical data) into line graph?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) The actual distribution graph looks like a gamma curve with alpha=3 and beta=0.5.&amp;nbsp; x is from 0.01 to 8 by 0.01.&amp;nbsp; Note that 1) there are lots of missing y values for x values starting from 4.2.&amp;nbsp; 2) There's a lot of volatility in the counts which I need to capture in the fitted curve so that my cdf is actually approaching 1, not 0.92 or 1.2&lt;/P&gt;&lt;P&gt;Right now I am doing trial and error by changing the number of parameters, parameter starting values and distribution name.&amp;nbsp; What is the best way to get the optimal fitted distribution result?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jan 2022 22:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790437#M40159</guid>
      <dc:creator>star68</dc:creator>
      <dc:date>2022-01-16T22:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc fmm questions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790502#M40160</link>
      <description>&lt;P&gt;1. You can use the OUTHIST= option on the HISTOGRAM statement in PROC UNIVARIATE to get the histogram information in a SAS data set, which you can then graph:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=sashelp.cars;
   var mpg_city;
   histogram mpg_city / grid vscale=proportion ENDPOINTS OUTHIST=OutHist;
run;

proc sgplot data=OutHist;
   series x=_MINPT_ y=_OBSPCT_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. It sounds like you want to renormalize the gamma distribution by truncating the tail and then dividing by the area under the curve on [0, b], where b is the truncation point. (Maybe you want b=4.2? I'm not sure.) This is called a truncated gamma distribution.&amp;nbsp; I have shown how to &lt;A href="https://blogs.sas.com/content/iml/2013/07/24/the-truncated-normal-in-sas.html" target="_self"&gt;form the truncated NORMAL distribution&lt;/A&gt;, and maybe that article can guide you.&amp;nbsp; The main idea is to divide the PDF and CDF by the areas under the CDF up to the cutoff point. For example, here is the computation for X_max = 4.2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* rescale the PDF so that it is a density on [0, b], where b=4.2 */
data Gamma;
alpha = 3; beta = 0.5;
Denom = cdf('gamma', 4.2, alpha, beta);  /* scaling factor = AUC on [0, 4.2] */
do x = 0 to 4.2 by 0.1;
   PDF = pdf('gamma', x, alpha, beta) / Denom;
   CDF = cdf('gamma', x, alpha, beta) / Denom;
   output;
end;
run;

title "Rescaled PDF and CDF for Gamma(3, 0.5)";
proc sgplot data=Gamma;
   series x=x y=PDF / curvelabel;
   series x=x y=CDF / curvelabel;
   refline 1 / axis=y;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jan 2022 12:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790502#M40160</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-17T12:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc fmm questions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790542#M40161</link>
      <description>Thank you very much for your response. I need to clarify and ask you the following questions:&lt;BR /&gt;1) How could I put both the actual distribution and proc fmm generated mixture distributions on the same graph?&lt;BR /&gt;2) To clarify that even though there are some missing y values for x values from 4.2 to 8.0, the long right tail in general has an asymptote of 0.0003 with little volatility. How could I adjust the fmm procedure for that?</description>
      <pubDate>Mon, 17 Jan 2022 16:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790542#M40161</guid>
      <dc:creator>star68</dc:creator>
      <dc:date>2022-01-17T16:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc fmm questions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790562#M40162</link>
      <description>&lt;P&gt;1. I discuss this in the article &lt;A href="https://blogs.sas.com/content/iml/2021/11/01/fit-mixture-weibull-sas.html" target="_self"&gt;"Fit a mixture of Weibull distributions in SAS."&lt;/A&gt;&amp;nbsp;See the last section (before the Summary).&amp;nbsp; If you need the histogram as well, see &lt;A href="https://blogs.sas.com/content/iml/2013/04/24/overlay-density-curve-on-a-histogram.html" target="_self"&gt;"How to overlay a custom density curve on a histogram in SAS,"&lt;/A&gt; which shows how to use GTL instead of PROC SGPLOT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. When you call PROC FMM, include&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;WHERE x &amp;lt; 4.2;&lt;/STRONG&gt;&lt;BR /&gt;just after the PROC FMM statement. This will cause the parameter estimates to fit only the observations of interest. You might still want to adjust the PDF/CDF as I did in my original response to that the probability is 1 on [0, 4.2].&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 18:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790562#M40162</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-17T18:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc fmm questions</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790569#M40163</link>
      <description>As always, thank you very much, Rick for all your responses. They are helpful!</description>
      <pubDate>Mon, 17 Jan 2022 19:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-fmm-questions/m-p/790569#M40163</guid>
      <dc:creator>star68</dc:creator>
      <dc:date>2022-01-17T19:21:05Z</dc:date>
    </item>
  </channel>
</rss>

