Below are the best I can get so far.
Code:
sysuse census, clear decode region, gen(region_char) local i = 1 local regions South West NE local region_num: word count `regions' matrix result = J(`region_num',3,.) foreach x of local regions { reg divorce pop medage if region_char == "`x'", noconst matrix coeff = e(b) matrix result[`i',2] = coeff[`i',1] matrix result[`i',3] = coeff[`i',2] local i = `i' + 1 matrix drop coeff } matrix list result
a) Only the first regression's estimates are saved in the matrix
b) I want to save string `x' in the first column of the matrix, but it shows type mismatch
c) Is there a good way to save the matrix as a dta dataset?
0 Response to Collect regression results in a loop
Post a Comment