Announcement

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

  • How do I set omitted category in triple interaction?



    Dear all,
    In the example below, I am wondering how can I set the base in a triple interaction.
    I want the base to be set for g = 1.
    So 5#foreign (g#foreign#c.mpg) will show and 1#foreign(g#foreign) will be omitted.
    (Please can ignore the fact that i did not include foreign dummy---it will be absorbed in my actually regression since I will have multiple years of data and I will include make FE)
    Foreign dummy does not vary within make, but g will).
    Thanks in advance.

    sysuse auto, clear
    egen g = group(headroom)
    keep if g<6
    fvset base 1 g

    . reg price i.foreign#c.mpg i.g#i.foreign#c.mpg i.g#i.foreign, baselevels

    Source | SS df MS Number of obs = 59
    -------------+---------------------------------- F(18, 40) = 2.33
    Model | 294846920 18 16380384.5 Prob > F = 0.0130
    Residual | 281011411 40 7025285.26 R-squared = 0.5120
    -------------+---------------------------------- Adj R-squared = 0.2924
    Total | 575858331 58 9928591.91 Root MSE = 2650.5

    ---------------------------------------------------------------------------------
    price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
    foreign#c.mpg |
    Domestic | 16.5 354.1914 0.05 0.963 -699.3474 732.3474
    Foreign | -562.1875 234.2756 -2.40 0.021 -1035.676 -88.69892
    |
    g#foreign#c.mpg |
    2#Domestic | -114.286 427.3338 -0.27 0.791 -977.9597 749.3877
    2#Foreign | 484.7834 320.9415 1.51 0.139 -163.8635 1133.43
    3#Domestic | -445.2269 388.8557 -1.14 0.259 -1231.134 340.6798
    3#Foreign | 283.0711 289.9935 0.98 0.335 -303.0276 869.1697
    4#Domestic | -50.7234 447.4244 -0.11 0.910 -955.0019 853.5551
    4#Foreign | 412.4222 277.2606 1.49 0.145 -147.9422 972.7867
    5#Domestic | -1028.184 436.6764 -2.35 0.024 -1910.74 -145.6283
    5#Foreign | 0 (omitted)
    |
    g#foreign |
    1#Domestic | 0 (base)
    1#Foreign | 14285.65 10519.57 1.36 0.182 -6975.194 35546.49
    2#Domestic | 1939.09 10286.25 0.19 0.851 -18850.19 22728.37
    2#Foreign | 2858.174 10462.87 0.27 0.786 -18288.07 24004.42
    3#Domestic | 11877.21 9565.826 1.24 0.222 -7456.045 31210.46
    3#Foreign | 8372.069 9562.23 0.88 0.387 -10953.92 27698.06
    4#Domestic | 2032.944 10271.33 0.20 0.844 -18726.19 22792.08
    4#Foreign | 4782.545 9612.566 0.50 0.622 -14645.18 24210.27
    5#Domestic | 19610.01 9677.573 2.03 0.049 50.91047 39169.12
    5#Foreign | 15986.96 10231.27 1.56 0.126 -4691.205 36665.12
    |
    _cons | 4873.667 8637.236 0.56 0.576 -12582.84 22330.17
    ---------------------------------------------------------------------------------






  • #2
    Take a look at the base levels section in
    Code:
    help fvvarlist
    for an explanation of the syntax. I am not sure if
    Code:
    ib1.g
    is what you have in mind.

    Comment


    • #3
      Hi Elain,

      Please note that your font is VERY small and made it difficult to read your post.

      To your question, in general you can state the base level of an indicator/dummy variable expansion by use the ib# prefix to a categorical variable. For example:

      Code:
      sysuse auto
      regress weight c.length##ib1.foreign, base

      Comment


      • #4
        Welcome to Statalist.

        Note that your expectation that using Courier font would make your text align properly did not work out. The Statalist software squeezes out extra spaces in text that is not marked as code. And, as Matt pointed out, the Courier text was very difficult to read.

        Next time, to assure maximum readability of results that you post, don't change the default font in your post, but instead copy commands and results from the Results window or your log file into a CODE block in the Forum editor, as explained in section 12 of the Statalist FAQ linked to at the top of the page. For example, the following:

        [CODE]
        . sysuse auto, clear
        (1978 Automobile Data)

        . describe make price

        storage display value
        variable name type format label variable label
        -----------------------------------------------------------------
        make str18 %-18s Make and Model
        price int %8.0gc Price
        [/CODE]

        will be presented in the post as the following:
        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . describe make price
        
                      storage   display    value
        variable name   type    format     label      variable label
        -----------------------------------------------------------------
        make            str18   %-18s                 Make and Model
        price           int     %8.0gc                Price

        Comment


        • #5
          Dear all,
          Thanks for the replies earlier. Unfortunately, using ib1.base does not solve the problem when it is a triple interaction.
          So I am bumping the thread again.
          In the example below, I am wondering how can I set the base in a triple interaction.
          I want the base to be set for g = 1.
          So 5#foreign (g#foreign#c.mpg) will show and 1#foreign(g#foreign) will be omitted.
          (Please can ignore the fact that i did not include foreign dummy---it will be absorbed in my actually regression since I will have multiple years of data and I will include make FE)
          Foreign dummy does not vary within make, but g will).
          Thanks in advance.

          Code:
          . sysuse auto, clear
          (1978 Automobile Data)
          
          . egen g = group(headroom)
          
          . keep if g<6
          (15 observations deleted)
          
          . fvset base 1 g
          
          . reg price i.foreign#c.mpg ib1.g#i.foreign#c.mpg ib1.g#i.foreign, baselevels
          note: 5.g#1.foreign#c.mpg omitted because of collinearity
          
                Source |       SS           df       MS      Number of obs   =        59
          -------------+----------------------------------   F(18, 40)       =      2.33
                 Model |   294846920        18  16380384.5   Prob > F        =    0.0130
              Residual |   281011411        40  7025285.26   R-squared       =    0.5120
          -------------+----------------------------------   Adj R-squared   =    0.2924
                 Total |   575858331        58  9928591.91   Root MSE        =    2650.5
          
          ---------------------------------------------------------------------------------
                    price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
            foreign#c.mpg |
                Domestic  |       16.5   354.1914     0.05   0.963    -699.3474    732.3474
                 Foreign  |  -562.1875   234.2756    -2.40   0.021    -1035.676   -88.69892
                          |
          g#foreign#c.mpg |
              2#Domestic  |   -114.286   427.3338    -0.27   0.791    -977.9597    749.3877
               2#Foreign  |   484.7834   320.9415     1.51   0.139    -163.8635     1133.43
              3#Domestic  |  -445.2269   388.8557    -1.14   0.259    -1231.134    340.6798
               3#Foreign  |   283.0711   289.9935     0.98   0.335    -303.0276    869.1697
              4#Domestic  |   -50.7234   447.4244    -0.11   0.910    -955.0019    853.5551
               4#Foreign  |   412.4222   277.2606     1.49   0.145    -147.9422    972.7867
              5#Domestic  |  -1028.184   436.6764    -2.35   0.024     -1910.74   -145.6283
               5#Foreign  |          0  (omitted)
                          |
                g#foreign |
              1#Domestic  |          0  (base)
               1#Foreign  |   14285.65   10519.57     1.36   0.182    -6975.194    35546.49
              2#Domestic  |    1939.09   10286.25     0.19   0.851    -18850.19    22728.37
               2#Foreign  |   2858.174   10462.87     0.27   0.786    -18288.07    24004.42
              3#Domestic  |   11877.21   9565.826     1.24   0.222    -7456.045    31210.46
               3#Foreign  |   8372.069    9562.23     0.88   0.387    -10953.92    27698.06
              4#Domestic  |   2032.944   10271.33     0.20   0.844    -18726.19    22792.08
               4#Foreign  |   4782.545   9612.566     0.50   0.622    -14645.18    24210.27
              5#Domestic  |   19610.01   9677.573     2.03   0.049     50.91047    39169.12
               5#Foreign  |   15986.96   10231.27     1.56   0.126    -4691.205    36665.12
                          |
                    _cons |   4873.667   8637.236     0.56   0.576    -12582.84    22330.17
          ---------------------------------------------------------------------------------

          Comment


          • #6
            Hi Elain,

            I would use ## instead of # and let Stata handle the interaction expansion. I had no issues using the following code:
            Code:
            sysuse auto, clear
            egen g = group(headroom)
            keep if g<6
            
            regress price i.foreign##c.mpg##ib1.g , base

            Comment


            • #7
              We often see advice here that including interaction terms without including the main effects is inadvisable. Perhaps someone who has given that advice will explain the logic once again.

              I mention this because fitting the model including the interaction terms works as you would expect. Perhaps your problem is a consequence of your unusual parameterization.

              Code:
              . sysuse auto, clear
              (1978 Automobile Data)
              
              . egen g = group(headroom)
              
              . keep if g<6
              (15 observations deleted)
              
              . reg price i.g##i.foreign##c.mpg, baselevels
              note: 5.g#1.foreign#c.mpg omitted because of collinearity
              
                    Source |       SS           df       MS      Number of obs   =        59
              -------------+----------------------------------   F(18, 40)       =      2.33
                     Model |   294846920        18  16380384.5   Prob > F        =    0.0130
                  Residual |   281011411        40  7025285.26   R-squared       =    0.5120
              -------------+----------------------------------   Adj R-squared   =    0.2924
                     Total |   575858331        58  9928591.91   Root MSE        =    2650.5
              
              ---------------------------------------------------------------------------------
                        price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              ----------------+----------------------------------------------------------------
                            g |
                           1  |          0  (base)
                           2  |    1939.09   10286.25     0.19   0.851    -18850.19    22728.37
                           3  |   11877.21   9565.826     1.24   0.222    -7456.045    31210.46
                           4  |   2032.944   10271.33     0.20   0.844    -18726.19    22792.08
                           5  |   19610.01   9677.573     2.03   0.049     50.91047    39169.12
                              |
                      foreign |
                    Domestic  |          0  (base)
                     Foreign  |  -9362.593   8546.104    -1.10   0.280    -26634.91    7909.727
                              |
                    g#foreign |
                   2#Foreign  |   10281.68   11794.52     0.87   0.389    -13555.94    34119.29
                   3#Foreign  |   5857.452   10333.12     0.57   0.574    -15026.57    26741.48
                   4#Foreign  |   12112.19   11033.31     1.10   0.279    -10186.96    34411.34
                   5#Foreign  |   5739.536   4008.848     1.43   0.160    -2362.648    13841.72
                              |
                          mpg |       16.5   354.1914     0.05   0.963    -699.3474    732.3474
                              |
                      g#c.mpg |
                           2  |   -114.286   427.3338    -0.27   0.791    -977.9597    749.3877
                           3  |  -445.2269   388.8557    -1.14   0.259    -1231.134    340.6798
                           4  |   -50.7234   447.4244    -0.11   0.910    -955.0019    853.5551
                           5  |  -1028.184   436.6764    -2.35   0.024     -1910.74   -145.6283
                              |
                foreign#c.mpg |
                     Foreign  |   449.4968   346.5831     1.30   0.202    -250.9738    1149.967
                              |
              g#foreign#c.mpg |
                   2#Foreign  |  -429.1149    474.764    -0.90   0.371    -1388.649    530.4189
                   3#Foreign  |  -299.8864   418.4355    -0.72   0.478    -1145.576    545.8032
                   4#Foreign  |  -565.0386   465.6665    -1.21   0.232    -1506.186    376.1085
                   5#Foreign  |          0  (omitted)
                              |
                        _cons |   4873.667   8637.236     0.56   0.576    -12582.84    22330.17
              ---------------------------------------------------------------------------------

              Comment

              Working...
              X