Announcement

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

  • Bootstrap error help

    Hi everyone,

    I'm getting errors when I run the following
    Code:
    set obs 10000
    set seed 14051969
    gen age = floor((65-18)*runiform() + 18)
    gen income = exp(0.005 * age + rnormal(10.31,0.60))/1000
    label var income "Income ($ Thousands)"
    gen dstar = 2 + 0.25 * income + rnormal(0,2)
    gen dy = income > 20
    gen donations = dy * dstar
    sum
    
    tobit donations income, ll
    
    ** Two-part probit and regress
    capture program drop boot_twostep
    program define boot_twostep, rclass
        probit dy age
        predict dylin, xb
        scalar gage = _b[age]
        regress donations income if donations > 0
        predict inclin, xb
        scalar binc = _b[inc]
        * age
        gen pe1 = normalden(dylin)*inclin*gage
        * income
        gen pe2 = normal(dylin)*binc
        sum pe1
        return scalar ape1 = r(mean)
        sum pe2
        return scalar ape2 = r(mean)
        drop dylin inclin pe1 pe2
    end
    bootstrap r(ape1) r(ape2): boot_twostep
    No bootstrap repetition is valid and I get the insufficient observations to compute bootstrap standard errors no results will be saved message. When I use the noisily option the estimation with data as is works perfectly but then I get the following in each repetition:
    Code:
    . boot_twostep
    
    outcome does not vary; remember:
                                      0 = negative outcome,
            all other nonmissing values = positive outcome
    an error occurred when bootstrap executed boot_twostep, posting missing values
    Is this because I generate my own data? Or do I have anything wrong in my code? Any help is really appreciated.
    Alfonso Sanchez-Penalver

  • #2
    bootstrap by default looks at which observations are used by the program and drops all observations that are at some point in the program excluded. So the fact that your program included the condition if donations > 0 meant that only the observations with donations were included in the bootstrap samples and the first probit could not be estimated. To prevent bootstrap from excluding the non-donors you can add the nodrop option in bootstrap. However, then you need to take care of missing values etc. yourself. This is not a big deal when you created the data yourself, but something to be aware of if you use real data.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Hi Maarten, thanks so much. That's tricky to pick up if you don't know that bootstrap does that by default. Following your comment about real data and how you would have to manage the missing values and other problems if you include the nodrop option, I tried using preserve and restore around the truncated regression and that worked well. Would that conflict with bootstrap in any way I don't foresee? Thanks again.
      Alfonso Sanchez-Penalver

      Comment

      Working...
      X