mercredi 10 juin 2015

Create correlated variable

I have a variable, var1 already defined. I want to create a new variable, var2 that has a correlation of .1 with var1. I have found that there is something called corr2data, but it seems as if this would need to create both var1 and var2 from scratch.

For the sake of argument, treat var1 as given:

clear all
set more off
set obs 1000
set seed 100
gen var1 = round(runiform(100)) 

How do I now create var2?




Aucun commentaire:

Enregistrer un commentaire