Code:
forvalues y = 2015/2017 { // Define a for/next loop spanning years in sample forvalues i = 1/45 { // Define a for/next loop spanning the industries in the sample capture: reg INVESTMENT SALESGROWTH if `y'==Years & `i'==INDUSTRYGROUP , noconstant // estimate Jones-type regression silently, within ind-year samples capture: predict resid`++n' if e(sample), residuals // save residuals in temporary variable named 'residXXX', and increment the local counter capture: replace `rname'=resid`n' if e(sample) // update values of permanent variable with residuals estimated in line above capture: drop resid`n' //drop temporary variable } // NEXT INDUSTRY } // NEXT YEAR
0 Response to Creating and storing residuals in a loop
Post a Comment