Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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 <richardwilliams.ndu@gmail.com>
To   statalist@hsphsun2.harvard.edu, statalist@hsphsun2.harvard.edu
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:  Richard.A.Williams.5@ND.Edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index