<?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: Generating bivariate lognormal data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117113#M24176</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if it what you need. You should run code several times to get almost 0.5 correlation rho.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data simulate;
do i=1 to 300;
r1 = rand('NORMAL',-0.4,0.3);
r2 = rand('NORMAL',-1.4,0.3);
r3 = rand('NORMAL',-1.4,0.3);
r1=0.5*r2+sqrt(1-0.5**2)*r3;
output;
end;

proc corr data=simulate;
var r1 r2;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Jun 2013 01:27:59 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2013-06-25T01:27:59Z</dc:date>
    <item>
      <title>Generating bivariate lognormal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117111#M24174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;I have to generate 30 lines of data from the bivariate lognormal distribution.&lt;/P&gt;&lt;P&gt;I have this information&lt;/P&gt;&lt;P&gt;"The log10 transformed responses follow the normal distribution as follows: X~N(-0.4, 0.3**2) and Y~N(-1.4, 0.3**2). Their correlation rho=0.5"&lt;/P&gt;&lt;P&gt;I have been generating the data with this code so far, which I believe is incorrect. &lt;/P&gt;&lt;P&gt;data simulate;&lt;BR /&gt;keep logy1 logy2;&lt;BR /&gt;do i=1 to 30;&lt;BR /&gt;mu1=-0.4 ;mu2=-1.4;sd1=0.3;sd2=0.3;rho=0.5;&lt;BR /&gt;r1 = rannor(1245);&lt;BR /&gt;r2 = rannor(2923);&lt;BR /&gt;logy1=10**(mu1 + sd1*r1);&lt;BR /&gt;logy2= 10**(mu2 + rho*sd2*r1+sqrt(sd2**2-sd2**2*rho**2)*r2);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;proc corr data=simulate;&lt;BR /&gt;var logy1 logy2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc corr gives me estimates that i do not expect. I suppose I expected to see the mean, sd and rho values that I wrote in the datastep: I don't know how they'd change by being logtransformed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please can anyone help me? I am very stuck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Katie&lt;/P&gt;&lt;P&gt;XX&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 16:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117111#M24174</guid>
      <dc:creator>katiexyz</dc:creator>
      <dc:date>2013-06-24T16:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Generating bivariate lognormal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117112#M24175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Rand function with 'LOGNORMAL' might generate the type of number you need better than the attempted transforms.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 22:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117112#M24175</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-06-24T22:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Generating bivariate lognormal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117113#M24176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if it what you need. You should run code several times to get almost 0.5 correlation rho.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data simulate;
do i=1 to 300;
r1 = rand('NORMAL',-0.4,0.3);
r2 = rand('NORMAL',-1.4,0.3);
r3 = rand('NORMAL',-1.4,0.3);
r1=0.5*r2+sqrt(1-0.5**2)*r3;
output;
end;

proc corr data=simulate;
var r1 r2;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jun 2013 01:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generating-bivariate-lognormal-data/m-p/117113#M24176</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-06-25T01:27:59Z</dc:date>
    </item>
  </channel>
</rss>

