Announcement

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

  • Interaction terms

    Dear all I have a question about including interaction terms in a regression model.

    I am using panel data at the intra household level. The data is collected for three rounds so time period is 3 and the panels are the individuals within the household. I want to see the impact of droughts, floods and price on individual food consumption.
    Dependent variable = Consumption
    Time variable=Round
    Panel Variable = Individual within House_no
    Explanatory variables = Literacy Drought Flood and Price

    I have an additional variable "member" that identifies different family members namely boys, gorls, men, women, elderly men and elderly women.

    For this I run a regression where the dependent variable is food consumption of individuals. As explanatory variables I include Literacy, Price and dummy variables for Droughts and Floods. Food consumption, and literacy vary across individuals however the dummies for Droughts, Flood and Price vary at the household level (not at the individual level).

    Since I want to see the impact of Droughts, Flood and Price on intra household consumption I want to include them only as interactions with the member variables. I try the below specification.


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(House_no Individual) float(Literacy member Round Consumption) double(Drought Flood) float Price
    1 1 0 1 1 4.0661736 1 0  5.467961
    1 2 0 2 1 3.4420195 1 0  5.467961
    1 3 0 1 1 3.8694634 1 0  5.467961
    1 4 0 1 1  4.101265 1 0  5.467961
    2 1 0 1 1  2.995732 0 1 4.4532146
    2 2 0 2 1  2.995732 0 1 4.4532146
    2 3 0 1 1  2.995732 0 1 4.4532146
    3 1 0 1 1  2.995732 0 0  5.170106
    3 2 0 2 1 3.7297015 0 0  5.170106
    3 3 0 1 1 4.4228487 0 0  5.170106
    3 4 0 2 1  2.995732 0 0  5.170106
    4 1 0 1 1 4.2158246 0 0 4.5442963
    4 2 0 1 1  4.002031 0 0 4.5442963
    4 3 0 1 1  4.394449 0 0 4.5442963
    4 4 0 6 1 4.2158246 0 0 4.5442963
    5 1 0 1 1  5.622105 0 1  5.041504
    5 2 0 2 1  5.139253 0 1  5.041504
    5 3 0 2 1  5.485529 0 1  5.041504
    5 4 0 3 1  5.485529 0 1  5.041504
    6 1 0 1 1  5.198234 0 0 4.4584827
    6 3 0 3 1  4.910552 0 0 4.4584827
    6 4 0 3 1  4.505087 0 0 4.4584827
    7 1 0 1 1  5.039147 0 0  4.251332
    8 1 0 5 1 4.0964584 0 0 4.1943393
    8 2 0 2 1  4.473143 0 0 4.1943393
    8 3 0 4 1 4.0008264 0 0 4.1943393
    8 4 0 2 1 3.5943055 0 0 4.1943393
    9 1 0 1 1 4.7285824 0 1 4.5547814
    9 2 0 2 1  4.437426 0 1 4.5547814
    9 3 0 4 1  4.437426 0 1 4.5547814
    9 4 0 3 1 4.3150067 0 1 4.5547814
    9 5 1 6 1  4.394189 0 1 4.5547814
    1 1 0 1 2  5.115996 0 0  5.467961
    1 2 0 2 2  5.115996 0 0  5.467961
    1 3 0 3 2  5.039147 0 0  5.467961
    1 4 0 1 2  5.115996 0 0  5.467961
    2 1 0 1 2 4.1967425 0 0  5.045644
    2 2 0 2 2 4.1967425 0 0  5.045644
    2 3 0 1 2  4.215394 0 0  5.045644
    3 1 0 1 2  4.185422 0 0  5.026363
    3 2 0 2 2  4.156924 0 0  5.026363
    3 3 0 1 2  2.995732 0 0  5.026363
    4 1 0 1 2 4.3780656 0 1  5.226694
    4 2 0 1 2 4.3780656 0 1  5.226694
    4 3 0 3 2  5.039147 0 1  5.226694
    4 4 0 6 2  4.387086 0 1  5.226694
    4 5 1 2 2 4.3848567 0 1  5.226694
    5 1 0 1 2 4.0554314 0 0  5.585279
    5 2 0 2 2 3.9633164 0 0  5.585279
    5 3 0 2 2 3.9763885 0 0  5.585279
    5 4 0 1 2  4.002031 0 0  5.585279
    6 1 0 1 2  5.034825 1 1 4.7509837
    6 2 0 2 2  4.857273 1 1 4.7509837
    6 3 0 3 2  5.039147 1 1 4.7509837
    6 4 0 3 2  4.857273 1 1 4.7509837
    6 6 1 3 2  4.857273 1 1 4.7509837
    7 1 0 1 2   4.59522 0 0  5.191849
    7 2 0 2 2   4.59522 0 0  5.191849
    7 4 0 1 2  3.902073 0 0  5.191849
    8 1 0 5 2  4.473143 0 0  5.517803
    8 2 0 2 2 4.0008264 0 0  5.517803
    8 3 0 4 2  3.499627 0 0  5.517803
    8 4 0 2 2 3.5943055 0 0  5.517803
    9 5 1 1 2  4.473143 0 0 4.6879663
    1 1 0 5 3  5.039147 0 0  4.888159
    1 2 0 2 3  4.791809 0 0  4.888159
    1 3 0 4 3  5.039147 0 0  4.888159
    1 4 0 1 3  4.985965 0 0  4.888159
    2 1 0 1 3  4.824568 1 0  4.783557
    2 2 0 2 3  4.710537 1 0  4.783557
    2 3 0 1 3   4.53605 1 0  4.783557
    2 4 0 3 3 4.2909274 1 0  4.783557
    3 1 0 1 3  4.104698 1 1  5.346228
    3 2 0 2 3  4.014138 1 1  5.346228
    3 3 0 5 3  4.002031 1 1  5.346228
    3 4 0 6 3  4.394449 1 1  5.346228
    4 1 0 1 3   4.67418 1 0  4.550129
    4 2 0 1 3  4.632998 1 0  4.550129
    4 3 0 1 3  4.696973 1 0  4.550129
    4 4 0 4 3  5.039147 1 0  4.550129
    4 5 1 2 3  4.505028 1 0  4.550129
    5 1 0 5 3  4.465908 0 0  4.947703
    5 2 0 2 3  4.394449 0 0  4.947703
    5 3 0 2 3 4.2801323 0 0  4.947703
    5 4 0 1 3 4.2158246 0 0  4.947703
    6 1 0 1 3  4.004663 0 1  4.780981
    6 2 0 2 3 4.2336717 0 1  4.780981
    6 3 0 1 3  5.039147 0 1  4.780981
    6 4 0 3 3  3.764837 0 1  4.780981
    6 5 1 3 3  3.461456 0 1  4.780981
    6 6 1 3 3  3.764837 0 1  4.780981
    7 1 0 1 3  4.739899 1 1  4.861855
    7 2 0 2 3   4.59027 1 1  4.861855
    7 3 0 3 3  4.565402 1 1  4.861855
    7 4 0 5 3  4.473143 1 1  4.861855
    7 6 1 5 3  4.706102 1 1  4.861855
    8 1 0 5 3 4.0732913 1 0  5.079934
    8 2 0 2 3  4.049575 1 0  5.079934
    8 3 0 2 3 4.0964584 1 0  5.079934
    8 4 0 2 3 4.0732913 1 0  5.079934
    end
    egen group= group(House_no Individual), label
    xtset group Round
    xtreg Consumption Literacy i.Drought#i.member i.Flood#i.member c.Price#i.member i.Round , fe

    [/CODE]


    I expect the interaction terms to give me results for the member variable when Droughts and Floods take the value 1. However the results are confusing as i get the estimates even when the dummy variables are equal to 0.
    Any advice would be appreciated as to what i am doing wrong





  • #2
    Shailaja:
    your code, whose results are really difficult to disseminate due to tons of interactions, should have been written:
    Code:
    xtreg Consumption Literacy i.Drought##i.member i.Flood##i.member c.Price##i.member i.Round , fe
    That said:
    1) if individuals are nested within houses, why not considering -mixed-?
    2) you seem to have little within-panel variation in your dataset
    Code:
    . bysort House_no: xtsum Consumption
    , and it does not help the -fe- machinery (hence, interacting with -member- is probably unhelpful);
    3) if you created a composite panelvar to avoid -repeated time values within panel- error message, you can simply -xtset- your dataset with individual as panelvar, provided that you do not plan to use time-series operators, such as lags and leads in your regression.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo Lazzaro thank you for your reply. Your observation is indeed correct. I am running xtmixed after comparing it with a pooled OLS and the FE specifications as my final specification. I ommited to mention it as i was not able to capture the hierarchal structure of the data in dataex. The dataset has around 66000 observations.

      Code:
       
       xtreg Consumption Literacy i.Drought##i.member i.Flood##i.member c.Price##i.member i.Round , fe
      The above code includes member, Price, drought and flood in levels as well as their interactions. Can I include only the interactions and not the variables in the levels?




      Comment


      • #4
        Shailaja:
        -xtreg, mle and -mixed- (that replaced -xtmixed- from Stata 13 onward. BTW: if you're using a Stata release older than 17 you're kindly requested to mention it in your posts, for reasond that are well explained in the FAQ. Thanks) are close cousins.
        Therefore, if -re- is the way to go and you switch to -fe-, other things being equal your estimates will still be consistent but inefficient, because the -fe- estimator calculates the standard errors based on within-panel variation only, whereas the -re- one uses a mix of between- and within-panel variation for the same goal.
        In fact, I do not see how -fe- could ever be a reliable test for the robustness (BTW robustness vs. what?) of your -mixed- regression.
        As far as your last question is concerned (and provided that I would not sponsor going -fe- there), I would type:
        Code:
        xtreg Consumption Literacy i.Drought##i.member i.Flood##i.member c.Price##i.member i.Round , fe vce(cluster panelid)
        Finally, I would be much more concerned about endogeneity (other things being equal, more educated individuals may have a higher level of consumption, but a lower level of consumption may mean that a share of the household's disposable income is devoted to the education of the family members (a sort of reverse causation-led endogeneity); disposable income may affect both the regressand (consumption; other things being equal, a higher disposable income may mean higher level of consumption) and one of the predictor (literacy; other things being equal, a higher disposable income may mean a higher level of literacy shared by all the family members; the latetr is an example of latent variable-led endogeneity) and the correctness of the functional form of the regressand.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Dear Carlo Lazzaro thank you for your reply.
          Is it possible to specify interactions without including the level variable in the model.


          Code:
           
           xtreg Consumption Literacy i.Drought##i.member i.Flood##i.member c.Price##i.member i.Round , fe vce(cluster panelid)
          When I run the above code I get estimates of Member, Droughts, Floods , Price as well as their interactions. Could I specify only the interaction terms but omit the level variable?




          Comment


          • #6
            Shailaja:
            in a fewcases (and I do not think yours is one of them) you can include the interaction only (say, i.Drought#i.member) and exlude their conditional main effec (say, i.Drought##i.member).
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Dear Carlo
              If I understand correctly you suggest that I should include Member, Droughts, Floods and Prices in their levels as well as their interactions with the member variable. Instead of includeing only th interaction terms

              Also if I include say, i.Drought#i.member, in the model (Without the level effects of member and drought) then what is the base? Should I not get estimates of all the member variables only at Drought =1?

              Comment


              • #8
                Shailaja:
                your interpretation of my previous reply id correct.
                To get the big picture of the interactions coefficients just type:
                Code:
                mat list e(b)
                after -xtreg-.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Dear Carlo Lazzaro Thank you for your reply.

                  I am wondering that when i run the below regression the interactions of Flood with the member variable get dropped. I understand that these are collinear, but with which variable are they collinear?
                  Is there any way of locating this?

                  Code:
                  xtreg Consumption Literacy i.Drought#i.member i.Flood#i.member c.Price#i.member i.Round , fe
                  Code:
                                     
                  Consumption       Coef.    Std. Err.        t    P>t        [95% Conf. Interval]
                                          
                  Literacy           0    (omitted)
                  
                  Drought#member 
                  0 2     1.339205    3.189727        0.42   0.677        -5.129861    7.808271
                  0 3    -4.348433    6.855958        0.63   0.530        -18.25296    9.556093
                  0 4     1.510325    4.129051        0.37   0.717        -6.863779     9.88443
                  0 5     -1.81835    4.008827        0.45   0.653        -9.948629    6.311929
                  0 6    -2.418543    2.486668        0.97   0.337        -7.461741    2.624654
                  1 1     .2643756    .2844707        0.93   0.359        -.3125577     .841309
                  1 2     1.453114    3.185641        0.46   0.651        -5.007666    7.913894
                  1 3    -3.964312    6.811895        0.58   0.564        -17.77947    9.850851
                  1 4     1.494658    3.820859        0.39   0.698        -6.254403    9.243718
                  1 5    -2.039735    4.023375        0.51   0.615        -10.19952    6.120047
                  1 6    -.4693677    3.315357        0.14   0.888        -7.193223    6.254487
                  
                  Flood#member 
                  0 2    -.2692621    .3432208        0.78   0.438        -.9653461    .4268218
                  0 3     .4286872    .6571917        0.65   0.518        -.9041595    1.761534
                  0 4            0    (omitted)
                  0 5    -.8066695    1.139007        0.71   0.483        -3.116683    1.503344
                  0 6     .2272755    .9313991        0.24   0.809        -1.661689     2.11624
                  1 1    -.0915907    .2738786        0.33   0.740        -.6470423    .4638609
                  1 2            0    (omitted)
                  1 3            0    (omitted)
                  1 4            0    (omitted)
                  1 5            0    (omitted)
                  1 6            0    (omitted)
                  
                  member#c.Price 
                  1    -.5840754    .5306552        1.10   0.278        -1.660294    .4921432
                  2    -.5236445    .4359917        1.20   0.238        -1.407877    .3605875
                  3     .3871072    1.421937        0.27   0.787        -2.496715     3.27093
                  4    -.6798342    .7037586        0.97   0.340        -2.107123    .7474543
                  5    -.0964239    .6803675        0.14   0.888        -1.476273    1.283425
                  6            0    (omitted)
                  
                  Round 
                  2     .3985368    .2852662        1.40   0.171        -.1800099    .9770835
                  3     .2307299    .2376519        0.97   0.338        -.2512505    .7127103
                  
                  _cons    6.387753    2.63724        2.42   0.021        1.039182    11.73632
                                          
                  sigma_u   .80438482
                  sigma_e   .62694793
                  rho   .62208997    (fraction    of    variance due    to    u_i)
                                          
                  F test that all    u_i=0: F(40,    36) = 0.87                Prob > F = 0.6657
                  Thank you.

                  Comment


                  • #10
                    Shailaja:
                    they might be collinear with the fixed effect,
                    In addition, and more relevant, Prob > F = 0.6657 shows no evidence of a panel-wise effect.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      Dear Carlo Lazzaro I have been able to post only 100 observations of my data. I get Prob > F = 0.0000 when I run the command on the entire data set.

                      Comment


                      • #12
                        Shailaja:
                        they might be collinear with the fixed effect,
                        In addition, and more relevant, Prob > F = 0.0000 shows clear evidence of a panel-wise effect.
                        Kind regards,
                        Carlo
                        (Stata 19.0)

                        Comment


                        • #13
                          Dear Carlo Lazzaro thank you for your input. Still trying to figure out why the values get dropped.
                          if i estimate
                          Code:
                          xtreg Consumption Literacy i.Flood#i.member c.Price#i.member i.Round , fe
                          instead of
                          Code:
                           xtreg Consumption Literacy i.Drought#i.member i.Flood#i.member c.Price#i.member i.Round , fe
                          then the interactions of Flood with the member variable do not get dropped.

                          Comment


                          • #14
                            Shailaja:
                            the main issue here is not what get dropped or not, but the consistency with the literature in your research field as far as the right-hand side of your regression equation is concerned.
                            Kind regards,
                            Carlo
                            (Stata 19.0)

                            Comment


                            • #15
                              Dear Carlo Lazzaro thank you again for your reply.
                              Indeed I agree with your point.
                              My main objective is to see the impact of droughts and floods on intra household consumption. To do so I classify household members into six categories (boys, girls, men, women, elderly males and elderly females) and include it in the regression along with droughts and floods. In addition to see how the impact of droughts and floods varies across different members I interact them with the member variable.

                              Running the margin command post the regression should provide the total impact of droughts and floods
                              Code:
                              margins, dydx(Droughts) at(member=(1(1)6))

                              Comment

                              Working...
                              X