Announcement

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

  • #16
    There is no built in feature of a command that restricts regressions to at least 10 observations, but what you can do is modify the code so that it discards results based on fewer than 10 observations.

    Code:
    gen Jones_Modified = . 
    forval y = 1999(1) 2016 { 
        forval i = 1(1) 52 { 
            display `i' 
            display `y' 
            capture reg TA B1 B2 B3 if `i' == industry & `y' == year, noconstant
            if c(rc) == 0  {    // SUCCESSFUL REGRESSION
                if e(N) >= 10    {    // IGNORE IF < 10 OBS IN REGRESSION
                    predict r if `i' == industry & `y' == year, resid 
                    replace Jones_Modified = r if `i' == industry & `y' == year 
                    drop r
                }
            }
            else if !inlist(c(rc), 2000, 2001) { // UNANTICIPATED ERROR
                display as error "Unexpected error encountered"
                exit c(rc)
            }
            else {    // NO OR INSUFFICIENT OBSERVATIONS; NOTIFY & PROCEED
                display "No or insufficient observations"
            }
        } 
    }

    Comment


    • #17
      Dear Clyde
      I've tried with your comments,
      run the code as below and no result

      one more thing,
      my data has missing total_acc & inv_ta....
      it there any code to ignore the missing data when run the regression?


      foreach i in `a' {
      foreach x in `b' {
      capture noisily reg total_acc inv_ta rev_ar s_ppe if ind_code==`i'&fyr==`x',nocons
      if c(rc)==0
      if e(N)>=10{
      capture noisily predict aa2 if ind_code==`i'&fyr==`x',resid
      capture noisily replace aa=aa2 if if ind_code==`i'&fyr==`x'
      capture noisily drop aa2
      }
      }
      }
      Last edited by Ashley Choi; 06 Jun 2018, 04:20.

      Comment


      • #18
        Hi,Is the following code true for the m jones model? data: 2010-2017 for 35 country and 24 industry
        I think that in case of more than one country, country factor should be taken into consideration in addition to firm-industry.
        Thank you for your contributions.


        xtset firm date, yearly
        gen dREC = d.REC
        gen dREV = d.REV
        gen lA = l.A
        gen TACC = TA/lA
        gen term1 = 1/lA
        gen term2 = (dREV - dREC)/ lA
        gen term3 = PPEG / lA
        tabulate industry, gen(d_dum)
        egen ccode = group(country)
        gen Jones_1995_TAC3=.
        forval y = 2011(1)2017{
        forval i = 1(1)35{
        display `i'
        display `y'
        reg TACC term1 term2 term3 d_dum1-d_dum24 if `i'== ccode&`y'== date
        predict residd if `i'== ccode&`y'== date
        replace Jones_1995_TAC3=residd if `i'== ccode&`y'== date
        drop residd
        }
        }

        Comment


        • #19
          Hi Yasin,
          Please, read Statalist FAQ on the best practices on posting your questions. Namely, when asking for help with code, always show example data using -dataex-.

          That said, I find no sense in the way you regress TACC. To do waht I think you wish to do, you would have to multiply each -term*- by each -d_dum*-.

          You may try this:
          Code:
            
          gen Jones_1995_TAC3=.
          gen TACC = TA/lA gen term1 = 1/lA gen term2 = (dREV - dREC)/ lA gen term3 = PPEG / lA forvalues j = 1/`=_N' { capture quietly { reg TACC term1 term2 term3 if industry == industry[`j'] & ccode == ccode[`j'] & date == date[`j'] & _n != `j' if e(N) >= 8 { replace Jones_1995_TAC3== TACC - (_b[term1] * term1 + _b[term2] * term2 + _b[term3] * term3) in `j' } } }
          NOTE: 1. -_b[term1] * term1 + _b[term2] * term2 + _b[term3] * term3)- is the measure of normal accruals.
          2. Here the minimum number of industry-date observations is 8.
          Last edited by Pedro Coelho; 31 Aug 2019, 14:29.
          Best Regards,

          Pedro
          (StataMP 16 user)

          Comment

          Working...
          X