<?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 Fitting exponential distributed data and overlaying empirical with theoretical data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384556#M91843</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By using &lt;EM&gt;SEVERITY&lt;/EM&gt; procedure, I found that the exponential distribution is the one that fits better empirical data; so, I got the parameter theta.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I built a random dataset distributed according to an exponential distribution wiith parameter &lt;EM&gt;theta&lt;/EM&gt; equal to &lt;EM&gt;0.7423&lt;/EM&gt;, on the basis of the following code:&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 exponential (keep = x);
	call streaminit(&amp;amp;seed.);
	theta = &amp;amp;theta.;
		do i = 1 to &amp;amp;n.;
			x = theta * rand("Exponential");
			output;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where n, theta estimate and seed are previosly defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After that, I merge the empirical data with the ones etimated above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I want to compare graphically the distributions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you suggest a way to overlay them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2017 10:20:18 GMT</pubDate>
    <dc:creator>Quantopic</dc:creator>
    <dc:date>2017-08-01T10:20:18Z</dc:date>
    <item>
      <title>Fitting exponential distributed data and overlaying empirical with theoretical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384556#M91843</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By using &lt;EM&gt;SEVERITY&lt;/EM&gt; procedure, I found that the exponential distribution is the one that fits better empirical data; so, I got the parameter theta.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I built a random dataset distributed according to an exponential distribution wiith parameter &lt;EM&gt;theta&lt;/EM&gt; equal to &lt;EM&gt;0.7423&lt;/EM&gt;, on the basis of the following code:&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 exponential (keep = x);
	call streaminit(&amp;amp;seed.);
	theta = &amp;amp;theta.;
		do i = 1 to &amp;amp;n.;
			x = theta * rand("Exponential");
			output;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where n, theta estimate and seed are previosly defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After that, I merge the empirical data with the ones etimated above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I want to compare graphically the distributions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you suggest a way to overlay them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 10:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384556#M91843</guid>
      <dc:creator>Quantopic</dc:creator>
      <dc:date>2017-08-01T10:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting exponential distributed data and overlaying empirical with theoretical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384557#M91844</link>
      <description>&lt;P&gt;Is this a "from a stats point of view whats the best way to graphically represent this type of data"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or a "technically how do I overlay data in a graph" question?&lt;/P&gt;
&lt;P&gt;I can't answer the first as thats all greek to me (literally), but for the second, using sgplot ot Graph Template language it is very easy to overlay multiple plots, first join your data, then sgplot it:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=have;
  scatter x=xvalue y=empirical;
  scatter x=xvalue y=othervalue;
run;&lt;/PRE&gt;
&lt;P&gt;Will overlay the two graphs, although need to check axis values etc, to make sure they match somehow (not much good if all of one set of values is 100* more than the other for instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 10:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384557#M91844</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-01T10:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting exponential distributed data and overlaying empirical with theoretical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384662#M91872</link>
      <description>&lt;P&gt;You've generated random Exp(theta) data. A better way is to compute the Exp(theta) PDF (density) and overlay that. &amp;nbsp;You can do it with PROC SGPLOT, but the easiest way is to use the ODS&amp;nbsp;graphics that are automatically produced by PROC SEVERITY or PROC UNIVARIATE. Try submitting&lt;/P&gt;
&lt;P&gt;ODS GRAPHICS ON;&lt;/P&gt;
&lt;P&gt;before you run the PROC SEVERITY code and you should automatically get a histogram and a fitted density curve, as shown below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data exponential (keep = x);
call streaminit(12345);
theta = 7;
do i = 1 to 200;
	x = theta * rand("Exponential");
	output;
end;
run;

ods graphics on;
proc severity data=exponential;
   loss x;
   dist exp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Aug 2017 16:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fitting-exponential-distributed-data-and-overlaying-empirical/m-p/384662#M91872</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-08-01T16:48:33Z</dc:date>
    </item>
  </channel>
</rss>

