Announcement

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

  • Finding out numerator and denominator of F-statistic of joint significance of some (but not all) regressors

    I am trying to get the numerator and denominator used to get a F-statistic of a joint significance test of some of the model's regressors.

    In case of a single regressor (or if we want to test the joint significance), this shows up in the regression output. The F-stat is the ratio between MS(Model) and MS(Residual).

    Code:
    . sysuse auto.dta, clear
    (1978 automobile data)
    
    . reg price mpg 
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =     20.26
           Model |   139449474         1   139449474   Prob > F        =    0.0000
        Residual |   495615923        72  6883554.48   R-squared       =    0.2196
    -------------+----------------------------------   Adj R-squared   =    0.2087
           Total |   635065396        73  8699525.97   Root MSE        =    2623.7
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
           _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
    ------------------------------------------------------------------------------
    
    . display 139449474/6883554.48 // I get the same Fstat as displayed in regression output
    20.258353
    What would be the numerator and denominator of the F-statistic below, when we test the join significance of some (but not all) regressors?

    Code:
    . reg price mpg weight foreign
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(3, 70)        =     23.29
           Model |   317252881         3   105750960   Prob > F        =    0.0000
        Residual |   317812515        70  4540178.78   R-squared       =    0.4996
    -------------+----------------------------------   Adj R-squared   =    0.4781
           Total |   635065396        73  8699525.97   Root MSE        =    2130.8
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |    21.8536   74.22114     0.29   0.769    -126.1758     169.883
          weight |   3.464706    .630749     5.49   0.000     2.206717    4.722695
         foreign |    3673.06   683.9783     5.37   0.000     2308.909    5037.212
           _cons |  -5853.696   3376.987    -1.73   0.087    -12588.88    881.4934
    ------------------------------------------------------------------------------
    
    . test mpg weight // how can I get the numerator and denominator used to calculate this F-sta
    > tistic?
    
     ( 1)  mpg = 0
     ( 2)  weight = 0
    
           F(  2,    70) =   34.77
                Prob > F =    0.0000
    
    .
    I copied below the corresponding detailed -anova- output, but I still don't know how to find out the numerator and denominator
    Code:
    . anova price c.mpg c.weight foreign
    
                             Number of obs =         74    R-squared     =  0.4996
                             Root MSE      =    2130.77    Adj R-squared =  0.4781
    
                      Source | Partial SS         df         MS        F    Prob>F
                  -----------+----------------------------------------------------
                       Model |  3.173e+08          3   1.058e+08     23.29  0.0000
                             |
                         mpg |  393607.95          1   393607.95      0.09  0.7693
                      weight |  1.370e+08          1   1.370e+08     30.17  0.0000
                     foreign |  1.309e+08          1   1.309e+08     28.84  0.0000
                             |
                    Residual |  3.178e+08         70   4540178.8  
                  -----------+----------------------------------------------------
                       Total |  6.351e+08         73     8699526  
    
    . test mpg weight
    
     ( 1)  mpg = 0
     ( 2)  weight = 0
    
           F(  2,    70) =   34.77
                Prob > F =    0.0000


  • #2
    Paula:
    see the -Methods and formulas- paragraph, -test- entry, Stata .pdf manual (a bit of heavy stuff! ).
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      maybe I'm misunderstanding, but doesn't the following line have what you are looking for
      Code:
       
       F(  2,    70) =   34.77
      where the "2" in the parens is the numerator df and the "70" is the denominator df?

      Comment


      • #4
        Thanks, both!
        Rich Goldstein, the F-statistic of 34.77 is equal to the ratio between the Mean Square of the between group (i.e., numerator) and the Mean Square of the within group (i.e., denominator). I am looking to get such numerator and denominator.
        Carlo Lazzaro, thank you for referring to the algebra behind! I was just wondering if Stata would allow us to recover the numerator and denominator of the F ratio.

        Comment


        • #5
          Look at the stored results:

          Code:
          di e(df_m)
          di e(df_r)
          Code:
          ereturn list

          Comment


          • #6
            Paula de Souza Leao Spinola - thanks for the clarification; I do not see those being saved by Stata anyplace (but maybe I missed them); I suggest writing to tech support

            Comment


            • #7
              Thanks Andrew Musau. This does not solve my question. I can compute the numerator and denominator of the F-ratio of all explanatory variables in the model (i.e., basically, the MS of the between and within groups divided by the respective degrees of freedom you referred to).

              What I am doing here is testing the joint significance of some (but not all) explanatory variables in the regression. I can get the F-stat by running the -test- command followed by the regressors of my interest. However, I haven't found a way to recover the numerator and denominator used in this calculation.

              Rich Goldstein, thanks for trying to help!

              Comment


              • #8
                I still cannot follow what the issue is here. The stored statistics for test are available from r()

                Code:
                sysuse auto, clear
                reg mpg rep78-turn
                test headroom trunk weight
                return list
                Res.:

                Code:
                . sysuse auto, clear
                (1978 Automobile Data)
                
                . reg mpg rep78-turn
                
                      Source |       SS           df       MS      Number of obs   =        69
                -------------+----------------------------------   F(6, 62)        =     21.46
                       Model |  1579.51779         6  263.252965   Prob > F        =    0.0000
                    Residual |  760.685109        62  12.2691147   R-squared       =    0.6749
                -------------+----------------------------------   Adj R-squared   =    0.6435
                       Total |   2340.2029        68  34.4147485   Root MSE        =    3.5027
                
                ------------------------------------------------------------------------------
                         mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                       rep78 |   .6052625   .5079629     1.19   0.238    -.4101409    1.620666
                    headroom |   .2185587   .6657947     0.33   0.744    -1.112346    1.549463
                       trunk |  -.0611532   .1661838    -0.37   0.714    -.3933498    .2710434
                      weight |   -.002695   .0017594    -1.53   0.131    -.0062121    .0008221
                      length |  -.0973695     .06771    -1.44   0.155    -.2327199     .037981
                        turn |  -.0421743   .2106316    -0.20   0.842    -.4632207    .3788722
                       _cons |   47.60779   8.287501     5.74   0.000     31.04131    64.17427
                ------------------------------------------------------------------------------
                
                . test headroom trunk weight
                
                 ( 1)  headroom = 0
                 ( 2)  trunk = 0
                 ( 3)  weight = 0
                
                       F(  3,    62) =    0.83
                            Prob > F =    0.4840
                
                . return list
                
                scalars:
                               r(drop) =  0
                               r(df_r) =  62
                                  r(F) =  .827028422441071
                                 r(df) =  3
                                  r(p) =  .4840004571773908
                
                .

                Comment


                • #9
                  The formula OP is asking for is

                  F = [(RSSr - RSSu)/q]/RSSu/(n - k),
                  where RSSr is the residual sum of squares of the restricted model
                  RSSu is the residual sum of squares of the unrestricted model
                  q is the number of restrictions test
                  n is the number of obs
                  k is the number of parameters estimated in the unrestricted model.

                  Here is an example, I want to test that mpg and headroom are jointly equal to 0 in the model

                  Code:
                  . sysuse auto, clear
                  (1978 automobile data)
                  
                  . reg price mpg headroom weight
                  
                        Source |       SS           df       MS      Number of obs   =        74
                  -------------+----------------------------------   F(3, 70)        =     11.09
                         Model |   204556469         3  68185489.6   Prob > F        =    0.0000
                      Residual |   430508927        70  6150127.53   R-squared       =    0.3221
                  -------------+----------------------------------   Adj R-squared   =    0.2931
                         Total |   635065396        73  8699525.97   Root MSE        =    2479.9
                  
                  ------------------------------------------------------------------------------
                         price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                           mpg |  -56.19416   85.07654    -0.66   0.511     -225.874    113.4856
                      headroom |  -675.5962   392.3504    -1.72   0.090    -1458.115     106.922
                        weight |   2.061945   .6586383     3.13   0.003      .748332    3.375557
                         _cons |   3158.306   3617.449     0.87   0.386    -4056.468    10373.08
                  ------------------------------------------------------------------------------
                  
                  . test mpg headroom
                  
                   ( 1)  mpg = 0
                   ( 2)  headroom = 0
                  
                         F(  2,    70) =    1.65
                              Prob > F =    0.1990
                  Now I fit the restricted model

                  Code:
                  . reg price weight
                  
                        Source |       SS           df       MS      Number of obs   =        74
                  -------------+----------------------------------   F(1, 72)        =     29.42
                         Model |   184233937         1   184233937   Prob > F        =    0.0000
                      Residual |   450831459        72  6261548.04   R-squared       =    0.2901
                  -------------+----------------------------------   Adj R-squared   =    0.2802
                         Total |   635065396        73  8699525.97   Root MSE        =    2502.3
                  
                  ------------------------------------------------------------------------------
                         price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
                  -------------+----------------------------------------------------------------
                        weight |   2.044063   .3768341     5.42   0.000     1.292857    2.795268
                         _cons |  -6.707353    1174.43    -0.01   0.995     -2347.89    2334.475
                  ------------------------------------------------------------------------------
                  Now I calculate manually the F-statistic

                  Code:
                  . display [(450831459 - 430508927 )/2]/[430508927 /70]
                  1.6522041
                  and I observe that what I calculated manually is numerically equivalent to what -test- reported.

                  Comment


                  • #10
                    This is extremely helpful Joro Kolev , thank you so much!

                    Comment

                    Working...
                    X