Announcement

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

  • Saving margin estimates in bootstrap program

    Hello,

    I am attempting to write a bootstrap program that will save the marginal estimates of a multinomial logisitic regression. I would ultimately like my program to create a dataset that contains just the margin estimates obtained from each iteration of my bootstrap program. My current program will save the coefficient estimates for each iteration, but not the margin estimates. Any suggestions on how to achieve that would be helpful.

    I am using a complex survey dataset, the Medical Expenditure Panel Survey, in stata 13.1. My outcome is a four-level categorical variable and my exposure variables are year and income level. The (simplified) code I have written is below:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    program savemargins, rclass
    svyset varpsu [pweight=perwt], strata(varstr) psu(varpsu)
    svy, subpop(subpop): mlogit outcome i.income##c.year
    margins, at [specified levels] predict(outcome(1))
    matrix list r(b)
    end

    bootstrap, saving(margins) reps(200): savemargins

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Thank you for your help.

    Best,
    Doug

  • #2
    It doesn't save the margin estimates because you never tell it to.

    Code:
    program savemargins, rclass 
    svyset varpsu [pweight=perwt], strata(varstr) psu(varpsu)
    svy, subpop(subpop): mlogit outcome i.income##c.year
    margins, at [specified levels] predict(outcome(1))
    matrix list r(b)
    tempname M
    matrix `M' = r(b)
    local M_cols = colsof(`M')
    forvalues j = 1/`M_cols' {
        return scalar margin_`j' = `M'[1, `j']
    }
    end
    
    bootstrap m1 = r(margin_1) m2 = r(margin_2) m3 = r(margin_3) /* etc.--you need to enumerate them one by one */,
         saving(margins) reps(200): savemargins
    

    Untested, but I think it will work as is. If not, it should give you a start.

    Comment


    • #3
      I think you need to post the results of the margins command:

      Here's an example, possibly non-sensical:

      Code:
      set more off
      use http://www.stata-press.com/data/r14/nhanes2f, clear
      svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid)
      
      capture program drop savemargins
      program savemargins, rclass
      svy, subpop(race): mlogit health i.agegrp##c.zinc
      margins, at(zinc=(0 10)) predict(outcome(1)) post
      end
      
      bootstrap _b, saving(margins, replace) reps(200): savemargins

      Comment


      • #4
        Dimitry's solution is simpler than mine, but it has one drawback that may preclude using it. After the -margins, ...post- command, the original coefficients from the -mlogit- command are no longer available. If in the real problem -margins- comes at the end of the program, that is not a problem. But if the real program needs to do other things after -margins-, and if those things require the -mlogit- coefficients, then this approach won't work as written.

        Comment


        • #5
          Thanks so much for your help, Clyde and Dimitriy. I ended up using Clyde's code and it worked just as I hoped it would. Thanks!

          Comment


          • #6
            After the -margins, ...post- command, the original coefficients from the -mlogit- command are no longer available.
            I have not much experience with bootstrap, but If this is a problem, it can probably be solved. Try

            Code:
            ...
            tempname myb
            _estimates hold `myb' , copy
            margins ... , post
            ...
            _estimates unhold `myb'
            ...
            For more, see

            Code:
            help _estimates
            Best
            Daniel

            Comment


            • #7
              Hi,
              Assuming that the health variable in the below solution has missing values, I was wondering to know how can include mi estimate to the below solution to derive the bootstrap margins from the imputed model.
              Thanks,
              NM

              Originally posted by Dimitriy V. Masterov View Post
              I think you need to post the results of the margins command:

              Here's an example, possibly non-sensical:

              Code:
              set more off
              use http://www.stata-press.com/data/r14/nhanes2f, clear
              svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid)
              
              capture program drop savemargins
              program savemargins, rclass
              svy, subpop(race): mlogit health i.agegrp##c.zinc
              margins, at(zinc=(0 10)) predict(outcome(1)) post
              end
              
              bootstrap _b, saving(margins, replace) reps(200): savemargins

              Comment


              • #8
                Hi everyone,
                I have a problem similar to post #1. I was wondering if either Clyde's or Dimitry's solutions are applicable to the panel data (long data format). As described here, the randomly selected observations for the bootstrap cannot be chosen by the individual record but must be chosen by the panel. It looks like that neither
                solutions consider this. I appreciate any feedback.
                Thanks SS
                Originally posted by Clyde Schechter View Post
                Dimitry's solution is simpler than mine, but it has one drawback that may preclude using it. After the -margins, ...post- command, the original coefficients from the -mlogit- command are no longer available. If in the real problem -margins- comes at the end of the program, that is not a problem. But if the real program needs to do other things after -margins-, and if those things require the -mlogit- coefficients, then this approach won't work as written.
                Originally posted by [B
                Dimitriy V. Masterov[/B]]I think you need to post the results of the margins command:

                Here's an example, possibly non-sensical:

                Code:
                set more off use http://www.stata-press.com/data/r14/nhanes2f, clear svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid) capture program drop savemargins program savemargins, rclass svy, subpop(race): mlogit health i.agegrp##c.zinc margins, at(zinc=(0 10)) predict(outcome(1)) post end bootstrap _b, saving(margins, replace) reps(200): savemargins

                Comment


                • #9
                  The -bootstrap- command has a -cluster()- option that allows you to force resampling of panels rather than individual observations. N.B. when you do this, you must also specify the -idcluster()- option. Do read -help bootstrap-, and then follow the link to the PDF manual entry for more information as well.

                  Please note that it is the norm in this community to use our real given and surnames as our username, to promote collegiality and professionalism. The Forum editor does not permit you to change your user name, however, you can click on Contact Us in the lower right corner of this webpage and message the system administrator to request the change be made. Thank you.

                  Comment


                  • #10
                    Thanks Clyde very much for your helpful comment. Given that xtmlogit is not supported by svy prefix, I wonder to know how can xtset can be applied to define idcluster?

                    Sure! I will.
                    Best,
                    SS

                    Comment


                    • #11
                      Thank you Clyde Schechter, Dimitriy V. Masterov for this helpful discussion.

                      With complex survey data, shouldn't we use bootstrap weights when performing bootstrap?

                      That can be done easily by using 'bsweights' by skolenik in combination with 'svy boostrap'.

                      Easy in principle, however.

                      Following Dimitry's codes in #3, for simplicity, when I try estimating the following:

                      Code:
                      set more off
                      use http://www.stata-press.com/data/r14/nhanes2f, clear
                      svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid)
                      bsweights bw, reps(200) n(-1) dots replace seed(0123456789) /*to create bootstrap weights*/
                      svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid) bsrweight(bw*) /*to include bootstrap weights in svyset*/
                      
                      capture program drop savemargins
                      program savemargins, rclass
                          svy, subpop(race): mlogit health i.agegrp##c.zinc, baseoutcome(1)
                          *mlogit health i.agegrp##c.zinc [pw=finalwgt], baseoutcome(1) /*this produces the same point estimates of the command above*/
                          margins, at(zinc=(0 10)) predict(outcome(1)) post
                      end
                      
                      svy bootstrap _b: savemargins now
                      I get the following table including the observed coefficient but not the standard errors:

                      Code:
                      ------------------------------------------------------------------------------
                                   |   Observed   Bootstrap                         Normal-based
                                   | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                      -------------+----------------------------------------------------------------
                               _at |
                                1  |   .1371592          .        .       .            .           .
                                2  |   .1233056          .        .       .            .           .
                      ------------------------------------------------------------------------------
                      Can anyone figure out why?
                      Last edited by Lukas Lang; 15 Jun 2022, 16:36.
                      ------
                      I use Stata 17

                      Comment


                      • #12
                        I think you need to specify the number of replications you want with your bootstrap which probably is 200 iterations. Also, I think svy prefix for the bootstrap command is redundant as your code already accounts for complex survey design within the program:


                        Code:
                        set more off
                        use http://www.stata-press.com/data/r14/nhanes2f, clear
                        svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid)
                        bsweights bw, reps(200) n(-1) dots replace seed(0123456789) /*to create bootstrap weights*/
                        svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid) bsrweight(bw*) /*to include bootstrap weights in svyset*/
                        
                        capture program drop savemargins
                        program savemargins, rclass
                            svy, subpop(race): mlogit health i.agegrp##c.zinc, baseoutcome(1)
                            *mlogit health i.agegrp##c.zinc [pw=finalwgt], baseoutcome(1) /*this produces the same point estimates of the command above*/
                            margins, at(zinc=(0 10)) predict(outcome(1)) post
                        end
                        
                         bootstrap _b, reps(200): savemargins now
                        Code:
                        Bootstrap replications (200)
                        ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
                        ..................................................    50
                        ..................................................   100
                        ..................................................   150
                        ..................................................   200
                        
                        Predictive margins                              Number of obs     =      9,188
                                                                        Replications      =        200
                        
                        ------------------------------------------------------------------------------
                                     |   Observed   Bootstrap                         Normal-based
                                     |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                        -------------+----------------------------------------------------------------
                                 _at |
                                  1  |   .1371592   .0446705     3.07   0.002     .0496067    .2247117
                                  2  |   .1233056   .0362283     3.40   0.001     .0522995    .1943117
                        ------------------------------------------------------------------------------

                        Comment


                        • #13
                          Thanks Nader Mehri, I had a go with your suggestion and, to test it, I have simplified the codes as follows:

                          Code:
                          set more off
                          use http://www.stata-press.com/data/r14/nhanes2f, clear
                          set seed 0123456789
                          svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid)
                          bsweights bw, reps(200) n(-1) dots replace /*to create bootstrap weights*/
                          svyset psuid [pweight=finalwgt], strata(stratid) psu(psuid) bsrweight(bw*) /*to include bootstrap weights in svyset*/
                          
                          capture program drop savemargins
                          program savemargins, rclass
                              qui mlogit health i.agegrp##c.zinc [pw=finalwgt], baseoutcome(1) /*this produces the same point estimates of the command above*/
                          end
                          
                           bootstrap _b, reps(200): savemargins now
                           svy bootstrap _b: mlogit health i.agegrp##c.zinc, baseoutcome(1)
                           svy bootstrap _b: savemargins now
                          As you can see below, standard errors from 'bootstrap' and 'svy bootstrap' differ:

                          Code:
                          bootstrap _b, reps(200): savemargins now
                          (running savemargins on estimation sample)
                          
                          Bootstrap replications (200)
                          ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
                          ..................................................    50
                          ..................................................   100
                          ..................................................   150
                          ..................................................   200
                          
                          Multinomial logistic regression                        Number of obs =   9,188
                                                                                 Replications  =     200
                                                                                 Wald chi2(44) = 1227.31
                                                                                 Prob > chi2   =  0.0000
                          Log pseudolikelihood = -1.459e+08                      Pseudo R2     =  0.0443
                          
                          -------------------------------------------------------------------------------
                                        |   Observed   Bootstrap                         Normal-based
                                 health | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                          --------------+----------------------------------------------------------------
                          poor          |  (base outcome)
                          --------------+----------------------------------------------------------------
                          fair          |
                                 agegrp |
                              age30-39  |   .6307591   2.372338     0.27   0.790    -4.018937    5.280455
                              age40-49  |   .1858713    2.25382     0.08   0.934    -4.231535    4.603277
                              age50-59  |  -2.285295   1.890361    -1.21   0.227    -5.990334    1.419743
                              age60-69  |  -1.267306   1.790183    -0.71   0.479       -4.776    2.241388
                               age 70+  |   .0880936   1.984159     0.04   0.965    -3.800786    3.976973
                                        |
                                   zinc |   .0030401   .0196409     0.15   0.877    -.0354553    .0415356
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0111744   .0269093    -0.42   0.678    -.0639157    .0415668
                              age40-49  |  -.0114104   .0262707    -0.43   0.664    -.0629001    .0400793
                              age50-59  |   .0162348   .0221602     0.73   0.464    -.0271985    .0596681
                              age60-69  |     .00372   .0206204     0.18   0.857    -.0366953    .0441353
                               age 70+  |  -.0123845   .0233368    -0.53   0.596    -.0581238    .0333548
                                        |
                                  _cons |   1.467004   1.699347     0.86   0.388    -1.863655    4.797664
                          --------------+----------------------------------------------------------------
                          average       |
                                 agegrp |
                              age30-39  |  -1.013213   2.274207    -0.45   0.656    -5.470577    3.444151
                              age40-49  |  -1.474417   2.135002    -0.69   0.490    -5.658944     2.71011
                              age50-59  |  -4.576451   1.882386    -2.43   0.015    -8.265859   -.8870427
                              age60-69  |  -2.953667    1.77805    -1.66   0.097    -6.438581    .5312479
                               age 70+  |  -2.122265   1.996448    -1.06   0.288    -6.035231    1.790702
                                        |
                                   zinc |  -.0021463   .0196212    -0.11   0.913    -.0406033    .0363106
                                        |
                          agegrp#c.zinc |
                              age30-39  |   .0070231   .0260274     0.27   0.787    -.0439896    .0580359
                              age40-49  |   .0014442   .0247989     0.06   0.954    -.0471607    .0500491
                              age50-59  |   .0351228   .0222357     1.58   0.114    -.0084584    .0787039
                              age60-69  |   .0103388    .020513     0.50   0.614     -.029866    .0505436
                               age 70+  |  -.0032432   .0236537    -0.14   0.891    -.0496036    .0431173
                                        |
                                  _cons |   3.336288   1.688949     1.98   0.048     .0260092    6.646566
                          --------------+----------------------------------------------------------------
                          good          |
                                 agegrp |
                              age30-39  |  -.4318196   2.222318    -0.19   0.846    -4.787484    3.923844
                              age40-49  |  -2.015888   2.220332    -0.91   0.364    -6.367658    2.335883
                              age50-59  |  -5.141381   1.852362    -2.78   0.006    -8.771944   -1.510817
                              age60-69  |  -3.859092   1.746961    -2.21   0.027    -7.283072   -.4351122
                               age 70+  |  -2.179386   1.888796    -1.15   0.249    -5.881358    1.522586
                                        |
                                   zinc |   .0069424   .0196188     0.35   0.723    -.0315097    .0453945
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0020289    .025517    -0.08   0.937    -.0520412    .0479834
                              age40-49  |   .0013358   .0256616     0.05   0.958    -.0489601    .0516317
                              age50-59  |   .0319356   .0217965     1.47   0.143    -.0107848     .074656
                              age60-69  |   .0116608   .0201097     0.58   0.562    -.0277536    .0510751
                               age 70+  |    -.01292   .0224938    -0.57   0.566     -.057007     .031167
                                        |
                                  _cons |   2.965805   1.691762     1.75   0.080    -.3499865    6.281597
                          --------------+----------------------------------------------------------------
                          excellent     |
                                 agegrp |
                              age30-39  |  -.4955834   2.281333    -0.22   0.828    -4.966914    3.975747
                              age40-49  |  -1.965187   2.196011    -0.89   0.371     -6.26929    2.338916
                              age50-59  |  -4.839694   1.972694    -2.45   0.014    -8.706103   -.9732851
                              age60-69  |  -3.345652   1.767189    -1.89   0.058    -6.809279    .1179746
                               age 70+  |  -3.280243   2.097342    -1.56   0.118    -7.390959    .8304716
                                        |
                                   zinc |   .0106708   .0198553     0.54   0.591    -.0282448    .0495864
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0013921   .0260711    -0.05   0.957    -.0524906    .0497064
                              age40-49  |   .0018209   .0255722     0.07   0.943    -.0482997    .0519415
                              age50-59  |   .0257879   .0232652     1.11   0.268     -.019811    .0713867
                              age60-69  |  -.0013309   .0204226    -0.07   0.948    -.0413584    .0386966
                               age 70+  |  -.0020064   .0247615    -0.08   0.935    -.0505382    .0465253
                                        |
                                  _cons |   2.694864    1.70975     1.58   0.115    -.6561842    6.045912
                          -------------------------------------------------------------------------------
                          
                           
                          svy bootstrap _b: mlogit health i.agegrp##c.zinc, baseoutcome(1)
                          (running mlogit on estimation sample)
                          
                          Bootstrap replications (200)
                          ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
                          ..................................................    50
                          ..................................................   100
                          ..................................................   150
                          ..................................................   200
                          
                          Survey: Multinomial logistic regression          Number of obs   =       9,188
                                                                           Population size = 104,162,204
                                                                           Replications    =         200
                                                                           Wald chi2(44)   =    24481.19
                                                                           Prob > chi2     =      0.0000
                          
                          -------------------------------------------------------------------------------
                                        |   Observed   Bootstrap                         Normal-based
                                 health | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                          --------------+----------------------------------------------------------------
                          poor          |  (base outcome)
                          --------------+----------------------------------------------------------------
                          fair          |
                                 agegrp |
                              age30-39  |   .6307591   2.784013     0.23   0.821    -4.825807    6.087325
                              age40-49  |   .1858713    2.58411     0.07   0.943    -4.878892    5.250634
                              age50-59  |  -2.285295   2.543675    -0.90   0.369    -7.270807    2.700217
                              age60-69  |  -1.267306   2.125213    -0.60   0.551    -5.432647    2.898035
                               age 70+  |   .0880936   2.255595     0.04   0.969    -4.332792    4.508979
                                        |
                                   zinc |   .0030401   .0241923     0.13   0.900    -.0443758    .0504561
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0111744    .030755    -0.36   0.716    -.0714531    .0491042
                              age40-49  |  -.0114104   .0284998    -0.40   0.689    -.0672689    .0444481
                              age50-59  |   .0162348   .0291624     0.56   0.578    -.0409224    .0733919
                              age60-69  |     .00372   .0236476     0.16   0.875    -.0426284    .0500684
                               age 70+  |  -.0123845    .025922    -0.48   0.633    -.0631907    .0384218
                                        |
                                  _cons |   1.467004   2.154797     0.68   0.496    -2.756321    5.690329
                          --------------+----------------------------------------------------------------
                          average       |
                                 agegrp |
                              age30-39  |  -1.013213   3.008141    -0.34   0.736    -6.909061    4.882635
                              age40-49  |  -1.474417   2.662485    -0.55   0.580    -6.692792    3.743957
                              age50-59  |  -4.576451   2.427487    -1.89   0.059    -9.334237    .1813353
                              age60-69  |  -2.953667   2.391359    -1.24   0.217    -7.640645    1.733312
                               age 70+  |  -2.122265   2.516095    -0.84   0.399    -7.053721    2.809192
                                        |
                                   zinc |  -.0021463   .0259741    -0.08   0.934    -.0530547     .048762
                                        |
                          agegrp#c.zinc |
                              age30-39  |   .0070231   .0336488     0.21   0.835    -.0589273    .0729736
                              age40-49  |   .0014442   .0297591     0.05   0.961    -.0568826    .0597711
                              age50-59  |   .0351228    .027244     1.29   0.197    -.0182744      .08852
                              age60-69  |   .0103388   .0270509     0.38   0.702    -.0426799    .0633575
                               age 70+  |  -.0032432   .0291694    -0.11   0.911    -.0604142    .0539279
                                        |
                                  _cons |   3.336288   2.289978     1.46   0.145    -1.151986    7.824562
                          --------------+----------------------------------------------------------------
                          good          |
                                 agegrp |
                              age30-39  |  -.4318196   2.692593    -0.16   0.873    -5.709205    4.845565
                              age40-49  |  -2.015888   2.599128    -0.78   0.438    -7.110086     3.07831
                              age50-59  |  -5.141381   2.537319    -2.03   0.043    -10.11443   -.1683265
                              age60-69  |  -3.859092   2.168088    -1.78   0.075    -8.108467    .3902834
                               age 70+  |  -2.179386   2.548777    -0.86   0.393    -7.174897    2.816125
                                        |
                                   zinc |   .0069424   .0248134     0.28   0.780    -.0416909    .0555757
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0020289   .0305298    -0.07   0.947    -.0618662    .0578084
                              age40-49  |   .0013358    .028949     0.05   0.963    -.0554031    .0580747
                              age50-59  |   .0319356   .0288228     1.11   0.268    -.0245561    .0884273
                              age60-69  |   .0116608   .0246166     0.47   0.636    -.0365869    .0599084
                               age 70+  |    -.01292   .0291148    -0.44   0.657     -.069984     .044144
                                        |
                                  _cons |   2.965805   2.177808     1.36   0.173    -1.302619     7.23423
                          --------------+----------------------------------------------------------------
                          excellent     |
                                 agegrp |
                              age30-39  |  -.4955834   2.828905    -0.18   0.861    -6.040135    5.048968
                              age40-49  |  -1.965187   2.680753    -0.73   0.464    -7.219366    3.288992
                              age50-59  |  -4.839694   2.432614    -1.99   0.047    -9.607529    -.071859
                              age60-69  |  -3.345652    2.29151    -1.46   0.144     -7.83693    1.145625
                               age 70+  |  -3.280243   2.783724    -1.18   0.239    -8.736242    2.175755
                                        |
                                   zinc |   .0106708   .0250371     0.43   0.670     -.038401    .0597426
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0013921   .0317513    -0.04   0.965    -.0636235    .0608394
                              age40-49  |   .0018209   .0296879     0.06   0.951    -.0563663    .0600081
                              age50-59  |   .0257879    .027434     0.94   0.347    -.0279818    .0795575
                              age60-69  |  -.0013309   .0255839    -0.05   0.959    -.0514744    .0488125
                               age 70+  |  -.0020064   .0320969    -0.06   0.950    -.0649152    .0609024
                                        |
                                  _cons |   2.694864   2.207606     1.22   0.222    -1.631964    7.021692
                          -------------------------------------------------------------------------------
                          
                          svy bootstrap _b: savemargins now
                          (running savemargins on estimation sample)
                          
                          Bootstrap replications (200)
                          ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
                          ..................................................    50
                          ..................................................   100
                          ..................................................   150
                          ..................................................   200
                          
                          Multinomial logistic regression                  Number of obs   =      10,337
                                                                           Population size = 117,023,659
                                                                           Replications    =         200
                                                                           Wald chi2(0)    =           .
                                                                           Prob > chi2     =           .
                          
                          -------------------------------------------------------------------------------
                                        |   Observed   Bootstrap                         Normal-based
                                 health | coefficient  std. err.      z    P>|z|     [95% conf. interval]
                          --------------+----------------------------------------------------------------
                          poor          |  (base outcome)
                          --------------+----------------------------------------------------------------
                          fair          |
                                 agegrp |
                              age30-39  |   .6307591          .        .       .            .           .
                              age40-49  |   .1858713          .        .       .            .           .
                              age50-59  |  -2.285295          .        .       .            .           .
                              age60-69  |  -1.267306          .        .       .            .           .
                               age 70+  |   .0880936          .        .       .            .           .
                                        |
                                   zinc |   .0030401          .        .       .            .           .
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0111744          .        .       .            .           .
                              age40-49  |  -.0114104          .        .       .            .           .
                              age50-59  |   .0162348          .        .       .            .           .
                              age60-69  |     .00372          .        .       .            .           .
                               age 70+  |  -.0123845          .        .       .            .           .
                                        |
                                  _cons |   1.467004          .        .       .            .           .
                          --------------+----------------------------------------------------------------
                          average       |
                                 agegrp |
                              age30-39  |  -1.013213          .        .       .            .           .
                              age40-49  |  -1.474417          .        .       .            .           .
                              age50-59  |  -4.576451          .        .       .            .           .
                              age60-69  |  -2.953667          .        .       .            .           .
                               age 70+  |  -2.122265          .        .       .            .           .
                                        |
                                   zinc |  -.0021463          .        .       .            .           .
                                        |
                          agegrp#c.zinc |
                              age30-39  |   .0070231          .        .       .            .           .
                              age40-49  |   .0014442          .        .       .            .           .
                              age50-59  |   .0351228          .        .       .            .           .
                              age60-69  |   .0103388          .        .       .            .           .
                               age 70+  |  -.0032432          .        .       .            .           .
                                        |
                                  _cons |   3.336288          .        .       .            .           .
                          --------------+----------------------------------------------------------------
                          good          |
                                 agegrp |
                              age30-39  |  -.4318196          .        .       .            .           .
                              age40-49  |  -2.015888          .        .       .            .           .
                              age50-59  |  -5.141381          .        .       .            .           .
                              age60-69  |  -3.859092          .        .       .            .           .
                               age 70+  |  -2.179386          .        .       .            .           .
                                        |
                                   zinc |   .0069424          .        .       .            .           .
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0020289          .        .       .            .           .
                              age40-49  |   .0013358          .        .       .            .           .
                              age50-59  |   .0319356          .        .       .            .           .
                              age60-69  |   .0116608          .        .       .            .           .
                               age 70+  |    -.01292          .        .       .            .           .
                                        |
                                  _cons |   2.965805          .        .       .            .           .
                          --------------+----------------------------------------------------------------
                          excellent     |
                                 agegrp |
                              age30-39  |  -.4955834          .        .       .            .           .
                              age40-49  |  -1.965187          .        .       .            .           .
                              age50-59  |  -4.839694          .        .       .            .           .
                              age60-69  |  -3.345652          .        .       .            .           .
                               age 70+  |  -3.280243          .        .       .            .           .
                                        |
                                   zinc |   .0106708          .        .       .            .           .
                                        |
                          agegrp#c.zinc |
                              age30-39  |  -.0013921          .        .       .            .           .
                              age40-49  |   .0018209          .        .       .            .           .
                              age50-59  |   .0257879          .        .       .            .           .
                              age60-69  |  -.0013309          .        .       .            .           .
                               age 70+  |  -.0020064          .        .       .            .           .
                                        |
                                  _cons |   2.694864          .        .       .            .           .
                          -------------------------------------------------------------------------------
                          So I still have some doubts that the 'bootstrap' command takes account of the svyset instructions, at least in the same way 'svy bootstrap' does.

                          Also, the key issue of no standard errors when running 'svy bootstrap' using a program is still there unfortunately.

                          Why is that the case?
                          Last edited by Lukas Lang; 16 Jun 2022, 04:20.
                          ------
                          I use Stata 17

                          Comment


                          • #14
                            Hi I have found a workaround to this issue which you can find here: https://www.statalist.org/forums/for...-wrong-with-it
                            ------
                            I use Stata 17

                            Comment

                            Working...
                            X