# st: R: Question about -drawnorm- for two normally distributed variables

 From "Carlo Lazzaro" To Subject st: R: Question about -drawnorm- for two normally distributed variables Date Tue, 18 Mar 2008 18:00:30 +0100

```Dear Tiago,

--------------------------------begin example------------------------
corr2data cholesterol1 cholesterol2, means(125 120) cov(25, 0.7\ 0.7, 50)
cstorage(full)

correlate  cholesterol1 cholesterol2, covariance
(obs=1000)

| choles~1 choles~2
-------------+------------------
cholesterol1 |       25
cholesterol2 |       .7       50

---------------------------------end example------------------------------

HTH and Kind Regards,

Carlo

-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di
tiago.pereira@incor.usp.br
Inviato: marted́ 18 marzo 2008 17.23
A: statalist@hsphsun2.harvard.edu
Oggetto: st: Question about -drawnorm- for two normally distributed
variables

Dear all,

I just want to generate two means which are modelled as being bivariate
normally distributed. However, I am not 100% sure regarding doing that in
Stata.

I have to simulate two variables (mean+-standard deviation, respectively:

variable 1 = 125+-50 mg/dl
variable 2 = 120+-25 mg/dl

covariance = 0.7

In this respect, I am using the following code:

clear
matrix C = (25, 0.7\ 0.7, 50)
matrix m = (125,120)
drawnorm cholesterol1 cholesterol2, n(100) means (m) cov(C)

My question is: is that correct? when I type

corr cholesterol1 cholesterol2, covar

the estimated covariance (for 10^6 simulated values) is far away from the
inputed 0.7 value.

For instance:

| choles~1 choles~2
-------------+------------------
cholesterol1 |  24.9746
cholesterol2 |  .655911  49.9338

(for 1000000 simulated values)

Is that normal or am I doing something wrong?

Tiago

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```