[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Rachel <academicgirl@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Drawing multiple variables with fixed correlations to an existing variable and to each other |

Date |
Wed, 15 Aug 2007 17:01:52 -0400 |

Thanks, Paulo. Here is a somewhat more complicated question: Is there a way to generate several variables with a given correlation matrix given a single variable. Again I have an existing variable x1, which is distributed as a standard normal. I'd like to generate x2 and x3 such that corr(x1,x2)=p1 and corr(x1,x3)=p2 and corr(x2,x3)=p3. Assume the resulting correlation matrix is positive definite. If it's possible to achieve this correlation matrix given the x1, can Stat do this? The rationale behind this is that I'm trying to generate a set of variables x1,x2,x3 that have a certain correlation structure, but only for those cases in which x1+c>0 (where c is a predefined number). If there is a more direct way to do this, please let me know. Thank you again, Rachel On 8/15/07, Paulo Guimaraes <guimaraes@moore.sc.edu> wrote: > Rachel, > > If you want a new normal variable that on average has, say 0.5 > correlation, then you can easily do that: > > clear > set obs 10000 > local corr=0.5 > gen x1=invnorm(uniform()) > quietly sum x1 > local sz=r(sd) > local mz=r(mean) > local s2=`sz'^2*(1/`corr'^2-1) > gen x2=x1+sqrt(`s2')*invnorm(uniform()) > corr x1 x2 > > > Paulo Guimaraes > > > Rachel wrote: > > Suppose I have an existing variable x1, which is distributed as a > > standard normal. I wish to create a new variable x2 (also standard > > normal) such that corr(x1,x2)=0.5. ?Is there a way to do this in > > Stata? > > > > Thanks, > > Rachel > > * > > * 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/ > * * 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/

**Follow-Ups**:**Re: st: Drawing multiple variables with fixed correlations to an existing variable and to each other***From:*Michael Hanson <mshanson@mac.com>

- Prev by Date:
**st: Stata str0 BUG [affected versions 8, 9, 10]** - Next by Date:
**RE: st: Power calculation for Beta/Odds Ratios in logistic regression models** - Previous by thread:
**st: Stata str0 BUG [affected versions 8, 9, 10]** - Next by thread:
**Re: st: Drawing multiple variables with fixed correlations to an existing variable and to each other** - Index(es):

© Copyright 1996–2022 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |