Announcement

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

  • how to multiply 100 times in bootstrapping

    Hello Statalist,

    I am currently working on 2 stage bootstrapping command. I already compute 100 y hat(which has 100 values in each y hat set) and resote 100 new column for those 100 of y hat set.
    What I want to do now is to run for the second stage 100 y hat for 100 times.
    I hope there is someone who could help me with this issue.

  • #2
    I'm not able to understand what you want to do, or what the problem is. I suspect that other people who could help are having the same experience. I have two suggestions for you:
    1) Post again showing the exact Stata code you are using. To help you, we need to know what commands you are using and in what context. Look at the FAQ and read about "code delimiters" about how to nicely do that in the StataList forum.
    2) Show your description to a colleague, and ask for some help in clarifying your description.

    Comment


    • #3
      I'm not able to understand what you want to do, or what the problem is. I suspect that other people who could help are having the same experience. I have two suggestions for you:
      1) Post again showing the exact Stata code you are using. To help you, we need to know what commands you are using and in what context. Look at the FAQ and read about "code delimiters" about how to nicely do that in the StataList forum.
      2) Show your description to a colleague, and ask for some help in clarifying your description, and rewrite it in your new post.

      Comment


      • #4
        Hi Prof Mike Lacy,
        Thank you for your feedback.
        I am using xtpoisson in Stata 13.1, currently working on bootstrapping. I combine Poisson with 2sls to tackle some issues in my dataset.
        For the 1st stage, I manage to save all 100 yhat (yhat_1, yhat_2, yhat_3......yhat_100) after bootstrapping (as per command below) and each yhat were saved in new column in the dataset used.That means, I have 100 new columns after the 1st stage of bootstrapping.


        Code:
        foreach n of numlist 1/100{
        use "dataset.dta", clear
        xtpoisson endovariable Instrument1 Instrument2 Z, irr fe vce(boot,rep(100))
        predict yhat_`n'
        preserve
        save tryA_`n', replace
        restore
        }
        
        *Forming appended data set
        use tryA_1, clear
        foreach n of numlist 2/100{
        append using tryA_`n'
        }
        save Predicted
        
        *for second stage
        foreach n of numlist 1/100 {
        xtpoisson Dependvariable yhat_1 Z, irr fe vce(boot,rep(100)),
        outreg2 using mysecondfindingN_`n'.doc, word dec (3)
        }

        ​​​​​​​For the 2nd stage, I want to run the regression (bootstrap) yhat_1, and store each regression result. Means, for yhat_1, I will have 100 regression result and 100 regression results for yhat_2 and so on until yhat_100.Therefore I will have 10000 bootstrapp regression result. The problem now is in the second stage, which I could not find the correct command to store all the regression result for each bootstrap. I am hoping that you could help me with this matter.

        Thank you so much Prof Mike Lacy

        Comment


        • #5
          I am not knowledgeable about the particular analysis (2SLS) you say you are doing. However, one things seems odd to me about your code: Using vce(boot ...) on your -xtpoisson- command will only change the estimates of the standard errors, and will give you exactly the same values for yhat each time. There is therefore no point to your first loop. So, I don't really understand what you are trying to do.

          Comment


          • #6
            Dear Prof. Mike Lacy,
            Thank you for your comment and I will look into my stata commands again regarding vce.
            But Prof., is there any way that I could save 100 sets of bootstrap estimates result, assuming that we wont use 2SLS estimator.

            Thank you so much Prof. Mike Lacy

            Comment


            • #7
              First, I would suggest you read -help bootstrap-, where among many other things, you will be able to learn how that bootstrap command is useful for your situation. You will want to pay particular attention to the saving() option of -bootstrap-. Then, you should take a look at https://stats.idre.ucla.edu/stata/fa...strap-program/ to learn about writing your own program to give to bootstrap. Finally, your application involves data that has been -xtset-, and I have not done boostrapping with xtset data, but I believe you will need to use the -strata- option of bootstrap in order to make the bootstrapping respect the panel aspect of your data. That's the best advice I can give at this point.

              Finally, I would note that I find various relevant pages when I search on such things as /bootstrap stata xt/

              Comment


              • #8
                Thank you very much Dear Prof. Mike Lacy. And you are right about the command only change the estimates of the standard errors. I will find out about -strata- option.

                Thank you very much for your advice Prof. Mike Lacy.

                Comment

                Working...
                X