<?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: Generate correlated random variables that follow beta distributions in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204879#M11018</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like a question for&lt;SPAN class="font-color-meta j-line2"&gt; &lt;A _jive_internal="true" data-avatarid="1051" data-externalid="" data-online="false" data-presence="null" data-userid="129106" data-username="Rick%40SAS" href="https://communities.sas.com/people/Rick@SAS"&gt;Rick Wicklin&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-color-meta j-line2"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Jul 2015 13:52:13 GMT</pubDate>
    <dc:creator>lvm</dc:creator>
    <dc:date>2015-07-17T13:52:13Z</dc:date>
    <item>
      <title>Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204878#M11017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;I need to generate random values for two beta-distributed variables that are&lt;EM&gt; correlated&lt;/EM&gt;. The two variables of interest are characterized as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;----&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;X1 has mean = 0.896 and variance = 0.001.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;X2 has mean = 0.206 and variance = 0.004.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;For X1 and X2, p = 0.5, where p is the correlation coefficient.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;----&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"&gt;I understand how to generate a random number specifying a beta distribution using the function X = RAND('BETA', a, b), where &lt;EM&gt;a&lt;/EM&gt; and &lt;EM&gt;b&lt;/EM&gt; are the two shape parameters for a variable X that can be calculated from the mean and variance. However, I want to generate values for both X1 and X2 simultaneously while specifying that they are correlated at p = 0.5.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 16:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204878#M11017</guid>
      <dc:creator>gavin_jones</dc:creator>
      <dc:date>2015-07-16T16:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204879#M11018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like a question for&lt;SPAN class="font-color-meta j-line2"&gt; &lt;A _jive_internal="true" data-avatarid="1051" data-externalid="" data-online="false" data-presence="null" data-userid="129106" data-username="Rick%40SAS" href="https://communities.sas.com/people/Rick@SAS"&gt;Rick Wicklin&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-color-meta j-line2"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 13:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204879#M11018</guid>
      <dc:creator>lvm</dc:creator>
      <dc:date>2015-07-17T13:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204880#M11019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a duplicate of the same question asked on &lt;A class="active_link" href="http://stackoverflow.com/questions/31459291/generate-correlated-random-variables-that-follow-beta-distributions"&gt;StackOverflow.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run the SAS/IML program on p. 166 of &lt;A href="http://support.sas.com/publishing/authors/wicklin.html"&gt;Simulating Data with SAS&lt;/A&gt;, but substiture the Beta distribution for the Gamma and Exponential variables that appear in the book.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 14:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204880#M11019</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-17T14:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204881#M11020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick--this is the solution I came to yesterday. Thanks for producing such a fantastic resource.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 14:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204881#M11020</guid>
      <dc:creator>gavin_jones</dc:creator>
      <dc:date>2015-07-17T14:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204882#M11021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What values did you get for alpha_1, beta_1 and alpha_2, beta_2?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 14:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204882#M11021</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-17T14:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204883#M11022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data corr_vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x1 var1 x2 var2; *var1 and var2 are the variances for x1 and x2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a_x1 = ((1 - x1) / var1 - 1/ x1) * x1**2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a_x2 = ((1 - x2) / var2 - 1/ x2) * x2**2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; b_x1 = a_x1 * (1 / x1 - 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; b_x2 = a_x2 * (1 / x2 - 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;0.896 0.001 0.207 0.004&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc print data = corr_vars;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alpha1 = 82.597&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; beta1 = 9.587&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alpha2 = 8.289&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; beta2 = 31.750&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, here is the code I used to generate the correlated rates based on the book chapter:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc iml;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call randseed(12345);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N = 10000; *number of random variable sets to generate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Z = RandNormal(N, {0, 0}, {1 0.5, 0.5 1});&amp;nbsp;&amp;nbsp; *RandNormal(N, Mean, Cov);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; U = cdf("Normal", Z); &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1_beta = quantile('BETA', U[,1], 82.597, 9.587);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x2_beta = quantile('BETA', U[,2], 8.289, 31.750);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X = x1_beta || x2_beta;&amp;nbsp; *here are my correlated variables, beta-distributed;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rhoZ = corr(Z)[1,2];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *check correlations;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rhoX = corr(X)[1,2];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print rhoZ rhoX;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 14:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204883#M11022</guid>
      <dc:creator>gavin_jones</dc:creator>
      <dc:date>2015-07-17T14:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204884#M11023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are interested in Pearson correlations, the correlation for the MVN data is not exactly the correlation that you want&amp;nbsp; for the beta variables. It needs to be modified, as explained on p. 167.&amp;nbsp; For this example, I think you want to use&lt;/P&gt;&lt;P&gt;rho = 0.5105&lt;/P&gt;&lt;P&gt;for the MVN data in order to have the correlation ot the beta variables be 0.5.&lt;/P&gt;&lt;P&gt;For Spearman (rank) correlations, no adjustment is necessary.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 19:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/204884#M11023</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-17T19:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/723200#M35060</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to apply the solution here to a slightly different problem: to generated auto-correlated time-series of say 24 intervals (24 hours in a day) with each interval following a Weibull distribution (of different parameters across hours). My understanding is that each value depends on the last one so they have to be generated in sequence.&amp;nbsp;Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bo&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 16:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/723200#M35060</guid>
      <dc:creator>luboxing</dc:creator>
      <dc:date>2021-03-03T16:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/723296#M35062</link>
      <description>&lt;P&gt;Yes, I think if you have a different question then you should start a new thread instead of appending to a thread from 2015.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 21:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/723296#M35062</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-03-03T21:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Generate correlated random variables that follow beta distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/723664#M35083</link>
      <description>Good idea... Just posted!</description>
      <pubDate>Thu, 04 Mar 2021 21:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Generate-correlated-random-variables-that-follow-beta/m-p/723664#M35083</guid>
      <dc:creator>luboxing</dc:creator>
      <dc:date>2021-03-04T21:35:00Z</dc:date>
    </item>
  </channel>
</rss>

