clear
pause on

set obs 500
gen x = invnorm(uniform()) + 2
gen y = -.3 + .8*x + invnorm(uniform())

reg y x

gen x_u = x + .25*invnorm(uniform())

reg y x_u
pause

gen x_u2 = x + .5*invnorm(uniform())

reg y x_u2
pause

gen z_0 = invnorm(uniform())
gen z_1 = .5*x + invnorm(uniform())
gen z_2 = -.5*x + invnorm(uniform())

local j = 0
while `j'<3{
gen y_`j' = -.3 + .8*x + 1.2*z_`j' + invnorm(uniform())
local j = `j' + 1}
pause


local i = 0
while `i'<3{
replace y_`i' = -.3 + .8*x + .3*z_`i' + invnorm(uniform())
local i = `i' + 1}