Announcement

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

  • bootstrap random residuals

    Hi all,

    I am trying to do a bootstrapping approach (in state 12.2) around the residuals. I would like to run my original regression

    reg y x1 x2
    predict yhat
    predict res, r

    Then, I would like to assign the residuals randomly to each of my predicted yhats. Then, using the original vector of x1 and x2, I would repeat the regression. I am new to bootstrapping, but from what I can see, this bootstrap is not one of the defaults in Stata's bootstrap command. Am I correct on that?

    Any help would be great.

    Thanks,
    Steve

  • #2
    Anybody have suggestions on how I can improve my question here?

    Comment


    • #3
      There was a remarkably similar question posted by Alexander Lauritzen earlier today (or maybe it was yesterday). He got extensive replies that, I think, solved his problem. Check out that post and see if it answers your question.

      Comment


      • #4
        Thanks, but I think that post was from a few weeks back. I added a comment on the post, trying to get some help from the problem in this question above. I believe the program outlined in those responses is what I am looking for though.

        Comment


        • #5
          You will need to write your own program if you want to resample residuals. If you use pairs/residual bootstrap, then bootstrap is still the proper command. If you want to resample residuals by reweighting (aka the wild bootstrap), then you would use simulate. If you can be more clear on your resampling concept, we can offer more guidance on the algorithm.

          Comment


          • #6
            Thanks Keith. Let me try to provide more information.

            Thanks Keith,

            Here is what I am trying to do.

            I analyze y=cons+bX+e

            Then, I predict y using the results, to get yhat.

            yhat=cons+bX

            I want to randomly add the residuals (e*) back to my yhat terms, to get yhat* (is this the same thing as simulate?)

            yhat*=yhat+e*

            I then want to regress the bootstrapped Y*s using the original set of regressors.

            Here is a program I am using currently.

            program bs_resid
            syntax, RESidual(varname numeric) MATrix(name)

            * get the varlist for -regress-
            local xvars : colna `matrix'
            local CONS _cons
            local xvars : list xvars - CONS

            * compute the linear prediction
            tempvar xb idx y
            matrix score double `xb' = `matrix'

            * idx randomly selects the observations with replacement
            gen long `idx' = ceil(_N*runiform())

            * the new dependent variable using resample residuals
            gen double `y' = `xb' + `residual'[`idx']

            regress `y' `xvars', vce(robust)
            end

            set seed 12345
            sysuse auto

            regress mpg turn trunk displ, vce(robust)
            matrix b = e(b)
            predict double resid, residuals
            simulate _b _se, reps(1000) : bs_resid, res(resid) mat(b)
            sum



            Any assistance here would be great.

            Thank you.

            -Steve

            Comment


            • #7
              Steve,

              The easiest way to use bootstrap and simulate with a custom program is to make that program e-class, and use ereturn to hand the simulated estimate back to bootstrap or simulate. The easiest way to use ereturn is ereturn post:
              Code:
              ereturn post [b [V [Cns]]] [weight] [, depname(string) obs(#) dof(#) esample(varname) properties(string)]
              You look to be using a "residual bootstrap". If that's the case, it would be easier to use the bootstrap command. If you want a "wild bootstrap", use simulate and draw your own weights for the residuals. Please read the Cameron, Gelbach, and Miller REStat paper for a nice comparison. That paper is focused on cluster sampling, but the discussion is useful for understand the general differences.

              Keith
              Last edited by Keith Finlay; 05 Sep 2014, 08:37.

              Comment


              • #8
                Thanks Keith. Yes, the residual bootstrap is what I am trying to do. I found the Cameron, Gelbach, and Miller paper useful. But, still not clear how to call the residual bootstrap command in Stata, using bootstrap. I am not finding the manual very useful in that regard. The words "residual bootstrap" are not in the manual, that I can see.

                Comment


                • #9
                  You will find what you need on this post: http://www.statalist.org/forums/foru...1275#post81275 .

                  Comment


                  • #10
                    Hey Keith, thanks. That is where the code above comes from. Would be nice to compare results to the canned procedure, which I will try to do now.

                    Comment

                    Working...
                    X