Announcement

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

  • dbs: Stata command for computing double bootstrap confidence intervals

    Dear all,
    I am happy to announce a new Stata command, dbs, which allows the computation of double bootstrap confidence intervals. The command is easy to use, very similar to bootstrap, lightweight and supports multiple threads. For more information please refer to the documentation file (help dbs) or the Github page.

    Installation
    Code:
    net install dbs, from(https://raw.github.com/fbittmann/dbs/stable) replace
    Minimal example
    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . dbs r(mean) r(p50): summarize mpg, detail
    Warning:  Because the command invoked does not set e(sample),
              dbs has no way to determine which observations are
              used incalculating the statistics and so assumes
              that all observations are used. Check for missing
              values with care.
    
    Bootstrap replications (100 / 20)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    ..........
    
    Bootstrap results                                           Number of obs = 74
                                                                        Reps1 = 100
                                                                        Reps2 = 20
    command:  summarize mpg, detail
        _bs_1: r(mean)
        _bs_2: r(p50)
    
    ---------------------------------------------------------------------------------
              | Observed Coef.   Boot. Std. Err.   Bias   SFrancia   [95% Conf. Interval]
    ----------+----------------------------------------------------------------------
       _bs_1  |  21.2973      0.6301      -0.075       0.963     20.1315     22.8198
       _bs_2  |  20.0000      0.9891       0.095       0.561     16.9322     22.4864
    ---------------------------------------------------------------------------------
    Since this is a new release bugs and errors might occur so please be careful. I am grateful for input and advice and would like to hear your opinions and suggestions. Next thing on my to-do list is to run simulations to assess in detail the pros and cons of double bootstraps in comparison to the regular ones.
    Last edited by Felix Bittmann; 20 Sep 2020, 11:18.
    Best wishes

    (Stata 16.1 MP)

  • #2
    Very good then, I already have a complaint :-).

    It does not run on older Statas

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . dbs _b[mpg], reps1(120) reps2(100) parallel(4): regress price mpg headroom
    this is version 15.1 of Stata; it cannot run version 16.1 programs
         You can purchase the latest version of Stata by visiting http://www.stata.com.
    r(9);

    Comment


    • #3
      Thank you, that's of course not a good thing! I am not sure which versions are able to dbs but most commands I used are quite basic. I set it to version 11 now and hope for the best for the moment until I can run further tests. However, 15.1 should absolutely be able to run dbs.
      Best wishes

      (Stata 16.1 MP)

      Comment


      • #4
        Hey there,
        I have two questions and would be grateful for some pointers.

        1. Atm dbs stores the internal result in matrices, since I believed this is a fast solution and faster than writing anything to a file, that is, to disk. However, I noticed that this restricts analyses since max. matrix size is about 65000 rows. While this is not a real practical problem since usually a much lower number of replications is fine, what are better options to use?
        2. The output display is not pretty and I did not manage to align the row names and the produced statistics... since the number format can also change, depending on the absolute size of a number (say 1.5 vs 1500.5), is there any trick to do this?

        Thanks a lot.
        Best wishes

        (Stata 16.1 MP)

        Comment


        • #5
          Felix, the matsize limitations are quite a bit below. In Intercooled Stata maximum matsize is 800. In Stata SE max matsize is 11000.
          Code:
          . help limits
          I think the civilised way to save simulation results is to post to file, here
          https://blog.stata.com/2015/10/06/mo...s-using-stata/

          I never do this, I either post to matrices like you say, or just expand the dataset and write in the original data the simulated statistics.

          Finally you might want to look at the code of -boottest- by David Roodman for ideas.

          Originally posted by Felix Bittmann View Post
          Hey there,
          I have two questions and would be grateful for some pointers.

          1. Atm dbs stores the internal result in matrices, since I believed this is a fast solution and faster than writing anything to a file, that is, to disk. However, I noticed that this restricts analyses since max. matrix size is about 65000 rows. While this is not a real practical problem since usually a much lower number of replications is fine, what are better options to use?
          2. The output display is not pretty and I did not manage to align the row names and the produced statistics... since the number format can also change, depending on the absolute size of a number (say 1.5 vs 1500.5), is there any trick to do this?

          Thanks a lot.

          Comment


          • #6
            Thank you Joro, that is indeed a critical aspect I forgot about. What I did was change the outer resample structure to postfile (for the inner this is less relevant since even 800 inner resamples is insane). To my big surprise, the code got even faster. Apparently, a lookup in a large matrix is slower in Stata than using the postfile-setup.
            Best wishes

            (Stata 16.1 MP)

            Comment

            Working...
            X