Hi all,

I am running a simulation in STATA and would like to obtain a single mean out of the code below. In particular the code displays 100 values given by
Code:
(y_test`i'-(bx_1_`i'*x_1_test`i'+ bx_2_`i'*x_2_test`i'+bx_3_`i'*x_3_test`i'+bx_4_`i'*x_4_test`i'))^2
. What I would like to do is to make the mean (values/100) and display it at the end of the for loop...can you please help me?

Code:
forvalues i = 1/100{
gen bx_2_`i'= 0
gen bx_3_`i'= 0
gen bx_4_`i'= 0
quietly reg y_tilde_train_eq`i' x_1_train x_2_train x_3_train x_4_train 
matrix coefficienti_`i' = e(b)
gen bx_1_`i'= coefficienti_`i'[1,1]
replace bx_2_`i'= coefficienti_`i'[1,2]
replace bx_3_`i'= coefficienti_`i'[1,3]
replace bx_4_`i'= coefficienti_`i'[1,4]
display (y_test`i'-(bx_1_`i'*x_1_test`i'+ bx_2_`i'*x_2_test`i'+bx_3_`i'*x_3_test`i'+bx_4_`i'*x_4_test`i'))^2

}
Many thanks!