Announcement

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

  • Joint F test on interaction effects

    Hi everyone,
    For one of my papers, I am using Oaxaca decomposition method looking at caste differences in consumption. To see whether there is evidence of differences in the effects of the determinants, we have to first run a regression of household Fruit and veg consumption (dependent variable) on the covariates interacted with the dummy variable separating low castes from high castes.

    What is the STATA code for doing the joint F test on these interaction effects after running the above regression?

    Many thanks for your help,
    Samira.

  • #2
    Samira:
    do you mean somethuing along the following lines?
    Code:
    . sysuse 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
    -------------------------------------------------------------------------------
    
    . mat list e(b)
    
    e(b)[1,18]
                 0b.           1.          1b.           2.           3.           4.           5.
            foreign      foreign        rep78        rep78        rep78        rep78        rep78
    y1            0    2088.1667            0     1403.125    2042.5741    1317.0556         -360
    
         0b.foreign#  0b.foreign#  0b.foreign#  0b.foreign#  0b.foreign#  1o.foreign#  1o.foreign#
           1b.rep78     2o.rep78     3o.rep78     4o.rep78     5o.rep78     1b.rep78     2o.rep78
    y1            0            0            0            0            0            0            0
    
          1.foreign#   1.foreign#  1o.foreign#            
            3.rep78      4.rep78     5o.rep78        _cons
    y1   -3866.5741   -1708.2778            0       4564.5
    
    . test 1o.foreign#4.rep78=1.foreign#3.rep78
    
     ( 1)  - 1.foreign#3.rep78 + 1.foreign#4.rep78 = 0
    
           F(  1,    61) =    0.87
                Prob > F =    0.3550
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Hi Carlo,
      Thanks for your response. I don't think I explained it quite clearly. I am running the following regression where I am interacting all the covariates with the low vs high castes (scheduledtribecaste).


      These are my covariates-
      logmpce logoutlierrelativeprice hh_size c0_5 educfsp - continuous variables
      femhh rural agri hindu state - dummy variables

      reg aeufruitvegg logmpce logoutlierrelativeprice hh_size c0_5 educfsp femhh rural agri hindu i.state i.scheduledtribecaste i.scheduledtribecaste#c.(logmpce logoutlierrelativeprice hh_size c0_5 educfsp) /*
      */ i.scheduledtribecaste#i.(femhh rural agri hindu state) [aw=hhwt], vce(cluster FSU_Serial_No)

      Then do a Joint F statistics for ALL interactions including the dummy on its own.

      test 1.scheduledtribecaste 1.scheduledtribecaste#c.logmpce 1.scheduledtribecaste#c.logoutlierrelativeprice 1.scheduledtribecaste#c.hh_size /*
      */ 1.scheduledtribecaste#c.c0_5 1.scheduledtribecaste#c.educfsp 1.scheduledtribecaste#i.femhh 1.scheduledtribecaste#i.rural 1.scheduledtribecaste#i.agri 1.scheduledtribecaste#i.hindu 1.scheduledtribecaste#i.state

      But now I'm getting this error "i: operator invalid".

      How do I solve this problem?

      Thanks a lot for your help,
      Samira.


      Comment


      • #4
        Samira:
        you should take the names of the coefficients from:
        Code:
        mat list e(b)
        .

        Stata assigns those name for calculation purposes and they should be used with postestimation commands such as -test-.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Thanks Carlo.

          Comment


          • #6
            I still get the same error when running test command.

            test ..... 1.scheduledtribecaste#i.rural

            rural is a dummy variable.


            Thanks for your help,
            Samira.

            Comment


            • #7
              Samira:
              in the following example I cannot reproduce your problem:
              Code:
              use "C:\Program Files (x86)\Stata15\ado\base\a\auto.dta"
              . reg 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
              -------------------------------------------------------------------------------
              
              . mat list e(b)
              
              e(b)[1,18]
                           0b.           1.          1b.           2.           3.           4.           5.
                      foreign      foreign        rep78        rep78        rep78        rep78        rep78
              y1            0    2088.1667            0     1403.125    2042.5741    1317.0556         -360
              
                   0b.foreign#  0b.foreign#  0b.foreign#  0b.foreign#  0b.foreign#  1o.foreign#  1o.foreign#
                     1b.rep78     2o.rep78     3o.rep78     4o.rep78     5o.rep78     1b.rep78     2o.rep78
              y1            0            0            0            0            0            0            0
              
                    1.foreign#   1.foreign#  1o.foreign#            
                      3.rep78      4.rep78     5o.rep78        _cons
              y1   -3866.5741   -1708.2778            0       4564.5
              
              . test 1.foreign 1b.rep78 2.rep78 3.rep78 4.rep78 5.rep78 0b.foreign#1b.rep78 0b.foreign#2o.rep78 0b.foreign#3o.rep78 0b.foreign#4o.rep78 0b.foreign#5o.rep78 1o.foreign#1b.rep78 1o.foreign#2o.rep78 1.foreign#3.rep78 1.foreign#4.rep78 1o.foreign#5o.rep78
              
               ( 1)  1.foreign = 0
               ( 2)  1b.rep78 = 0
               ( 3)  2.rep78 = 0
               ( 4)  3.rep78 = 0
               ( 5)  4.rep78 = 0
               ( 6)  5.rep78 = 0
               ( 7)  0b.foreign#1b.rep78 = 0
               ( 8)  0b.foreign#2o.rep78 = 0
               ( 9)  0b.foreign#3o.rep78 = 0
               (10)  0b.foreign#4o.rep78 = 0
               (11)  0b.foreign#5o.rep78 = 0
               (12)  1o.foreign#1b.rep78 = 0
               (13)  1o.foreign#2o.rep78 = 0
               (14)  1.foreign#3.rep78 = 0
               (15)  1.foreign#4.rep78 = 0
               (16)  1o.foreign#5o.rep78 = 0
                     Constraint 2 dropped
                     Constraint 7 dropped
                     Constraint 8 dropped
                     Constraint 9 dropped
                     Constraint 10 dropped
                     Constraint 11 dropped
                     Constraint 12 dropped
                     Constraint 13 dropped
                     Constraint 16 dropped
              
                     F(  7,    61) =    0.39
                          Prob > F =    0.9049
              
              .
              You may want to add one coefficient at time and see when -test- starts gasping.
              Kind regards,
              Carlo
              (StataNow 18.5)

              Comment


              • #8
                okay thanks a lot Carlo!

                Comment

                Working...
                X