Sampling variation is normal; if you want to match .7 exactly use -corr2data-
Your code doesn't match your stated desiderata:
* variable 1 = 125+-50 mg/dl
* variable 2 = 120+-25 mg/dl
* covariance = 0.7
clear
matrix C = (50, 0.7\ 0.7, 25)
matrix m = (125,120)
drawnorm cholesterol1 cholesterol2, n(1000) means(m) cov(C)
su ch*
corr ch*, cov
On Tue, Mar 18, 2008 at 12:23 PM, <[email protected]> wrote:
> 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?
>
> Thanks again for your time.
>
> 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/