Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • C-Score: by-year regressions

    Dear All, Suppose that I have the following data, i.e., 500 firms (id) over 20 years (year).
    Code:
    clear
    set obs 500
    gen id = _n
    expand 20 
    bys id: gen year = _n+1999
    
    set seed 123
    gen X = rnormal()
    gen R = rnormal()
    gen D = (R<0)
    
    gen Size = rnormal()
    gen MB = rnormal()
    gen Leverage = rnormal()
    I wish to calculate the C-score (for each `id' and each `year') as described below:
    Click image for larger version

Name:	C-Score1.png
Views:	1
Size:	21.6 KB
ID:	1546588

    Click image for larger version

Name:	C-Score2.png
Views:	1
Size:	26.4 KB
ID:	1546589


    Any suggestions are highly appreciated.
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    Dear All, I tried the following code, and wish to receive comments from anyone. Note that you have to ssc install runby first.
    Code:
    foreach v of varlist Size MB Leverage {
        gen R_`v' = R*`v'
        gen DR_`v' = D*R*`v'
        gen D_`v' = D*`v'
    }
    gen DR = D*R
     
    reg X D R R_Size R_MB R_Leverage DR DR_Size DR_MB DR_Leverage ///
        Size MB Leverage D_Size D_MB D_Leverage
          
    cap program drop C_score
    program define C_score
      reg X D R R_Size R_MB R_Leverage DR DR_Size DR_MB DR_Leverage ///
          Size MB Leverage D_Size D_MB D_Leverage
      gen C_score3 = _b[DR]+(_b[Size]/_b[DR])*Size+(_b[MB]/_b[DR])*MB+(_b[Leverage]/_b[DR])*Leverage
    end
    
    runby C_score, by(year)
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

    Comment


    • #3
      This code does not generate the same variable that equation (7) shown in #1 defines.

      That equation uses all of the gamma coefficients, which would be the coefficients _b]DR], _b[DR_Size], _b[DR_MB], and _b[DR_Leverage] from the regression in #2. The code shown in #2, however, instead uses_b[DR], _b[Size]/_b[DR], _b[MB]/_b[DR], , and _b[Leverage]/_b[DR]. Only _b[DR] is the same in both places.

      Not being in finance, I have no idea what C_score is supposed to be, so I also have no idea whether equation (7) is correct or whether the code in #2 is correct. But I am completely certain that they are computing different things.

      Comment


      • #4
        Dear Clyde, Thanks for the comments. I will go through the code again.

        Ho-Chuan (River) Huang
        Stata 19.0, MP(4)

        Comment

        Working...
        X