Announcement

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

  • Problems with bootstrapping

    Dear Statalist users,

    I am trying to calculated bootstrapped differences in coefficients across two samples using code that I found on the forum. But I always get an error message.

    This is my code for the bootstrapping:

    capture program drop bootem
    program define bootem, rclass
    reghdfe logIC_w treatment_post logSALE_w lagCash_ta_w lagSIZE_w lagDebt_ta_w roa_w Q_w if constraint==1,absorb (fyear#cohort gvkey#cohort)
    est store a
    reghdfe logIC_w treatment_post logSALE_w lagCash_ta_w lagSIZE_w lagDebt_ta_w roa_w Q_w if constraint==0,absorb (fyear#cohort gvkey#cohort)
    est store b
    suest a b
    lincom [a_mean]_b[treatment_post_new ]-[b_mean]_b[treatment_post_new ]
    return scalar diff12 = r(estimate)
    end

    bootstrap diff = r(diff12), strata(avg_exante_constraint_all) nodrop reps(100) nodots: bootem

    And this is the error message I receive:

    "unable to generate scores for model a
    suest requires that predict allow the score option
    an error occurred when bootstrap executed bootem
    r(322);"

    Thanks,
    Annelies

  • #2
    Hi Annelies
    The problem you are facing is because of the "suest" command, as the error explains.
    Basically, for suest to work, it needs models with well defined score functions. Usually, those score functions are the residuals of a regression, but not always.
    Now, reghdfe , produces residuals, only if requested, but they are not identified as scores. Because of this Suest cannot run, and your bootstrap command fails
    Now,
    Since you are trying to use bootstrap, you do not need suest NOR lincom.
    you could instead just use something like this:

    Code:
    capture program drop bootem
    program define bootem, rclass
    reghdfe logIC_w treatment_post logSALE_w lagCash_ta_w lagSIZE_w lagDebt_ta_w roa_w Q_w if constraint==1,absorb (fyear#cohort gvkey#cohort)
    scalar a1=_b[treatment_post]
    reghdfe logIC_w treatment_post logSALE_w lagCash_ta_w lagSIZE_w lagDebt_ta_w roa_w Q_w if constraint==0,absorb (fyear#cohort gvkey#cohort)
    scalar a2=_b[treatment_post]
    
      return scalar diff12 = scalar(a1)-scalar(a2)
    end
    That should work.
    HTH

    Comment


    • #3
      Dear Fernando,
      It worked like charm; thanks!
      Annelies

      Comment

      Working...
      X