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.

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

 From Richard Williams 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 09:01:10 -0500

```At 07:47 AM 8/31/2011, Tirthankar Chakravarty wrote:
```
```Throw in some orthogonal, zero mean noise when constructing Z:

g z = .15625*x+.40625*y + runiform()
```
```
```
I believe that will zap the correlations though, won't it? i.e. the correlations of z with x and y will get smaller.
```
```
```> P.D. The reason I want to run the aforementioned regression is the
> following. Suppose I have an initial regression of y on x, and x turns
> out to be insignificantly different from zero at some chosen
> confidence level. Then I want to generate an example in which adding a
> new (artificial) variable z as a covariate I can get x to become
> significantly different from zero at the same confidence level. Based
> on the formula for the t-test, I think I can do this if I can control
> the correlations between the artificial variable and the original
> ones. The excercise is just for expositional purposes, I do not want
> to attach any deep meaning to it.
```
```
```
If this is just for expositional purposes, it would probably be easier just to fake all the data with corr2data, rather than trying to create a combo of fake and real data. I think you could add a variable e that had 0 correlation with x and y and nonzero correlation with z. I generally find it is easier to get fake data to behave the way I want rather than real data.
```

-------------------------------------------
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/
```