2
$\begingroup$

I need to generate two random variables - lognormal and beta distributed - while ensuring that the correlation between the two variables is -0.3.

I generated two normal random variables with -0.3 correlation as follows;

matrix C = (1, -0.3 \ -0.3, 1)
drawnorm x y, mean(0.921, 0) sds(0.174,1) corr(C)
// Here x is normal rv with mean 0.921 and sd 0.174 while y is a standard normal rv. 

Converting x to lognormal is simple. I do this

gen price = exp(x)
// price is now the lognormal(0.921, 0.174)

Problem is in converting y~$N(0,1)$ to $beta(\alpha,\beta)$. Is there a way to do it?

$\endgroup$
8
  • 1
    $\begingroup$ Some ideas here. $\endgroup$
    – dimitriy
    Commented Sep 5, 2018 at 21:26
  • $\begingroup$ There are many different ways to do this. Perhaps you can get the most control over them by using a copula. $\endgroup$
    – whuber
    Commented Sep 5, 2018 at 22:16
  • $\begingroup$ Cross-posted on SO. $\endgroup$
    – dimitriy
    Commented Sep 5, 2018 at 23:40
  • 1
    $\begingroup$ Are you aware that when you begin with two Normal variates of correlation $\rho$ and transform at least one of them nonlinearly--as will be necessary here--the correlation of the transformed variables is unlikely to equal $\rho$? In light of this fact, is your question really about how to transform a Normal variate into a Beta variate or is it about how to create a lognormal, Beta pair with a desired correlation? $\endgroup$
    – whuber
    Commented Sep 6, 2018 at 0:34
  • $\begingroup$ @whuber good point! Eventually I need lognormal and beta pair with desired correlation. I was hoping that I will adjust the correlation between normals (using trial and error) to get the desired correlation between lognormal and beta. I have been trying to understand copulas and how to implement this in Stata but things seem to not make sense so far. $\endgroup$ Commented Sep 6, 2018 at 16:22

1 Answer 1

0
$\begingroup$

This is how I was able to generate these variables;

matrix      C = (1, -0.32 \ -0.32, 1) // Matrix defining the correlation between two vars
drawnorm    x y, mean(0.921, 0) sds(0.174,1) corr(C) // Generate two multivariate normal vars with specified dependency
// Here x is normal rv with mean 0.921 and sd 0.174 while y is a standard normal rv. 

Converting x to lognormal is simple. I do this

gen price = exp(x)
// price is now the lognormal(0.921, 0.174)

To convert y (a standard normal rv) I generated a normal cdf of y as follows;

gen         z2 = normal(y)

Then I used invibeta function to generate beta density with parameters a and b as follows;

gen yield = invibeta(a, b, z2)

The above process generates price (lognormal) and yield (beta) with correlation of -0.30.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.