Announcement

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

  • Two Stage Poisson IV (Panel Data)

    Hi there,

    I am trying to run the following:

    1st stage: reghdfe x1 = z1 c1, absorb(category time) vce(robust)
    predict double v2hat1, r
    reghdfe x2 = z2 c1, absorb(category time) vce(robust)
    predict double v2hat2, r
    2nd stage: ppmldhfe y = x1 x2 v2hat1 v2hat2 c1, absorb(category time) vce(robust)

    I am not sure how to bootstrap the standard errors correctly (and whether this approach is correct). I am following an earlier post discussing ivpoisson which looks into this problem but I feel that there is no clear answer on the correct wat to bootstrap.

    My attempt is the following:

    * Define the process as a program to bootstrap
    program define mybootstrap, rclass
    * First regression with inmodel_intro
    reghdfe inmodel_intro inmodel_intro_p price, absorb(id_marca wdate) vce(robust)
    predict douncle v2hat1, r

    * Second regression with outmodel_intro
    reghdfe outmodel_intro outmodel_intro_p price, absorb(id_marca wdate) vce(robust)
    predict douncle v2hat12, r

    * Running the PPMLHDFE regression
    ppmlhdfe quantity inmodel_intro outmodel_intro v2hat1 v2hat2 price, absorb(id_marca wdate) vce(robust)

    * Store the coefficients in r() as scalars for bootstrap
    return scalar b_inmodel_intro = _b[inmodel_intro]
    return scalar b_outmodel_intro = _b[outmodel_intro]
    return scalar b_v2hat1 = _b[v2hat1]
    return scalar b_v2hat2 = _b[v2hat2]
    return scalar b_price = _b[price]
    end

    * Run the bootstrap, referencing the returned scalars
    bootstrap r(b_inmodel_intro) r(b_outmodel_intro) r(b_v2hat1) r(b_v2hat2) r(b_price), reps(500) seed(123): mybootstrap

    Thanks!


  • #2
    As I am working on the code. Here is an update that works but very slow.

    * Define the process as a program to bootstrap
    program define my_bootstrap, rclass

    * First regression with inmodel_intro
    xtreg inmodel_intro inmodel_intro_p price i.marca i.wdate, fe
    predict double v2hat1, r

    * Second regression with outmodel_intro
    xtreg outmodel_intro outmodel_intro_p price i.marca i.wdate, fe
    predict double v2hat2, r

    * Running the PPMLHDFE regression
    ppmlhdfe quantity inmodel_intro outmodel_intro v2hat1 v2hat2 price, absorb(id_marca wdate)
    return scalar b_inmodel_intro = _b[inmodel_intro]
    return scalar b_outmodel_intro = _b[outmodel_intro]
    return scalar b_v2hat1_1 = _b[v2hat1]
    return scalar b_v2hat1_2 = _b[v2hat2]
    return scalar b_price = _b[price]

    drop v2hat1 v2hat2

    end

    * Run the bootstrap, referencing the returned scalars
    bootstrap r(b_inmodel_intro) r(b_outmodel_intro) r(b_v2hat1_1) ///
    r(b_v2hat1_2) r(b_price), ///
    reps(100) seed(123) cluster(id_sku) :my_bootstrap

    Comment

    Working...
    X