Announcement

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

  • Testing significance of interaction coefficient in regression

    Hi,

    I have the following formula : reg Outcome x1 x2 x1*x2, where x1*x2 is an interaction variable of x1 and x2. Both x1 and x2 are binary variables, Outcome is continuous variable.


    How can I best test the significance between interaction variable x1*x2 and variable x1? I tried using test x1 + x1*x2=0 , but I'm not sure if this is the correct way to test it.

    Thanks

  • #2
    Mark:
    you may want to consider:
    Code:
    . use "https://www.stata-press.com/data/r17/auto.dta"
    (1978 automobile data)
    
    . regress price i.rep78##i.foreign
    note: 1b.rep78#1.foreign identifies no observations in the sample.
    note: 2.rep78#1.foreign identifies no observations in the sample.
    note: 5.rep78#1.foreign omitted because of collinearity.
    
          Source |       SS           df       MS      Number of obs   =        69
    -------------+----------------------------------   F(7, 61)        =      0.39
           Model |    24684607         7  3526372.43   Prob > F        =    0.9049
        Residual |   552112352        61  9051022.16   R-squared       =    0.0428
    -------------+----------------------------------   Adj R-squared   =   -0.0670
           Total |   576796959        68  8482308.22   Root MSE        =    3008.5
    
    -------------------------------------------------------------------------------
            price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    --------------+----------------------------------------------------------------
            rep78 |
               2  |   1403.125   2378.422     0.59   0.557    -3352.823    6159.073
               3  |   2042.574   2204.707     0.93   0.358    -2366.011    6451.159
               4  |   1317.056   2351.846     0.56   0.578    -3385.751    6019.863
               5  |       -360   3008.492    -0.12   0.905    -6375.851    5655.851
                  |
          foreign |
         Foreign  |   2088.167   2351.846     0.89   0.378     -2614.64    6790.974
                  |
    rep78#foreign |
       1#Foreign  |          0  (empty)
       2#Foreign  |          0  (empty)
       3#Foreign  |  -3866.574   2980.505    -1.30   0.199    -9826.462    2093.314
       4#Foreign  |  -1708.278   2746.365    -0.62   0.536    -7199.973    3783.418
       5#Foreign  |          0  (omitted)
                  |
            _cons |     4564.5   2127.325     2.15   0.036      310.651    8818.349
    -------------------------------------------------------------------------------
    
    . mat list e(b)
    
    e(b)[1,18]
                1b.          2.          3.          4.          5.         0b.          1.   1b.rep78#   1b.rep78#   2o.rep78#   2o.rep78#
             rep78       rep78       rep78       rep78       rep78     foreign     foreign  0b.foreign  1o.foreign  0b.foreign  1o.foreign
    y1           0    1403.125   2042.5741   1317.0556        -360           0   2088.1667           0           0           0           0
    
          3o.rep78#    3.rep78#   4o.rep78#    4.rep78#   5o.rep78#   5o.rep78#          
        0b.foreign   1.foreign  0b.foreign   1.foreign  0b.foreign  1o.foreign       _cons
    y1           0  -3866.5741           0  -1708.2778           0           0      4564.5
    
    . test 4.rep78= 4.rep78+4.rep78#1.foreign
    
     ( 1)  - 4.rep78#1.foreign = 0
    
           F(  1,    61) =    0.39
                Prob > F =    0.5363
    
    .
    Aa expected -test- outcome and -regress- outcome table give back the very same p-value.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment

    Working...
    X