Dear Statalist
***I run the following regression to calculate the coefficient on neg_siW
gen c1=.
ivreg2 cesur neg_siW, cluster(firmid yr)
replace c1=_b[neg_siW]
sum c1
**I get:
Variable Obs Mean Std. Dev. Min Max
c1 68490 -.0397268 0 -.0397268 -.0397268
*ofcourse c1 is the same for all observations
*******I try to run a loop to estimate the coefficient per industry (sic_2) and year (yr) combination:
gen c2=.
levelsof sic_2, local(levels)
foreach x of local levels {
foreach z of numlist 1990/2012 {
capture reg cesur neg_siW if sic_2==`x' & yr==`z'
if _rc == 0 {
replace c2=_b[neg_siW] if e(sample)
}
}
}
sum c2
** I get:
Variable Obs Mean Std. Dev. Min Max
c2 68490 .0347764 1.877543 -25.60417 87.14806
What I don't understand is that why the loop generates c2 that has a mean very similar to the value of c1 (which should be the case on average) but with a WRONG SIGN ?
I tried to re run the pooled cross section regression using i.sic_2 i.yr , still the same correct sign which is positive. The sign in the pooled cross sectional regression is the correct one i.e. for c1
while the mean of c2 has a wrong sign.
Why does the loop flips the sign ?
Thanks
***I run the following regression to calculate the coefficient on neg_siW
gen c1=.
ivreg2 cesur neg_siW, cluster(firmid yr)
replace c1=_b[neg_siW]
sum c1
**I get:
Variable Obs Mean Std. Dev. Min Max
c1 68490 -.0397268 0 -.0397268 -.0397268
*ofcourse c1 is the same for all observations
*******I try to run a loop to estimate the coefficient per industry (sic_2) and year (yr) combination:
gen c2=.
levelsof sic_2, local(levels)
foreach x of local levels {
foreach z of numlist 1990/2012 {
capture reg cesur neg_siW if sic_2==`x' & yr==`z'
if _rc == 0 {
replace c2=_b[neg_siW] if e(sample)
}
}
}
sum c2
** I get:
Variable Obs Mean Std. Dev. Min Max
c2 68490 .0347764 1.877543 -25.60417 87.14806
What I don't understand is that why the loop generates c2 that has a mean very similar to the value of c1 (which should be the case on average) but with a WRONG SIGN ?
I tried to re run the pooled cross section regression using i.sic_2 i.yr , still the same correct sign which is positive. The sign in the pooled cross sectional regression is the correct one i.e. for c1
while the mean of c2 has a wrong sign.
Why does the loop flips the sign ?
Thanks
Comment