0
$\begingroup$

Say I am running the following regression:

$Y=\beta_0 + \beta_1X + \beta_2Z +\beta_3W + othercontrols + error$

I want to test the null hypothesis that the first three coefficients are equal, or: $H_o = \beta_1=\beta_2=\beta_3$

I know how to calculate this on statistical software(e.g. Stata), but I am curious how you would do this by hand. Here is my thought, first setting up the 'restricted' model:

Noting that this is saying $\beta_1 = \beta_2$ and $\beta_1=\beta_3$,

I can plug in $\beta_1$ for all three coefficients to get:

$Y=\beta_0 + \beta_1X + \beta_1Z +\beta_1W + othercontrols + error$

which becomes:

$Y=\beta_0 + \beta_1(X+Y+Z) + othercontrols + error$

and from that, I can generate a new variable which is just the sum of these three, call it G,and the regress:

$Y=\beta_0 + \beta_1G + othercontrols + error$

and use that to get the error some of squares for the F test? Is this the right track?

$\endgroup$
3
  • 1
    $\begingroup$ Minor comment. When you change the specification like this, it's often helpful to also alter the coefficients with new letters (or tildes or primes) since they are no longer quite the same. $\endgroup$
    – dimitriy
    Commented Jun 24, 2021 at 23:30
  • 1
    $\begingroup$ Ditto for the error terms. $\endgroup$
    – dimitriy
    Commented Jun 24, 2021 at 23:41
  • $\begingroup$ ok that makes sense, thanks for pointing that out! $\endgroup$
    – Steve
    Commented Jun 25, 2021 at 18:20

1 Answer 1

1
$\begingroup$

Your approach is indeed on the right track. More precisely, you first fit the unrestricted model where all the covariates can have different coefficients. You then fit the restricted model where you enter the sum as a covariate instead of individual terms, so the coefficients are restricted to be the same for all three of them. An adjusted change in the sum of squared residuals between the two models gives you the F statistic you use to test the equality restriction.

This is covered here for a different type of restriction, but the formula is the same, so it is straightforward to extend it to your setting.

Here is Stata code showing how to do the calculation:

. sysuse auto, clear
(1978 automobile data)

. 
. /* Hypothesis Test Using Stata */
. reg price mpg weight foreign length

      Source |       SS           df       MS      Number of obs   =        74
-------------+----------------------------------   F(4, 69)        =     21.01
       Model |   348708940         4    87177235   Prob > F        =    0.0000
    Residual |   286356456        69  4150093.57   R-squared       =    0.5491
-------------+----------------------------------   Adj R-squared   =    0.5230
       Total |   635065396        73  8699525.97   Root MSE        =    2037.2

------------------------------------------------------------------------------
       price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         mpg |  -13.40719   72.10761    -0.19   0.853    -157.2579    130.4436
      weight |   5.716181   1.016095     5.63   0.000     3.689127    7.743235
     foreign |   3550.194   655.4564     5.42   0.000     2242.594    4857.793
      length |  -92.48018    33.5912    -2.75   0.008    -159.4928   -25.46758
       _cons |    5515.58   5241.941     1.05   0.296    -4941.807    15972.97
------------------------------------------------------------------------------

. test  mpg == weight == foreign

 ( 1)  mpg - weight = 0
 ( 2)  mpg - foreign = 0

       F(  2,    69) =   15.46
            Prob > F =    0.0000

. display "F = " r(F) 
F = 15.462448

Now we can do it by hand:

. /* Same Hypothesis Test By Hand in Stata */
. /* (1) Fit Unconstrained Model */
. reg price mpg weight foreign length

      Source |       SS           df       MS      Number of obs   =        74
-------------+----------------------------------   F(4, 69)        =     21.01
       Model |   348708940         4    87177235   Prob > F        =    0.0000
    Residual |   286356456        69  4150093.57   R-squared       =    0.5491
-------------+----------------------------------   Adj R-squared   =    0.5230
       Total |   635065396        73  8699525.97   Root MSE        =    2037.2

------------------------------------------------------------------------------
       price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         mpg |  -13.40719   72.10761    -0.19   0.853    -157.2579    130.4436
      weight |   5.716181   1.016095     5.63   0.000     3.689127    7.743235
     foreign |   3550.194   655.4564     5.42   0.000     2242.594    4857.793
      length |  -92.48018    33.5912    -2.75   0.008    -159.4928   -25.46758
       _cons |    5515.58   5241.941     1.05   0.296    -4941.807    15972.97
------------------------------------------------------------------------------

. scalar URSS = e(rss)

. 
. /* (2) Fit Constrained Model */
. gen sum_of_three = mpg + weight + foreign

. reg price sum_of_three length

      Source |       SS           df       MS      Number of obs   =        74
-------------+----------------------------------   F(2, 71)        =     18.86
       Model |   220367724         2   110183862   Prob > F        =    0.0000
    Residual |   414697672        71  5840812.28   R-squared       =    0.3470
-------------+----------------------------------   Adj R-squared   =    0.3286
       Total |   635065396        73  8699525.97   Root MSE        =    2416.8

------------------------------------------------------------------------------
       price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
sum_of_three |   4.709994   1.127407     4.18   0.000     2.462008     6.95798
      length |  -97.29181   39.10159    -2.49   0.015    -175.2582   -19.32545
       _cons |    10126.2    4263.61     2.38   0.020     1624.799    18627.59
------------------------------------------------------------------------------

. scalar RRSS = e(rss)

. 
. display "F' = " ((scalar(RRSS) - scalar(URSS))/2)/(scalar(URSS)/69)
F' = 15.462448

This "by-hand" F-statistic matches the "canned" one above.

$\endgroup$
9
  • $\begingroup$ This doesn't seem to give the "by hand" version, which seems to be what the OP is asking for. $\endgroup$ Commented Jun 24, 2021 at 23:34
  • $\begingroup$ @gung I suppose I can calculate the sums of squares in a more manual manner. Would that allay your concern? Or do you have something else in mind? $\endgroup$
    – dimitriy
    Commented Jun 24, 2021 at 23:36
  • $\begingroup$ I'm not married to any specific format, & I'm certainly not opposed to Stata. I'm just trying to point out that your answer, which I would otherwise upvote, doesn't seem to quite answer the OP's explicit question. $\endgroup$ Commented Jun 25, 2021 at 1:20
  • $\begingroup$ My answer shows how to get the F statistic from the scaled SSRs from the constrained and unconstrained regressions that matches the one produced by the canned hypothesis test of the restriction at the beginning. I am not sure what is missing since two regressions plus division gives you the test statistic. $\endgroup$
    – dimitriy
    Commented Jun 25, 2021 at 1:50
  • $\begingroup$ Maybe I just don't get it, since I can't read Stata code. The OP asks, can I "generate a new variable which is just the sum of these three, call it G, and then regress... and use that to get the error some of squares for the F test? Is this the right track?" I don't see an explicit answer to that. $\endgroup$ Commented Jun 25, 2021 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.