Announcement

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

  • user written program to compute two step mole in Stata 12:problem of insufficient observations to compute bootstrap standard errors

    Dear Statalisters,

    I am using a sample of 845 migrants and I want to estimate a remittance model using both a Heckman selection model and a simple two-step model.

    My dependent variables are 1) remit (binary variable equal 1 if migrant i remit) and 2) amount remit ( recoded as intervals).

    The dependent variable remit is estimated using a probit model; while the variable amount_remit is estimated, conditional on the decision to remit, using interval regression (I have created two variables, amount_remit_L and amount_remit_U, containing the lower and upper endpoints of the amount_remit categories). The migrants sending remittances are 585.

    Given that I need to estimate the model in one step (to get the correct standard errors) I did it in the following way:
    (x4 and x11 are my exclusion restrictions)

    capture program drop myprog
    program myprog, eclass
    xi: prob remit x1 x2 x3 i.x4 x5 x6 x7 i.x8 x9 x10 x11 x12
    predict double xb1,xb
    gen double imr1=normalden(xb1)/normal(xb1)
    xi:intreg amount_remit_L and amount_remit_U x1 x2 x3 x5 x6 x7 i.x8 x9 x10 x12 imr1 if remit==1
    end
    bootstrap, reps(50) seed(2364723): myprog

    Bootstrap replications (50)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
    insufficient observations to compute bootstrap standard errors
    no results will be saved

    Can you please help me to understand what I am doing wrong? does it depend on the sample size?
    How can I estimate my model in one step to get the correct standard errors?


  • #2
    Welcome to Statalist, Teresa!. Stata runs the program once before starting the bootstrap replicates. At each replicate, the program will try to predict xb1 and xb2 and to gen imr1, only to find that those variables are already in the data set. Outside of the bootstrap, Stata would issue a "variable already defined", error. However, inside it stops and goes on to the next replicate. Convert these generated variables to temporary variables or drop them at the end of the program. I remember experiencing this problem when I wrote my first bootstrap program years ago. I think it was Maarten Buis who set me straight.

    A word of advice: be sure to read the FAQ, especially FAQ 12. Putting code and results between CODE delimiters, described by that FAQ, makes posts much easier to read.
    Last edited by Steve Samuels; 20 Nov 2015, 11:06.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      helloooo dear form members....i m in trouble ...need help..i am working on a panel data set of 30 banks for a quarterly data of 7 years...i am unable to define to stata that my data is panel quarterly i m using the commands but getting the error like this
      gen qdate = yq(year, quarter)

      . format qdate %tq

      . xtset bankid qdate
      repeated time values within panel
      r(451);

      Comment


      • #4
        For future reference, as your question is unrelated to this thread, you should have started a new thread for your post.

        That said, the message explains itself: there are some bankid's in your data set that have more than one observation with the same value of qdate. To see them, run -duplicates list bankid qdate-. You will not be able to -xtset bankid qdate- your data until you eliminate those duplicates, resolving any conflicts they may have for other variables.

        Comment


        • #5
          ism:
          welcome to the list.
          You shoud better start a new thread asking for advice, instead of tailing your message to another thread that focuses on a complete different topic.
          Besides, crying out for help does not put your query on a priority lane.
          That said, I would recommend you to take a look at [U] 24 Working with dates and times in Stata .pdf manual.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Dear Steve,

            many thanks for your help. My boostrap program works now (after converting the generated variables to temporary variables as you suggested). And, next time I will try to make my post easier to read. Kind Regards, Teresa

            Comment

            Working...
            X