Announcement

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

  • Bootstrap stuck.

    Hello everyone,

    Is there any way to foster the process of bootstrapping. I am replicating only 1000 times but it is stuck after 5 replications for a long time. I can see Stata working but with no progress. Please see the codes below. The dots are where the estimation seems stuck for a long time (last one and half hour). The 'gsem' model and the 'nlcom' runs perfectly without bootstrapping.

    Code:
     capture program drop boots
         program boots, rclass
             gsem (L -> wk*@1,  link(logit) fam(bin)) ///
                   (z1 <- z0 treat, link(ident) fam(gaus)) ///
                   (L <- hotash itihash z1 treat, link(logit) fam(bin)), diff
           return scalar product = _b[z1:treat]*_b[L:z1]
         end
     bootstrap r(product), reps(1000) seed(329250) : boots
    
    (running boots on estimation sample)
    
    Bootstrap replications (1000)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    ....
    Any suggestion is highly appreciated.
    Roman

  • #2
    It looks as if, with the fifth draw, gsem's iterations aren't converging. So, put a limit on the number of iterations allowed using the iterate(#) option, add a test of whether convergence was achieved by looking at the value of the e(converged) e-return scalar, and then set the returned scalar from you boots wrapper command to missing if convergence was not attained.

    bootstrap will then place a red upper-case X in the place of the dot and will give you a warning at the end. You might want to take that warning to heart if there are more than just a couple of nonconvergent replications.

    Comment


    • #3
      Dear Joseph,

      Thanks for the helpful reply. Did you mean I need to limit iteration less than<5! That will certainly not converge my model. Or I might be completely misunderstanding your suggestion. Could you please see my codes below to confirm if that is what you meant. I limited the iteration to 24; the current converging threshold for my model.


      Code:
      capture program drop boots
           program boots, rclass
               gsem (L -> wk*@1,  link(logit) fam(bin)) ///
                     (z1 <- z0 treat, link(ident) fam(gaus)) ///
                     (L <- hotash itihash z1 treat, link(logit) fam(bin)), diff iterate(24)
            
            loc converge = e(converged)
            if `converge' == 1 {
                return scalar product = _b[z1:treat]*_b[L:z1]
              }
              else {
                return scalar product =.
             } 
      end
       
      bootstrap r(product), reps(1000) seed(129280) : boots
      Many thanks again.
      Roman

      Comment


      • #4
        Originally posted by Roman Mostazir View Post
        Dear Joseph,

        Thanks for the helpful reply. Did you mean I need to limit iteration less than<5! That will certainly not converge my model. Or I might be completely misunderstanding your suggestion. Could you please see my codes below to confirm if that is what you meant. I limited the iteration to 24; the current converging threshold for my model.


        Code:
        capture program drop boots
        program boots, rclass
        gsem (L -> wk*@1, link(logit) fam(bin)) ///
        (z1 <- z0 treat, link(ident) fam(gaus)) ///
        (L <- hotash itihash z1 treat, link(logit) fam(bin)), diff iterate(24)
        
        loc converge = e(converged)
        if `converge' == 1 {
        return scalar product = _b[z1:treat]*_b[L:z1]
        }
        else {
        return scalar product =.
        }
        end
        
        bootstrap r(product), reps(1000) seed(129280) : boots
        Many thanks again.
        To help clarify, Joseph meant that the 5th bootstrap sample looks to have not converged. The model clearly was identified in your original sample, but that 5th bootstrap sample may have had some problem. The bootstrapping could have introduced collinearities between the items that made it not identified. When a model isn't identified, you typically see Stata iterate again and again, and the log likelihood doesn't change, plus there is a "not concave" message on each iteration.

        If this happened, the default maximum number of iterations is 16,000. I've had this happen to me, and it takes a long time for a model to get to 16,000 iterations. In my experience, a model like yours, which is not very complex, shouldn't need a lot of iterations to converge. It sounds like your original model took 24 iterations to converge. I would maybe set your maximum number to 100 iterations for this purpose.
        Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

        When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

        Comment


        • #5
          That's very helpful. Thanks Weiwen.
          Roman

          Comment


          • #6
            Originally posted by Weiwen Ng View Post
            In my experience, a model like yours, which is not very complex, shouldn't need a lot of iterations to converge. It sounds like your original model took 24 iterations to converge. I would maybe set your maximum number to 100 iterations for this purpose.
            Weiwen's rule of thumb sounds the same as mine here.

            Comment


            • #7
              Thanks Joseph. It was very helpful.
              Roman

              Comment

              Working...
              X