Hi guys!
I am new to stata and trying to do a loop for a regression for each country (I have 14 countries). I like to generate an output as an matrix and then put it into an excel sheet. This is what I've done, but there occurs an error code:
conformability error
r(503);
putexcel set regresultwithoutweight
foreach i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 {
regress y1 x1 x2 x3 x4 i.YoIDummy if CCDummy== `i', vce(robust) beta
matrix betas=nullmat(beta), e(b)
matrix r2=nullmat(r2), e(r2)
matrix s2=nullmat(s2), e(V)
}
putexcel (A3) = matrix(betas), names overwritefmt
putexcel (A10) = matrix(r2), names overwritefmt
putexcel (A30) = matrix(s2), names overwritefmt
The CCDummy contains the numbering from 1 to 14 which I assigned to each company.
I appreciate any help on this, also if there is an easier way to save just all regression results in that matrix.
Thanks,
Mel
I am new to stata and trying to do a loop for a regression for each country (I have 14 countries). I like to generate an output as an matrix and then put it into an excel sheet. This is what I've done, but there occurs an error code:
conformability error
r(503);
putexcel set regresultwithoutweight
foreach i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 {
regress y1 x1 x2 x3 x4 i.YoIDummy if CCDummy== `i', vce(robust) beta
matrix betas=nullmat(beta), e(b)
matrix r2=nullmat(r2), e(r2)
matrix s2=nullmat(s2), e(V)
}
putexcel (A3) = matrix(betas), names overwritefmt
putexcel (A10) = matrix(r2), names overwritefmt
putexcel (A30) = matrix(s2), names overwritefmt
The CCDummy contains the numbering from 1 to 14 which I assigned to each company.
I appreciate any help on this, also if there is an easier way to save just all regression results in that matrix.
Thanks,
Mel
Comment