I am trying to write a code that shows me the results of 1000 replications (I want to do a placebo test). I would like to end up with a matrix that shows the coefficient, the standard error and the t-value of the variable of interest (thus 3 columns, 1000 rows).
Assume that I am using the auto dataset, and I am running a regression and I am interested in the variable foreign. For the placebo test, I am assigning random values to foreign, re-running the regression, and storing the coefficients of foreign in a matrix (this is what I managed to do, see the code below). How can I expand this matrix so that it also includes the s.e. and t-value?
Assume that I am using the auto dataset, and I am running a regression and I am interested in the variable foreign. For the placebo test, I am assigning random values to foreign, re-running the regression, and storing the coefficients of foreign in a matrix (this is what I managed to do, see the code below). How can I expand this matrix so that it also includes the s.e. and t-value?
Code:
sysuse auto, clear regress price weight mpg foreign count if foreign == 1 local numberforeign = r(N) tempname resmat forv i=1(1)1000 { gen randomorder = runiform() sort randomorder drop foreign gen foreign = 0 replace foreign = 1 in 1/`numberforeign' regress price weight mpg foreign matrix `resmat'=nullmat(`resmat')\ e(b) drop randomorder } matlist `resmat', format(%9.3f) matrix V = `resmat' matrix a = V[1..1000 ,3..3] mat list a
Comment