Announcement

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

  • T test between coefficients in categorical variables

    Hello there,



    my regression is: WageHour Var1##Var2


    I want to check all the p-values between the values of the interaction variable (as you can see in the circle below)

    for example, the p-value between (0 2) and (0 3), or the p-value between (0,3) and (0,4) in the interaction variable (var1#var2)


    Indeed, i know that i can launch regression like:

    WageHour Var1##ib(3).Var2


    but I want the stata to do it automatically for all the p-value combinations.


    How can i do it?
    Thanks, Peter
    Attached Files
    Last edited by Peter Housmann; 19 Sep 2019, 07:51.

  • #2
    Peter:
    with a bit og guess-work, you may be looking for -test-:
    Code:
    . use "C:\Program Files (x86)\Stata15\ado\base\a\auto.dta"
    (1978 Automobile Data)
    
    . regress price i.foreign##i.rep78
    note: 1.foreign#1b.rep78 identifies no observations in the sample
    note: 1.foreign#2.rep78 identifies no observations in the sample
    note: 1.foreign#5.rep78 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 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
          foreign |
         Foreign  |   2088.167   2351.846     0.89   0.378     -2614.64    6790.974
                  |
            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#rep78 |
       Foreign#1  |          0  (empty)
       Foreign#2  |          0  (empty)
       Foreign#3  |  -3866.574   2980.505    -1.30   0.199    -9826.462    2093.314
       Foreign#4  |  -1708.278   2746.365    -0.62   0.536    -7199.973    3783.418
       Foreign#5  |          0  (omitted)
                  |
            _cons |     4564.5   2127.325     2.15   0.036      310.651    8818.349
    -------------------------------------------------------------------------------
    
    . test 1.foreign#3.rep78=1.foreign#4.rep78
    
     ( 1)  1.foreign#3.rep78 - 1.foreign#4.rep78 = 0
    
           F(  1,    61) =    0.87
                Prob > F =    0.3550
    By the way, launching:
    Code:
    regress WageHour i.Var1##i.Var2
    you would actually obtain the result of a different regression model.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Peter:
      with a bit og guess-work, you may be looking for -test-:
      Code:
      . use "C:\Program Files (x86)\Stata15\ado\base\a\auto.dta"
      (1978 Automobile Data)
      
      . regress price i.foreign##i.rep78
      note: 1.foreign#1b.rep78 identifies no observations in the sample
      note: 1.foreign#2.rep78 identifies no observations in the sample
      note: 1.foreign#5.rep78 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 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
      --------------+----------------------------------------------------------------
      foreign |
      Foreign | 2088.167 2351.846 0.89 0.378 -2614.64 6790.974
      |
      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#rep78 |
      Foreign#1 | 0 (empty)
      Foreign#2 | 0 (empty)
      Foreign#3 | -3866.574 2980.505 -1.30 0.199 -9826.462 2093.314
      Foreign#4 | -1708.278 2746.365 -0.62 0.536 -7199.973 3783.418
      Foreign#5 | 0 (omitted)
      |
      _cons | 4564.5 2127.325 2.15 0.036 310.651 8818.349
      -------------------------------------------------------------------------------
      
      . test 1.foreign#3.rep78=1.foreign#4.rep78
      
      ( 1) 1.foreign#3.rep78 - 1.foreign#4.rep78 = 0
      
      F( 1, 61) = 0.87
      Prob > F = 0.3550
      By the way, launching:
      Code:
      regress WageHour i.Var1##i.Var2
      you would actually obtain the result of a different regression model.
      thank you for the answer

      do you know, how can i place it in tables?

      i know how the commands forv, foreach, tokenize and else and i know how to build matrices. but i dont know how to combine it with t tests

      Comment


      • #4
        Peter:
        you may want to take a look at -search outreg-.
        As an aside, quoting its -help- file
        test performs Wald tests of simple and composite linear hypotheses about the parameters of the most recently fit model.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X