06-24-2013 12:12 PM
I have to generate 30 lines of data from the bivariate lognormal distribution.
I have this information
"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"
I have been generating the data with this code so far, which I believe is incorrect.
keep logy1 logy2;
do i=1 to 30;
r1 = rannor(1245);
r2 = rannor(2923);
logy1=10**(mu1 + sd1*r1);
logy2= 10**(mu2 + rho*sd2*r1+sqrt(sd2**2-sd2**2*rho**2)*r2);
proc corr data=simulate;
var logy1 logy2;
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.
Please can anyone help me? I am very stuck.
06-24-2013 09:27 PM
Not sure if it what you need. You should run code several times to get almost 0.5 correlation rho.
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;