Announcement

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

  • Bootstrapped confidence intervals

    Hello, I have to use bootstrapping to add 90% confidence intervals to a ratio. How could I do that?

  • #2
    Irene.
    welcome to this forum.
    Do you mean something along the following lines?
    Code:
    . use "C:\Program Files\Stata16\ado\base\a\auto.dta"
    (1978 Automobile Data)
    
    . g wanted=price/mpg
    
    . sum wanted
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
          wanted |         74    330.9413    237.2313   108.5143   1132.833
    
    . bootstrap r(mean), reps(200) size(74) saving(C:\Users\user\Desktop\carlaz.dta, every(1) double replace) bca level(90) : sum wanted
    
    warning: Because summarize is not an estimation command or does not set e(sample), bootstrap has no way to determine which
             observations are used in calculating the statistics and so assumes that all observations are used. This means that no
             observations will be excluded from the resampling because of missing values or other reasons.
    
             If the assumption is not true, press Break, save the data, and drop the observations that are to be excluded. Be sure
             that the dataset in memory contains only the relevant data.
    (running summarize on estimation sample)
    
    Jackknife replications (74)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    ..................................................    50
    ........................
    
    Bootstrap replications (200)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    ..................................................    50
    ..................................................   100
    ..................................................   150
    ..................................................   200
    
    Bootstrap results                               Number of obs     =         74
                                                    Replications      =        200
    
          command:  summarize wanted
            _bs_1:  r(mean)
    
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                         Normal-based
                 |      Coef.   Std. Err.      z    P>|z|     [90% Conf. Interval]
    -------------+----------------------------------------------------------------
           _bs_1 |   330.9413   27.20673    12.16   0.000     286.1902    375.6924
    ------------------------------------------------------------------------------
    
    . estat bootstrap
    
    Bootstrap results                               Number of obs     =         74
                                                    Replications      =        200
    
          command:  summarize wanted
            _bs_1:  r(mean)
    
    ------------------------------------------------------------------------------
                 |    Observed               Bootstrap
                 |       Coef.       Bias    Std. Err.  [90% Conf. Interval]
    -------------+----------------------------------------------------------------
           _bs_1 |   330.94131  -1.561189   27.206732    288.9933   381.9036  (BC)
    ------------------------------------------------------------------------------
    (BC)   bias-corrected confidence interval
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Yes! Thank you very much

      Comment

      Working...
      X