Announcement

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

  • Extraction of R squared from a series of regressions

    Hi,

    I was wondering if it possible to extract given value from a series of regressions.

    I managed to generate 56 regressions (1962-2017) usind Stata 15 and now I need the R squared from every regression.


    Code:
    -> pyear = 2015
    
          Source |       SS           df       MS      Number of obs   =     3,935
    -------------+----------------------------------   F(1, 3933)      =  13057.92
           Model |  21756541.1         1  21756541.1   Prob > F        =    0.0000
        Residual |  6552993.76     3,933  1666.15656   R-squared       =    0.7685
    -------------+----------------------------------   Adj R-squared   =    0.7685
           Total |  28309534.9     3,934   7196.1197   Root MSE        =    40.819
    
    ------------------------------------------------------------------------------
             prc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            ibpr |   11.97655   .1048081   114.27   0.000     11.77107    12.18204
           _cons |   22.24909   .6580438    33.81   0.000     20.95895    23.53923
    ------------------------------------------------------------------------------
    
    ---------------------------------------------------------------------------------------------------------------------------------------------
    -> pyear = 2016
    
          Source |       SS           df       MS      Number of obs   =     3,909
    -------------+----------------------------------   F(1, 3907)      =   5940.46
           Model |  12809123.3         1  12809123.3   Prob > F        =    0.0000
        Residual |  8424470.45     3,907  2156.25044   R-squared       =    0.6032
    -------------+----------------------------------   Adj R-squared   =    0.6031
           Total |  21233593.7     3,908  5433.36584   Root MSE        =    46.435
    
    ------------------------------------------------------------------------------
             prc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            ibpr |   14.08432   .1827367    77.07   0.000     13.72605    14.44259
           _cons |   22.48249   .7494967    30.00   0.000     21.01304    23.95193
    ------------------------------------------------------------------------------
    
    ---------------------------------------------------------------------------------------------------------------------------------------------
    -> pyear = 2017
    
          Source |       SS           df       MS      Number of obs   =     3,809
    -------------+----------------------------------   F(1, 3807)      =   7187.95
           Model |  22908960.9         1  22908960.9   Prob > F        =    0.0000
        Residual |  12133417.1     3,807  3187.13346   R-squared       =    0.6538
    -------------+----------------------------------   Adj R-squared   =    0.6537
           Total |    35042378     3,808  9202.30515   Root MSE        =    56.455
    
    ------------------------------------------------------------------------------
             prc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            ibpr |   12.99276   .1532495    84.78   0.000      12.6923    13.29322
           _cons |   25.81245   .9221506    27.99   0.000     24.00449     27.6204
    ------------------------------------------------------------------------------

    I found a code that link this coefficient to a company, but not for years.

    I work on panel data and I have multiple observations for every year.


    Any help or comments much appreciated. Sorry If I missed any important information.

    Thanks!
    Last edited by Jakub Cirkowski; 20 Jul 2018, 03:49.

  • #2
    In your concurrent thread (https://www.statalist.org/forums/for...1-broken-loops) in #3 there I referred you to rangestat (SSC). Here's a dopey example of cross-section regressions for each year of a panel dataset.


    Code:
    . webuse grunfeld, clear
    
    . rangestat (reg) invest mvalue, int(year 0 0)
    
    . tabdisp year, c(reg_r2) format(%4.3f)
    
    --------------------------------
         year |               reg_r2
    ----------+---------------------
         1935 |                0.865
         1936 |                0.696
         1937 |                0.654
         1938 |                0.635
         1939 |                0.787
         1940 |                0.820
         1941 |                0.844
         1942 |                0.855
         1943 |                0.835
         1944 |                0.872
         1945 |                0.905
         1946 |                0.895
         1947 |                0.891
         1948 |                0.787
         1949 |                0.862
         1950 |                0.857
         1951 |                0.864
         1952 |                0.843
         1953 |                0.886
         1954 |                0.856
    --------------------------------

    Comment


    • #3
      Thank you very much for help I will try to use it as the result looks perfect to me.

      Comment

      Working...
      X