i am trying to do CAPM regressions with daily stock returns for every company over a period of 18 years (2002 - 2019). So far i have done a foreah loop and repeated it 18 times (once for each year). Is there any way to combine it and make nly one foreach loop.
This is the code i have done so far. I ran it 18 times (once for each year). I also need to have all the values (beta = systematic risk) in one matrix at the end.
Code:
foreach aktie of varlist u_s_*{ local regressanden `regressanden' `aktie' summarize `aktie' regress `aktie' u_i_SP500COMPOSITE if year == 2002 matrix out = nullmat(out)\ _b[u_i_SP500COMPOSITE] } // Ende Schleife matrix colnames out = beta_02 matrix list out svmat out, names (beta_2002) matrix drop out
Thanks
Patrick
0 Response to Foreach Loop for CAPM regression
Post a Comment