Announcement

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

  • Residual variance from the market model for multiple companies

    Hi all,

    For my Master's thesis I have to calculate 'Market Model Adjusted Return' with market model parameters computed over the five-year period ending in July 2008 & 'Idiosyncratic Risk', which is computed as the residual variance from the market model estimated over the five-year period ending in July 2008, using monthly data. There are over 3,000 companies in my dataset.

    I was able to get the the market model parameters for 'Market Model Adjusted Return' by using: rangestat (reg) lnret marketreturn, interval(crisis 0 0) by(PERMNO)
    However, this command doesn't give residuals for the variable 'Idiosyncratic Risk'. So I need a command that does give me, for each company, 1 residual for the regression lnret marketreturn in the five-year period ending in July 2008 (crisis==0).

    Could anyone please help me with the code to obtain the residuals?

    Thank you,
    Julia



    *crisis is a dummy variable set to 1 if NamesDate is between 20030731-20080731
    *lnret is the natural logarithm of return
    *beta2 and alpha2 are market model parameters calculated with rangestat if crisis==0

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(PERMNO NamesDate) float lnret double marketreturn float(crisis beta2 alpha2)
    10002 20030731            .  .021749 0 1.215891 -.019994756
    10002 20030829  .0024891114  .023516 0 1.215891 -.019994756
    10002 20030930   -.06350322 -.010602 0 1.215891 -.019994756
    10002 20031031   .021618923  .058836 0 1.215891 -.019994756
    10002 20031128    .02242965  .015052 0 1.215891 -.019994756
    10002 20031231   .015094626  .043848 0 1.215891 -.019994756
    10002 20040130   .005602255  .022013 0 1.215891 -.019994756
    10002 20040227    .11370549  .013994 0 1.215891 -.019994756
    10002 20040331  -.031516396 -.011991 0 1.215891 -.019994756
    10002 20040430   -.03727863  -.02556 0 1.215891 -.019994756
    10002 20040528   .015896713  .012374 0 1.215891 -.019994756
    10002 20040630   .023095714  .020039 0 1.215891 -.019994756
    10002 20040730   .003418807 -.038765 0 1.215891 -.019994756
    10002 20040831   .022498136  .001083 0 1.215891 -.019994756
    10002 20040930    .04459684  .019085 0 1.215891 -.019994756
    10002 20041029    .01058211  .016579 0 1.215891 -.019994756
    10002 20041130     .1142681  .044313 0 1.215891 -.019994756
    10002 20041231    .14444579  .033422 0 1.215891 -.019994756
    10002 20050131   -.14210112 -.027405 0 1.215891 -.019994756
    10002 20050228    -.0338208  .020839 0 1.215891 -.019994756
    10002 20050331  -.019570095 -.018583 0 1.215891 -.019994756
    10002 20050429   -.06902816 -.026569 0 1.215891 -.019994756
    10002 20050531    .04553296   .03615 0 1.215891 -.019994756
    10002 20050630  -.012213892  .009902 0 1.215891 -.019994756
    10002 20050729    .07637298  .042229 0 1.215891 -.019994756
    10002 20050831   .032208152 -.007761 0 1.215891 -.019994756
    10002 20050930   -.12146459  .009338 0 1.215891 -.019994756
    10002 20051031   -.04563126 -.021981 0 1.215891 -.019994756
    10002 20051130    .09125499   .03807 0 1.215891 -.019994756
    10002 20051230 -.0039721997  .001886 0 1.215891 -.019994756
    10002 20060131   .029413885  .038935 0 1.215891 -.019994756
    10002 20060228    .06363232 -.003553 0 1.215891 -.019994756
    10002 20060331  .0040714825  .017575 0 1.215891 -.019994756
    10002 20060428  -.069638036  .011492 0 1.215891 -.019994756
    10002 20060531    .04819071 -.033021 0 1.215891 -.019994756
    10002 20060630    .07933284 -.001883 0 1.215891 -.019994756
    10002 20060731     .1580993 -.002918 0 1.215891 -.019994756
    10002 20060831  -.034792554  .022974 0 1.215891 -.019994756
    10002 20060929    .04923845  .018105 0 1.215891 -.019994756
    10002 20061031     -.129187  .036087 0 1.215891 -.019994756
    10002 20061130  -.012315427  .021338 0 1.215891 -.019994756
    10002 20061229    .05269669  .009153 0 1.215891 -.019994756
    10002 20070131    -.1723402  .018461 0 1.215891 -.019994756
    10002 20070228   .032519467 -.015979 0 1.215891 -.019994756
    10002 20070330   -.04752913  .011475 0 1.215891 -.019994756
    10002 20070430   -.05488146  .038449 0 1.215891 -.019994756
    10002 20070531 .00049912656  .036643 0 1.215891 -.019994756
    10002 20070629    .04679216 -.016128 0 1.215891 -.019994756
    10002 20070731   -.18346506 -.032764 0 1.215891 -.019994756
    10002 20070831  -.073580034  .009677 0 1.215891 -.019994756
    10002 20070928  -.018018505  .039325 0 1.215891 -.019994756
    10002 20071031   -.16751015  .024655 0 1.215891 -.019994756
    10002 20071130   -.08022805 -.051276 0 1.215891 -.019994756
    10002 20071231   -.02851517 -.006511 0 1.215891 -.019994756
    10002 20080131    .02045061 -.063243 0 1.215891 -.019994756
    10002 20080229    -.1166703 -.023605 0 1.215891 -.019994756
    10002 20080331  -.022080014  -.01216 0 1.215891 -.019994756
    10002 20080430    .01018056  .049736 0 1.215891 -.019994756
    10002 20080530   -.07651915  .021494 0 1.215891 -.019994756
    10002 20080630    -.4230138 -.080241 0 1.215891 -.019994756
    10002 20080731    .12934968  -.01469 0 1.215891 -.019994756
    10002 20080829     .1180793  .008576 1 1.215891 -.019994756
    10002 20080930     .4411555  -.09977 1 1.215891 -.019994756
    10002 20081031   -.05161427 -.186131 1 1.215891 -.019994756
    10002 20081128  .0016038496  -.08735 1 1.215891 -.019994756
    10002 20081231    .16779345  .019088 1 1.215891 -.019994756
    10002 20090130   -.50924605 -.078704 1 1.215891 -.019994756
    10002 20090227     -.374386 -.103448 1 1.215891 -.019994756
    10002 20090331   .037011463  .083479 1 1.215891 -.019994756
    10025 20030731            .  .021749 0  1.53617 .0039992216
    10025 20030829    .06628192  .023516 0  1.53617 .0039992216
    10025 20030930    .04980763 -.010602 0  1.53617 .0039992216
    10025 20031031   -.16551444  .058836 0  1.53617 .0039992216
    10025 20031128  -.035281815  .015052 0  1.53617 .0039992216
    10025 20031231    .29651722  .043848 0  1.53617 .0039992216
    10025 20040130    .12175683  .022013 0  1.53617 .0039992216
    10025 20040227   .003629768  .013994 0  1.53617 .0039992216
    10025 20040331    -.0312813 -.011991 0  1.53617 .0039992216
    10025 20040430    .10965037  -.02556 0  1.53617 .0039992216
    10025 20040528   -.11527362  .012374 0  1.53617 .0039992216
    10025 20040630    .04232462  .020039 0  1.53617 .0039992216
    10025 20040730   -.04138521 -.038765 0  1.53617 .0039992216
    10025 20040831  -.017045867  .001083 0  1.53617 .0039992216
    10025 20040930    .02359713  .019085 0  1.53617 .0039992216
    10025 20041029    .03122384  .016579 0  1.53617 .0039992216
    10025 20041130  -.006349228  .044313 0  1.53617 .0039992216
    10025 20041231     .2942573  .033422 0  1.53617 .0039992216
    10025 20050131    .24526983 -.027405 0  1.53617 .0039992216
    10025 20050228      .079022  .020839 0  1.53617 .0039992216
    10025 20050331  -.032381408 -.018583 0  1.53617 .0039992216
    10025 20050429   -.06052969 -.026569 0  1.53617 .0039992216
    10025 20050531   -.07597175   .03615 0  1.53617 .0039992216
    10025 20050630    .06895418  .009902 0  1.53617 .0039992216
    10025 20050729      .059413  .042229 0  1.53617 .0039992216
    10025 20050831    .04442957 -.007761 0  1.53617 .0039992216
    10025 20050930    .07341018  .009338 0  1.53617 .0039992216
    10025 20051031    -.0822381 -.021981 0  1.53617 .0039992216
    10025 20051130    .12487333   .03807 0  1.53617 .0039992216
    10025 20051230     .0833816  .001886 0  1.53617 .0039992216
    10025 20060131    .03922071  .038935 0  1.53617 .0039992216
    end

  • #2
    I have not used -rangestat-.

    However your Idiosyncratic Risk is contained in the Root Mean Squared Error, this is the standard deviation of the residual from your market model regression. If you want the variance of the residual, you raise the root mean squared error to the power of 2.

    This quantity, the root mean squared error is in e(rmse).

    If -rangestat- can calculate and save your regression parameters, it should be able to save also your e(rmse).

    Comment


    • #3
      Are you asking for something like this
      Code:
      ssc install asreg
       bys PERMNO: asreg lnret marketreturn,  rmse fit se
      
      . list _* in 1/20
      
           +-------------------------------------------------------------------+
           |     _rmse   _Nobs         _R2      _adjR2   _b_mar~n      _b_cons |
           |-------------------------------------------------------------------|
        1. |         .       .           .           .          .            . |
        2. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
        3. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
        4. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
        5. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
           |-------------------------------------------------------------------|
        6. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
        7. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
        8. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
        9. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       10. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
           |-------------------------------------------------------------------|
       11. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       12. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       13. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       14. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       15. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
           |-------------------------------------------------------------------|
       16. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       17. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       18. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       19. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
       20. | .12643979      68   .07597682   .06197646   .8254304   -.01267124 |
           +-------------------------------------------------------------------+
      To know more about asreg, read these resources on my website http://fintechprofessor.com/stata-pr...ions-in-stata/
      Last edited by Attaullah Shah; 07 Jan 2019, 04:02.
      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


      • #4
        Thank you both for your help!

        Attaullah Shah I indeed needed the function: bys PERMNO: asreg lnret marketreturn, rmse fit se. Thank you for this!
        However, I needed the residuals for the market model based on the crisis period so I slightly added it to: bys PERMNO: asreg lnret marketreturn if crisis==0, rmse fit se.
        And I used the comment of Joro Kolev by using: by PERMNO: gen residual=(_rmse)^2 to obtain the residuals. (Unfortunatly rangestat only saves r2, adjr2, the coefficients and their standard error)

        Thanks a lot!
        Julia

        Comment


        • #5
          I am glad it worked for you. Please note that asreg is the program name that I have contributed to the Stata community, it is not a function. Usually, Stata functions are made by the Stata corporation, examples, include date() mod(), real(), mofd() etc.
          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


          • #6
            Julia,

            Out of curiosity, how is this:

            Code:
            by PERMNO: gen residual=(_rmse)^2
            going to contribute to obtain the idiosyncratic volatility? Don't you already have the residuals?

            I personally use Egarch or other ARCH family to obtain the IV.

            Thank you

            Comment


            • #7
              Hi Saad Al,

              I am partly following the paper Lins et al. (2017) Social capital, trust, and firm performance for my thesis. Therefore, I have to get to the regression:
              Returni,t=0+b1*CSRi+ b2*MarketCapi+ b3*LongTermDebti+ b4*ShortTermDebti+ b5*CashHoldingsi+ b6*Profitabilityi +b7*NegativeBM+ b8*Momentumi+ b9*IdiosyncraticRiski+ Four Factor Loadings+Industry Dummy+ei,t.
              Idiosyncratic Risk is one of the variables I need to obtain and is computed as the residual variance from the market model.

              I hope this answers your question.

              Comment


              • #8
                Thank you for sharing this paper, Julia. In computing Idiosyncratic risk, I am more familiar with Fu (2008)'s methodology in his work "Idiosyncratic risk and the cross-section of expected stock returns" as well as Ang et al (2006) "The cross-section of volatility and expected returns." I will read this paper this weekend, hopefully.
                Although you are using Idiosyncratic risk as a control variable, It would be interesting, at least to me, to see the relation between return and Idiosyncratic risk.There are two opposing views in the literature and the above two papers are one example.
                Thank you again for sharing

                Comment

                Working...
                X