Announcement

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

  • Bootstrapping fund alphas to distinguish luck vs skills: program automation

    Dear Forum,

    I have been trying to bootstrap some fund alphas derived from a Fama-French linear regression of the following form:
    Ri = αi + siRmt + biSMBt + hiHMLt + εi
    This is in order to determine whether the performance of fund managers given by alpha is due to luck or skills.
    For simplicity, I have around 13 funds for which I'd like to bootstrap the alphas for (see attached .csv file) and I have already used the following code (obtained from this website) to generate the bootstrapped alpha values of only one out of the 13 funds (name of the fund: ie00b65ng183):

    program bs_resid
    version 13.1
    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

    regress ie00b65ng183 mktrf smb hml , vce(robust)
    matrix b = e(b)

    * zero intercept
    local icons = colnumb(b, "_cons")
    matrix b[1,`icons'] = 0

    predict double resid, residuals
    simulate _b _se, reps(1000) : bs_resid, res(resid) mat(b)
    histogram _b_cons, frequency normal
    summ _b_cons

    However, I would ideally like to automate this process in order to bootstrap the alpha coefficient of all 13 funds in the .csv file but saving the bootstrapped values of all previous funds into a file... Is there a way to automate the program above to obtain bootsrapped data for all funds in the list? I'm new to Stata so your help would be greatly appreciated. Thanks
    Attached Files

  • #2
    I did write a wrapper program for a client to do what you want , but the service was paid. If you are interested, see http://www.opendoors.pk/home/paid-he...irical-finance
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Thank you for the reply! Unfortunately, I was looking for something a little bit cheaper...thank you for the help

      Comment


      • #4
        Hi, for those that are interested, I've managed to change the code slightly to make Stata calculate the coefficients for all funds in the attached file:

        Replacing
        regress ie00b65ng183 mktrf smb hml , vce(robust)
        matrix b = e(b)

        with

        foreach x of varlist ie00b65ng183-lu0122612848 {
        reg `x' mktrf smb hml
        }
        matrix b=e(b)

        However, I am still not able to bootstrap the alphas and save the results for all funds, just the first fund on the list so your help would still be greatly appreciated!

        Comment


        • #5
          Hi, right, I've done a bit more work on this and have used some code to bootstrap the estimates (alphas) for all funds in my spreadsheet in a loop.

          Code:

          cap prog drop bootresiduals3
          program bootresiduals3

          drop _all

          use residuals
          bsample
          merge using "O:\Documents\tibo.dta"
          reg `yvar' mktrf smb hml, r
          predict xb
          gen ystar = xb - _b[_cons] + uhat
          reg ystar mktrf smb hml, r

          end

          cd

          foreach yvar in ie00b65ng183 lu0256839274 lu0154234636 ie0004766675 lu0187937411 lu0261959422 lu0210531801 lu0942865220 lu0125946151 lu0823399810 lu0246035637 lu0153585137 lu0122612848 {

          use "O:\Documents\tibo.dta", clear
          reg `yvar' mktrf smb hml, r
          predict uhat, resid
          keep uhat
          save residuals, replace


          simulate _b _se, reps(1000): bootresiduals3 `yvar'

          }

          The bootstrap seems to work OK with no error messages popping up. However, the bootstrapped alpha values for each fund do not seem to be saved in the tibo.dta file. Only the bootstrap values for the first fund seem to be saved. I was wondering whether anyone could look at the code above and let me know why the alphas (and other estimators) are not merging in the tibo.dta file as they should do in theory...

          Your help would be greatly appreciated.

          Comment


          • #6
            Hello again, I think the main problem with the code above is the fact that the file residuals.dta is being replaced with a new set of estimates for the coefficient of interest every time the bootstrap simulation runs for each fund. Is there any way the new set of estimates generated after each bootstrap simulation can be merged into the already existing residuals.dta file? Your help would be greatly appreciated as I'm running out of ideas! Thanks

            Comment


            • #7
              Please let me know if what I'm asking is unclear and I will try to my best to answer your questions. Again, your help would be greatly appreciated.

              Comment


              • #8
                I seem to have found a solution to my problem (After many hours of head scratching!) so please let me know if you'd like more information...(the code is very long). thank you

                Comment


                • #9
                  Hello Thibault I am currently working on a project where I would like to examine whether fund managers performance is due to luck or skill, so please I would be greatfull if you could share the part of the remaining code above. Hope it is not too late!
                  Thank you.

                  Comment


                  • #10
                    Hello Thibault I would like to examine whether fund managers performance is due to luck or skill, so please I would be greatfull if you could share the part of the remaining code above. Hope it is not too late!
                    Thank you.

                    Comment

                    Working...
                    X