Hi forum members,
I was searching for a code to run regression based on industry (SIC) and year, and save residuals and coefficients of these regression as variables to be used in next level analysis.
Plus I want the regression to run if at least 20 observations are there per each SIC-year
I found a useful code from the statalist,quoted below
But it generated residuals for each SIC. But I wanted coefficients and residuals for each SIC-year (2000-2014).
I would be really grateful if someone could help me with that, I have around 50 SICs spanning over 10 years (Each SIC will have many firms), approximately need around 50*10 sic-year regressions and generate residual and coefficients as separate variables.
I was searching for a code to run regression based on industry (SIC) and year, and save residuals and coefficients of these regression as variables to be used in next level analysis.
Plus I want the regression to run if at least 20 observations are there per each SIC-year
I found a useful code from the statalist,quoted below
HTML Code:
levelsof SIC, local(codes) foreach code in `codes' { count if SIC == `code' if r(N) >= 20 { reg DV IV1 if SIC == `code' predict res_`code' if SIC == `code', residuals } }
I would be really grateful if someone could help me with that, I have around 50 SICs spanning over 10 years (Each SIC will have many firms), approximately need around 50*10 sic-year regressions and generate residual and coefficients as separate variables.
Comment