Hi,
I have the following code and would like to store the constants being produced from the loop regression so that I can calculate the median. Any help?
I have the following code and would like to store the constants being produced from the loop regression so that I can calculate the median. Any help?
Code:
encode GVKEY, gen(GVKEY_num) estimates clear levelsof GVKEY_num, local(groups) local start_group1 1 local end_group1 88 scalar sum_alpha1 = 0 // Initialize a sum variable for alpha1 scalar count_alpha1 = 0 // Initialize a count variable for alpha1 foreach group of local groups { if `group' >= `start_group1' & `group' <= `end_group1' { regress dealexcessreturns marketexcessreturns if GVKEY_num == `group', robust estimates store capm_`group' scalar alpha1 = _b[_cons] - (rf + benchmarkyrret * marketexcessreturns) display "`group' alpha1: " alpha1 // Update the sum and count for alpha1 scalar sum_alpha1 = sum_alpha1 + alpha1 scalar count_alpha1 = count_alpha1 + 1 } }
Comment