Announcement

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

  • generate all Root MSE from regression

    Hey there,

    I have run 722 regressions with my data set for each firm year by using: bysort variable: regress return market smb hml rmw cma

    how can I now generate the root MSE for each individual regression so that I have a list of the variable and root MSE values?

    Many thanks in advance

  • #2
    You do not explain very well what you want, because the RMSE are generated when you do what you do... But probably you want to save them?

    Explain better what you want, and give an data sample using -dataex-.

    Comment


    • #3
      If your question is about how to save those results, as Joro suggests, take a look at -help statsby-.

      Comment


      • #4
        Fabio:
        welcome to this forum.
        Do you mean something along the following lines?
        Code:
        . sysuse auto.dta
        (1978 Automobile Data)
        
        .  statsby _cons _b _se RMSE=e(rmse), by(foreign) nodots: regress mpg gear turn
        
              command:  regress mpg gear turn
          _eq2_stat_1:  _cons
            _eq2_RMSE:  e(rmse)
                   by:  foreign
        
        
        . list
        
             +---------------------------------------------------------------------------------------------------+
             |  foreign   _b_gea~o     _b_turn    _b_cons   _se_ge~o   _se_turn   _se_cons   _eq2_s~1   _eq2_R~E |
             |---------------------------------------------------------------------------------------------------|
          1. | Domestic   3.814768   -.7819742   41.52745   1.317297   .1115423   7.116191          1   2.819103 |
          2. |  Foreign   6.566766   -2.327916   84.17068   3.940296   .7793738   34.63375          1   5.075294 |
             +---------------------------------------------------------------------------------------------------+
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks for the quick response.

          To get a better understanding: I have a sample for around 80 companies with their daily stockreturn for 8 years.
          In summary I have 722 firm-year observation and i have to do a regression for each firm-year.
          It's for generating the idiosyncratic risk within the Fama & French 5 Factor Model.
          By using "bysort variable: regress return market smb hml rmw cma" stata run regressions for each firm-year (every firm-year has his own variable).
          Now I want to get the RMSE from all of the regressions, so that I have a list for all 722 RMSE.

          Code:
          ------------------------------------------------------------------------------------------------------------------
          -> variable = 721
          
                Source |       SS           df       MS      Number of obs   =       252
          -------------+----------------------------------   F(5, 246)       =     11.22
                 Model |  33.1924081         5  6.63848162   Prob > F        =    0.0000
              Residual |   145.59123       246  .591834268   R-squared       =    0.1857
          -------------+----------------------------------   Adj R-squared   =    0.1691
                 Total |  178.783638       251   .71228541   Root MSE        =    .76931
          
          ------------------------------------------------------------------------------
                return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                market |   .3050316   .0635369     4.80   0.000     .1798859    .4301773
                   smb |   .0025138    .172414     0.01   0.988    -.3370822    .3421098
                   hml |  -.6691774   .2559194    -2.61   0.009     -1.17325   -.1651046
                   rmw |  -.2798581   .3261269    -0.86   0.392    -.9222153    .3624991
                   cma |  -.3154956   .3174914    -0.99   0.321    -.9408438    .3098527
                 _cons |   -.084974   .0491616    -1.73   0.085    -.1818052    .0118573
          ------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------------------------------------------
          -> variable = 722
          
                Source |       SS           df       MS      Number of obs   =       251
          -------------+----------------------------------   F(5, 245)       =      9.18
                 Model |   38.833403         5   7.7666806   Prob > F        =    0.0000
              Residual |  207.351745       245  .846333653   R-squared       =    0.1577
          -------------+----------------------------------   Adj R-squared   =    0.1406
                 Total |  246.185148       250  .984740592   Root MSE        =    .91996
          
          ------------------------------------------------------------------------------
                return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                market |   .5535007   .1036814     5.34   0.000       .34928    .7577214
                   smb |   .0160476   .2073453     0.08   0.938    -.3923592    .4244544
                   hml |  -.2831234   .2518517    -1.12   0.262    -.7791941    .2129474
                   rmw |  -.8507779   .4060964    -2.10   0.037    -1.650664   -.0508922
                   cma |   -.275116   .3623975    -0.76   0.448    -.9889282    .4386963
                 _cons |   .0443023   .0586685     0.76   0.451    -.0712566    .1598612
          ------------------------------------------------------------------------------
          this is a extract of the bysort results

          Comment


          • #6
            Fabio:
            what's wrong with the approach suggested in #4?
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Dear Carlo,

              I'm sorry, I made a mistake by using your approach, but now it works.

              Thanks a lot!

              Comment

              Working...
              X