All: I tried to estimate the C-score and G-score following Khan and Watts(2009) - Journal of Accounting and Economics:

1) Step 1: estimate the following cross-sectional equation:
Earni = β0 + β1Di + Ri*(α1+ α2Sizei + α3MTBi+ α4Leveragei) + Di*Ri*( δ1+ δ2Sizei + δ3MTBi+ δ4Leveragei) + (λ1Sizei + λ2MTBi+ λ3Leveragei + λ4Di*Sizei + λ5Di*MTBi + λ6DiLeveragei)+ εi

2) Step 2: calculate G-score and C-score from the above estimates:

G-score = β2 = α1+ α2Sizei + α3MTBi+ α4Leveragei

C-score = β31+ δ2Sizei + δ3MTBi+ δ4Leveragei

My codes are as follow:

sort fyear
by fyear: reg Earn D R R*Size R*MTB R*Leverage D*R D*R*Size D*R*MTB D*R*Leverage Size MTB Leverage D*Size D*MTB D*Leverage
gen G_score = _b[R]*R + _b[R*Size]*R*Size + _b[R*MTB]*R*MTB + _b[R*Leverage]*R*Leverage
gen C_score = _b[D*R]*R*D + _b[D*R*Size]*D*R*Size + _b[D*R*MTB]*D*R*MTB + _b[D*R*Leverage]*D*R*Leverage


The results of C_score and G_score do not seem right.

Any help? I really appreciate.

Ben