Announcement

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

  • industry year regressions without firm i: additional retrictions can not be added?

    The Following code should run industry and year regressions excluding company i and then estimate the slope coefficients. The existing code has only one sample restriction, which is that the number of firms per each industry and year group is greater than 25:

    Code:
     
     local X inv exp uti acc rd  cf
    tokenize "`X'"
    
    gen adjr2=.
    forval j = 0/6 {
        gen b`j'=.
    }
    
    forval i = 1/`=_N' {
        local same sic_2[`i'] == sic_2 & yr[`i'] == yr
        qui count if `same' & _n != `i'
    
        qui if r(N) > 25  {
             reg pay `X' if `same' & _n != `i'
    
             if _rc == 0 {
                  replace b0 = _b[_cons] in `i'
                  replace adjr2=e(r2_a) in `i'
                  forval j = 1/6 {
                        replace b`j' = _b[``j''] in `i'
                  }
             }
        }
    }
    My question is that how can I edit the code to add the following additional restrictions:
    For each industry and year group, the number of firms that reports a non-zero dividend variable (use div for dividend) is greater than a quarter of the number of firms in each industry year group and must be greater than 10 firms per industry and year group ? Note that div is not a variable in the regression.

    My aim is to ensure that the regression above is estimated when there is a sufficient number of firms in each industry and year group that reports non-zero div. Note that sic_2 is my industry identifier.

    Thank in advance

  • #2
    Most of this can be boiled down to one line using rangestat (SSC).

    Code:
    rangestat (reg) pay inv exp uti acc rd cf, int(yr 0 0) by(sic_2)  excludeself
    Your other restrictions are best applied retrospectively. Just ignore regressions that don't qualify.

    It seems that this is the 500th post on the forum to mention rangestat (SSC).

    Comment


    • #3
      Hi Nick
      I have tried rangestat as per your code in post 2 and it gives me the following error message
      Code:
      statistic (reg): Mata function not found

      Comment


      • #4
        Code:
        which rangestat
        is likely to reveal that you need to update. The version at SSC is 1.1.1 dated 9 May 2017.

        Otherwise it works for me:

        Code:
        .  sysuse auto, clear
        (1978 Automobile Data)
        
        . rangestat (reg) mpg weight, int(rep78 0 0)
        
        . tabdisp rep78, c(reg* b*)
        
        --------------------------------------------------------------------------------------
        Repair    |
        Record    |
        1978      |       reg_nobs         reg_r2     reg_adj_r2       b_weight         b_cons
        ----------+---------------------------------------------------------------------------
                1 |              2                                                            
                2 |              8      .91175931      .89705253     -.00804643      46.110718
                3 |             30      .64187085      .62908052     -.00440965      33.980757
                4 |             18      .83062957      .82004391      -.0049572      35.893817
                5 |             11      .72899997      .69888886     -.01816005      69.544478
                . |                                                                           
        --------------------------------------------------------------------------------------




        Comment

        Working...
        X