Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RES: generating a variable with pre-specified correlations with other two (given) variables


From   Richard Williams <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: RES: generating a variable with pre-specified correlations with other two (given) variables
Date   Wed, 31 Aug 2011 13:59:05 -0500

At 07:41 AM 8/31/2011, fjc wrote:
Thanks, Tirthankar.

This answers my question as originally posted.

Now, something I didn't say in my earlier post (and I think I should
have) is that after I generate the new variable (z) I would like to
run a regression of y on x and z. But if I generate z in the way you
propose, I will get perfect collinearity. ¿Is there any other way to
generate z without getting this collinearity?

Slightly tweaking the earlier example, does this do what you want?

mat mCorr = (1, .6, .4\ .6, 1, .5 \ .4, .5, 1)
corr2data x y z, cstorage(full) corr(mCorr) n(100000) clear
corr
reg z x y

Again, mCorr is a combo of the given correlations for x and y with the desired correlations for z. If you want, you can also specify standard deviations and means, both observed (for x and y) and desired (for z). I am faking all the data, although the correlations etc. can come from real data. If you want to do some combo of fake and real (e.g. generate a z using the realx and realy) it can probably be done but would take a bit more work.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW:    http://www.nd.edu/~rwilliam


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index