<?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: Simulating from a Beta distribution with specified skewnewss and kurtosis in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/933206#M6220</link>
    <description>&lt;P&gt;For future reference, here are few related articles:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/15/beta-skewness-kurtosis.html" target="_self"&gt;Moment-ratio diagram and finding the (a,b) values so that Beta(a,b) has a specified skewness and kurtosis&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/22/moment-ratio-skew-kurt.html" target="_self"&gt;Use the moment-ratio diagram to visualize the sampling distribution of skewness and kurtosis&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/29/bimodal-unimodal-beta.html" target="_self"&gt;Bimodal and unimodal beta distributions&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Thu, 20 Jun 2024 18:09:23 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2024-06-20T18:09:23Z</dc:date>
    <item>
      <title>Simulating from a Beta distribution with specified skewnewss and kurtosis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922867#M6186</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am trying to generate a single column of data (length N=250,1000, 2000), from a Beta distribution with specified skewness and kurtosis (I want a range of&amp;nbsp; skewness and kurtosis: skew = 0,1,2 and&amp;nbsp; kurt = 3,5,7).&amp;nbsp; Given&amp;nbsp; values for Skew and Kurt, I am not able to back-solve for the Beta shape parameters A and B.&amp;nbsp; Is there a formula to go from Skew and Kurt to A and B?&lt;/P&gt;
&lt;P&gt;How can I get the data I want? I found this post here which is similar to my problem:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-a-non-normal-distribution-with-specified-skewness-and/td-p/442143" target="_blank"&gt;https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Generating-a-non-normal-distribution-with-specified-skewness-and/td-p/442143&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should I just use the RandFleishman code and modify the FLFUNC and FLDERIV functions be the Beta function and it's first derivative? I am not sure how to go about this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Newton's method to find roots of a function.
    You must supply the FLFUNC and FLDERIV functions
    that compute the function and the Jacobian matrix.
    Input: x0 is the starting guess
           optn[1] = max number of iterations
           optn[2] = convergence criterion for || f ||
    Output: x contains the approximation to the root */
start Newton(x, x0, optn);
   maxIter = optn[1]; converge = optn[2];
   x = x0;
   f = FLFunc(x);
   do iter = 1 to maxIter while(max(abs(f)) &amp;gt; converge);
      J = FLDeriv(x); 
      delta = -solve(J, f);                    /* correction vector */
      x = x + delta;                           /* new approximation */
      f = FLFunc(x);         
   end;
   /* return missing if no convergence */
   if iter &amp;gt; maxIter then x = j(nrow(x0),ncol(x0),.);
finish Newton;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are there otehr modifications I need to make to the RandFleishman code?&lt;/P&gt;
&lt;P&gt;I am new to simulating data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; or others, please help! Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 22:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922867#M6186</guid>
      <dc:creator>nstdt</dc:creator>
      <dc:date>2024-04-03T22:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating from a Beta distribution with specified skewnewss and kurtosis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922935#M6187</link>
      <description>&lt;P&gt;Some of the (skew, kurt) values that you mention are not reachable for a beta(a,b) distribution. Others are limiting cases for the beta but are not properly beta distributions. For example,&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The (skew,kurt)=(2,3) is an impossible combination that is not obtainable by ANY probability distribution.&lt;/LI&gt;
&lt;LI&gt;The pair (0,3) specifies the moments for the normal distribution. The normal distribution is an asymptotic limit of the beta family when a=b and a -&amp;gt; infinity.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Please read about &lt;A href="https://blogs.sas.com/content/iml/2020/01/15/moment-ratio-diagram.html" target="_self"&gt;the moment-ratio diagram,&lt;/A&gt;&amp;nbsp;which shows the feasible (skew,kurt) values for common families.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After you choose feasible (skew, kurt) values, then find the (a,b) values that correspond to them by solving the nonlinear equations that relate (a,b) to (skew, kurt). You can then simulate from the beta(a,b) distribution in each case.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 10:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922935#M6187</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-04-04T10:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating from a Beta distribution with specified skewnewss and kurtosis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922965#M6188</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;Yes, I suppose I have to find a nonlinear solver to get me the shape values a and b, given Skew and Kurtosis.&lt;/P&gt;
&lt;P&gt;Not sure if I need a different post but what&amp;nbsp;if I choose to go with a mixture of Normalsan like in the image below, but truncated on the left? I am going for something like below, but on a bounded interval (on one side only). I am looking to try cross different Skew and Kurtosis values : Skew in 0 to 3 and Kurt in (3,5,7)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nstdt_0-1712237267936.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95204i7A0EFE1302EC1CE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nstdt_0-1712237267936.png" alt="nstdt_0-1712237267936.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;(From&amp;nbsp;&lt;EM&gt;Allison J. Ames, Brian C. Leventhal &amp;amp; Nnamdi C. Ezike (2020) Monte Carlo&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Simulation in Item Response Theory Applications Using SAS, Measurement: Interdisciplinary&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Research and Perspectives, 18:2, 55-74, DOI: 10.1080/15366367.2019.1689762&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&lt;A href="https://doi.org/10.1080/15366367.2019.1689762" target="_blank"&gt;https://doi.org/10.1080/15366367.2019.1689762&lt;/A&gt;&amp;nbsp;)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found this from your blog:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/04/29/normal-mixture-distribution-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2019/04/29/normal-mixture-distribution-sas.html&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2013/07/24/the-truncated-normal-in-sas.html" target="_blank"&gt;Implement the truncated normal distribution in SAS - The DO Loop&lt;/A&gt;&amp;nbsp;?&lt;/P&gt;
&lt;P&gt;Sorry, too many questions. Any advice would help get me started. Thank you again!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 13:37:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922965#M6188</guid>
      <dc:creator>nstdt</dc:creator>
      <dc:date>2024-04-04T13:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating from a Beta distribution with specified skewnewss and kurtosis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922987#M6189</link>
      <description>&lt;P&gt;I don't think you need a separate post. This thread is fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I have already told you, it is impossible to have a probability distribution for which kurt=3 when skew&amp;gt;1.5. You can only use feasible pairs of (skew,kurt) values. In general, the impossible region is defined by kurt &amp;gt;= 1 + skew**2. However, the Fleishman family cannot model the most extreme distributions. Here is some DATA step code to get only the feasible pairs that can be fit by the Fleishman family:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create (skew,kurt) values for skew &amp;gt; 0 that can be fit by Fleishman family */
data FeasSkewKurt;
do skew = 0 to 2.4 by 0.2;
   do kurt = -2 to 10 by 0.5;
      /* keep only valid pairs */
      if kurt &amp;gt; (-1.2264489 + 1.6410373* skew**2) then output;
   end;
end;
run;
&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;The main question you need to answer is WHAT DISTRIBUTIONS do you want to simulate from? You originally said beta distributions, which are bounded. You can either choose from standard families (such as beta, gamma, lognormal,...) and try to get a wide range of (skew,kurt) values, or you can use a flexible family of distributions such as the Fleishman family or the Johnson system. Using a family such as truncated normals or a mixture of normals is going to greatly complicate your life, so I do not recommend using those families. (The problem is that it is hard to find parameter values for each (skew,kurt) pair when you use those distributions.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The basic idea of what you are trying to do is discussed and implemented in&amp;nbsp;&lt;EM&gt;Simulating Data with SAS&lt;/EM&gt; (Wicklin, 2013) in&amp;nbsp;Chapter 16 "Moment Matching and the Moment-Ratio Diagram." In that chapter, I used the Fleishman family, but the same ideas apply to the Johnson system. I recommend either of those families.&amp;nbsp; If you do not have access to that book, you can get the Fleishman functions for free from Appendix D, which is available at&amp;nbsp;&lt;A href="https://support.sas.com/en/books/authors/rick-wicklin.html" target="_blank" rel="noopener"&gt;https://support.sas.com/en/books/authors/rick-wicklin.html&lt;/A&gt;&amp;nbsp;You are comfortable using SAS/IML to simulate the data, you could then write the samples to a data set and use the simulated data anywhere in SAS.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 13:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922987#M6189</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-04-05T13:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating from a Beta distribution with specified skewnewss and kurtosis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922989#M6190</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;, for your patient answer and advice! Yes, the main problem is making sure the Skew and Kurtosis match up with each other , withing a legitimate distribution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very kind of you to help!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 14:35:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/922989#M6190</guid>
      <dc:creator>nstdt</dc:creator>
      <dc:date>2024-04-04T14:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating from a Beta distribution with specified skewnewss and kurtosis</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/933206#M6220</link>
      <description>&lt;P&gt;For future reference, here are few related articles:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/15/beta-skewness-kurtosis.html" target="_self"&gt;Moment-ratio diagram and finding the (a,b) values so that Beta(a,b) has a specified skewness and kurtosis&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/22/moment-ratio-skew-kurt.html" target="_self"&gt;Use the moment-ratio diagram to visualize the sampling distribution of skewness and kurtosis&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/29/bimodal-unimodal-beta.html" target="_self"&gt;Bimodal and unimodal beta distributions&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 20 Jun 2024 18:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Simulating-from-a-Beta-distribution-with-specified-skewnewss-and/m-p/933206#M6220</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-06-20T18:09:23Z</dc:date>
    </item>
  </channel>
</rss>

