Announcement

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

  • Doing a t test on regression coefficients

    Hi,

    I am trying to do a t test that the null hypothesis is B2= -B1 where B2 is the coefficient on a variable called lexpendB and B1 is the coefficient on lexpendA.

    My stata output is as follows:

    regress voteA lexpendA lexpendB prtystrA

    Source | SS df MS Number of obs = 173
    -------------+---------------------------------- F(3, 169) = 215.23
    Model | 38405.1089 3 12801.703 Prob > F = 0.0000
    Residual | 10052.1396 169 59.4801161 R-squared = 0.7926
    -------------+---------------------------------- Adj R-squared = 0.7889
    Total | 48457.2486 172 281.728189 Root MSE = 7.7123

    ------------------------------------------------------------------------------
    voteA | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    lexpendA | 6.083316 .38215 15.92 0.000 5.328914 6.837719
    lexpendB | -6.615417 .3788203 -17.46 0.000 -7.363247 -5.867588
    prtystrA | .1519574 .0620181 2.45 0.015 .0295274 .2743873
    _cons | 45.07893 3.926305 11.48 0.000 37.32801 52.82985
    ------------------------------------------------------------------------------


    But when I do ttest lexpendB=-lexpendA it gives me an error. What would be the code for testing this hypothesis?

  • #2
    Post some subset of your data, and what exactly error Stata gives you.

    Because to me it does not give an error:

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . reg price mpg head
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(2, 71)        =     10.44
           Model |   144280501         2  72140250.4   Prob > F        =    0.0001
        Residual |   490784895        71  6912463.32   R-squared       =    0.2272
    -------------+----------------------------------   Adj R-squared   =    0.2054
           Total |   635065396        73  8699525.97   Root MSE        =    2629.2
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |  -259.1057   58.42485    -4.43   0.000    -375.6015   -142.6098
        headroom |  -334.0215   399.5499    -0.84   0.406    -1130.701    462.6585
           _cons |   12683.31   2074.497     6.11   0.000     8546.885    16819.74
    ------------------------------------------------------------------------------
    
    . test mpg = - head
    
     ( 1)  mpg + headroom = 0
    
           F(  1,    71) =    1.93
                Prob > F =    0.1692

    Comment


    • #3
      I got it now. You are using the wrong command. It is not -ttest-. You have to write -test- as I have done above.

      Comment


      • #4
        I want a t test, not an F test.

        ttest lexpendB=-lexpendA
        - invalid name
        r(198);

        Comment


        • #5
          I know I can get the t statistic from the F statistic, but there must be a command to do a t test on this.

          Comment


          • #6
            You can find out about the "postestimation commands" available after running an estimation command by using the help command; for example help regress postestimation points us to the lincom command.

            Code:
            . sysuse auto, clear
            (1978 Automobile Data)
            
            . regress price mpg headroom
            
                  Source |       SS           df       MS      Number of obs   =        74
            -------------+----------------------------------   F(2, 71)        =     10.44
                   Model |   144280501         2  72140250.4   Prob > F        =    0.0001
                Residual |   490784895        71  6912463.32   R-squared       =    0.2272
            -------------+----------------------------------   Adj R-squared   =    0.2054
                   Total |   635065396        73  8699525.97   Root MSE        =    2629.2
            
            ------------------------------------------------------------------------------
                   price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                     mpg |  -259.1057   58.42485    -4.43   0.000    -375.6015   -142.6098
                headroom |  -334.0215   399.5499    -0.84   0.406    -1130.701    462.6585
                   _cons |   12683.31   2074.497     6.11   0.000     8546.885    16819.74
            ------------------------------------------------------------------------------
            
            . test mpg = - headroom
            
             ( 1)  mpg + headroom = 0
            
                   F(  1,    71) =    1.93
                        Prob > F =    0.1692
            
            . lincom mpg + headroom
            
             ( 1)  mpg + headroom = 0
            
            ------------------------------------------------------------------------------
                   price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                     (1) |  -593.1271   427.0515    -1.39   0.169    -1444.644    258.3893
            ------------------------------------------------------------------------------

            Comment


            • #7
              Originally posted by Ryan Whetstine View Post
              I know I can get the t statistic from the F statistic, but there must be a command to do a t test on this.
              The command that you might be looking for is either -lincom-, or the Square Root Command:

              Code:
              . sysuse auto, clear
              (1978 Automobile Data)
              
              . reg price mpg head, noheader
              ------------------------------------------------------------------------------
                     price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       mpg |  -259.1057   58.42485    -4.43   0.000    -375.6015   -142.6098
                  headroom |  -334.0215   399.5499    -0.84   0.406    -1130.701    462.6585
                     _cons |   12683.31   2074.497     6.11   0.000     8546.885    16819.74
              ------------------------------------------------------------------------------
              
              . test mpg = - head
              
               ( 1)  mpg + headroom = 0
              
                     F(  1,    71) =    1.93
                          Prob > F =    0.1692
              
              . dis sqrt(r(F))
              1.3888891
              
              . lincom mpg + head
              
               ( 1)  mpg + headroom = 0
              
              ------------------------------------------------------------------------------
                     price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       (1) |  -593.1271   427.0515    -1.39   0.169    -1444.644    258.3893
              ------------------------------------------------------------------------------
              
              . dis r(t)
              -1.3888891
              As one can see the two are the same except for the sign which gets lost when you do t^2=F.

              But I agree that it would have been cute if Stata could return the t-version of the F-test for a single constraint if you instruct her to do so by something like (imaginary code follows, this does not exist in Stata) -test mpg = - head, ttest-.

              Comment

              Working...
              X