Announcement

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

  • Bootstrap error for test of difference of estimated coefficient across two groups

    Dear Stata users:

    I hope you are all doing well.

    I am trying to test if the estimated coefficient of treated is significantly different across group 1 and group 2. The suest command cannot be used in this setting.

    Group 1 has 9000 observations. Group 2 has 9000 observations.

    I receive an error at the end of the procedure explained at the bottom of this message. How could you resolve this issue? Many thanks for your help!

    error message:

    "Bootstrap replications (50): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx done
    x: Error occurred when bootstrap executed boot_sdid_diff.
    insufficient observations to compute bootstrap standard errors
    no results will be saved


    Procedure:

    capture program drop boot_sdid_diff
    program define boot_sdid_diff, rclass

    * Preserve the full dataset
    preserve

    * Estimate SDID for Sample 1
    keep if sample == 0
    sdid interestrate counties year treated, vce(bootstrap) reps(100) seed(1213) covariates(countygdp)

    matrix b1 = e(b)

    * Restore the full dataset
    restore
    preserve

    * Estimate SDID for Sample 2
    keep if sample == 1
    sdid interestrate counties year treated, vce(bootstrap) reps(100) seed(1213) covariates(countygdp)

    matrix b2 = e(b)

    * Calculate the difference in coefficients
    scalar diff = b1[1,1] - b2[1,1]
    return scalar diff = diff

    * Restore the original dataset for the next bootstrap iteration
    restore
    end

    bootstrap diff = r(diff), reps(50): boot_sdid_diff

  • #2
    Try:

    Code:
    capture program drop boot_sdid_diff
    program define boot_sdid_diff, rclass
    
    * Preserve the full dataset
    preserve
    
    * Estimate SDID for Sample 1
    keep if sample == 0
    sdid interestrate counties year treated, vce(noinference) covariates(countygdp)
    
    matrix b1 = e(b)
    
    * Restore the full dataset
    restore
    preserve
    
    * Estimate SDID for Sample 2
    keep if sample == 1
    sdid interestrate counties year treated, vce(noinference) covariates(countygdp)
    
    matrix b2 = e(b)
    
    * Calculate the difference in coefficients
    scalar diff = b1[1,1] - b2[1,1]
    return scalar diff = diff
    
    * Restore the original dataset for the next bootstrap iteration
    restore
    end
    
    bootstrap diff = r(diff), reps(50) nodrop: boot_sdid_diff
    Best wishes

    (Stata 16.1 MP)

    Comment


    • #3
      Thank you for your quick response. it is not working.

      Comment


      • #4
        Does it work when you run the program without bootstrap, like:

        Code:
        boot_sdid_diff
        return list
        Is the result you get sensible? If no, there is probably a bug in your program. As I dont have the data (nor do I know sdid), I cannot reproduce it here.
        Last edited by Felix Bittmann; 06 Nov 2024, 14:50.
        Best wishes

        (Stata 16.1 MP)

        Comment

        Working...
        X