Hello Stata Forum
I have been searching the internet but I can't find an answer to my question. I have the following assignment:
The problem that I have is the line "Consider the following values of ρ: -0.5, 0, 0.5 and 1". I have entered the following in STATA but this is only with rho= -0,5. There must be a easy setup so I can run the experiment 4 times with the different rho values instead of inserting the STATA code 4 times in a row with different rho values?
This is my STATA:
I have been searching the internet but I can't find an answer to my question. I have the following assignment:
The problem that I have is the line "Consider the following values of ρ: -0.5, 0, 0.5 and 1". I have entered the following in STATA but this is only with rho= -0,5. There must be a easy setup so I can run the experiment 4 times with the different rho values instead of inserting the STATA code 4 times in a row with different rho values?
This is my STATA:
Code:
*PROBLEM 5 *DEFINE PROGRAM THAT SPECIFIES THE DGP program dgp, rclass drop _all *SET NUMBER OF CURRENT OBSERVATIONS set obs 1000 *DATA GENERATING PROCESS gen xstar=1+2*rnormal() gen y=4+3*xstar+rnormal() gen x=xstar+rnormal() gen z=1*xstar+rnormal() gen eta=-0.5*rnormal()+rnormal() *CALCULATE OLS ESTIMATES regress y x return scalar b_ols=_b[x] *CALCULATE IV ESTIMATES ivregress 2sls y (x=z) return scalar b_iv=_b[x] end *NOW RUN PROGRAM 500 TIMES USING SIMULATE simulate b_ols=r(b_ols) b_iv=r(b_iv), seed(117) reps(500) nodots:dgp su
Comment