Code downloadable from: https://timquigley.com/rmsm-code/

clear

//set the number of observations

set obs 1000

//create a variable in dataset to capture betas, p-values, and confidence interval

gen b = .

gen p = .

gen ci_l = .

gen ci_h = .

//loop from 1 to 100

forvalues i = 1/100 {

gen y`i' = rnormal() //generate y1 through y100

gen x`i' = rnormal() //generate x1 through x100

reg y`i' x`i' //run regression predicting y_i with x_i

mat b=r(table) //save results table

replace b = b[1,1] if _n==`i' //capture the b-value of the i-th model and save to i-th row

You do not currently have access to this chapter.
Don't already have an account? Register

Purchased this content as a guest? Enter your email address to restore access.

Please enter valid email address.
Email address must be 94 characters or fewer.