Announcement

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

  • Indicator explanatory variable versus Continuous explanatory variable interacted with an indicator variable

    Dear Stata members

    I would like to analyze the impact of income on savings. Since income has -ve values, I would like to know the differential impact of positive income on savings. I did it in two ways which I reproduce here. Can some one help me how these two ways are different?

    Code:
    *Example generated by -dataex-. For more info, type help dataex
    clear
    input float income long hhnumber int year float savings
              .     11 2010            .
    .0014249427     11 2011    .10736633
      .05814431     11 2012    .20697367
      .16007756     11 2013    .14467306
       .1201923     11 2014   .074012294
      .08846715     11 2015     .0140146
       .0726514     11 2016    .01886307
      .12587392     11 2017   .031362336
      .15529574     11 2018    .04968848
      .13117011     11 2019    .04589479
              .    289 2012            .
       .1063842    289 2013   .003435442
     .030946124    289 2014   -.07053278
              .    414 2017            .
              0    414 2018            .
     -.08986675    414 2019 -.0012395413
              .    415 2019            .
              .    783 2009            .
       .1544692    783 2010    .05574614
      .16448955    783 2011    .23329727
      .04310995    783 2012   .017116332
     .008366819    783 2013    .11295205
      .08187293    783 2014    .05379704
     .034545954    783 2015    .05745441
      .07042769    783 2016  -.001236377
       .0776962    783 2017    .01509867
      .11298357    783 2018    .02271775
      .09131507    783 2019   .019677164
              .   1120 2007            .
      .03272315   1120 2008    .11757955
       .2311833   1120 2009    .04758122
      .11494628   1120 2010    .02424889
     .026734795   1120 2011    .06212429
      .07235114   1120 2012    .08096437
      .10919048   1120 2013    .04544359
      .24382713   1120 2014    .05932112
      .13732953   1120 2015    .08129118
       .2332194   1120 2016   .069556594
      .08239351   1120 2017   .028527016
      .09170225   1120 2018    .04272934
      .05315301   1120 2019    .05568584
              .   2248 2018            .
              .   2842 2004            .
      .18045112   2842 2005   .020050125
       .0475423   2842 2006    .07413376
      .05962521   2842 2007   .032367975
    -.016780045   2842 2008    .04761905
      .13927959   2842 2009    .07409949
      .17747824   2842 2010    .06262286
       .3720662   2842 2011    .05393836
      .04881006   2842 2012    .04502046
       .1691708   2842 2013    .02970524
     .014821677   2842 2014    .01065308
      .09043597   2842 2015   .020305434
     -.21417657   2842 2016   -.07053278
       .3086735   2842 2017   .016193435
     .001294708   2842 2018    .04612397
      .04082516   2842 2019     .0778996
              .   3335 2008            .
      .12395398   3335 2009    .11924686
     .072086036   3335 2010    .08322837
     .012931754   3335 2011    .02252628
      .28680673   3335 2012    .03773585
      .18178575   3335 2013   .066252165
       .2992557   3335 2014   .034500875
      .04853231   3335 2015    .04187429
      .14049448   3335 2016    .04302565
      .06189393   3335 2017   .019713476
       .0512839   3335 2018    .14065205
     -.08913574   3335 2019    .06144074
              .   3990 2007            .
      .07772204   3990 2008    .05997492
      .14326105   3990 2009    .04691506
      .13510633   3990 2010    .06384772
      .03748062   3990 2011    .16237624
              .   3990 2016            .
       .1584383   3990 2017    .09711757
      .05857066   3990 2018   .062575564
       .1029306   3990 2019    .04536888
              .   3998 2003            .
      .05916222   3998 2004      .155697
      .16438296   3998 2005     .1251626
      .06377295   3998 2006    .14361057
       .1018157   3998 2007    .09600664
      .01869701   3998 2008    .07013272
      .17360023   3998 2009    .07471496
      .17570733   3998 2010    .05754061
      .05002748   3998 2011    .05210307
      .08634122   3998 2012    .09458223
      .13831381   3998 2013    .13929507
      .14476629   3998 2014    .13228461
      .12714736   3998 2015    .11036541
      .19519085   3998 2016    .15307838
       .1584429   3998 2017    .17860597
      .09565893   3998 2018    .17539375
      .16764395   3998 2019      .180125
              .   4024 2019            .
              .   4030 2017            .
     -.08848921   4030 2018 -.0010791367
     -.04015908   4030 2019    .04966534
              .   4253 2003            .
       .3452001   4253 2004   .025665287
              .   4253 2006            .
              .   4253 2008            .
      .14364538   4253 2009     .3458175
      .10231846   4253 2010    .01983287
        .084929   4253 2011   -.02901434
      .06022375   4253 2012    .04102596
      .11601672   4253 2013    .05468807
       .1634769   4253 2014     .0778448
    -.032785323   4253 2015    .04615743
      .06111732   4253 2016   .003794699
      .08735888   4253 2017   .001503597
              .  15510 2005            .
              .  15510 2007            .
      .06862519  15510 2008    .04327957
      .05536599  15510 2009    .05305449
     .026251806  15510 2010    .00697699
    -.009033038  15510 2011    .01461645
      .06229695  15510 2012    .04461265
      .07001339  15510 2013    .02874017
      .04550454  15510 2014    .02309596
      .01703171  15510 2015    .01310886
       .0609783  15510 2016   .009260134
      .03541027  15510 2017    -.0377477
      .10685416  15510 2018  .0031206526
              .  15510 2019            .
              .  15646 2009            .
       .1629551  15646 2010     .4219632
    .0027040315  15646 2011    .07399213
              .  21420 2013            .
              .  23354 2001            .
      .14969166  23354 2002    .04274219
      .12502342  23354 2003    .07422638
       .1380101  23354 2004    .04490476
       .1537394  23354 2005    .14754564
       .1406326  23354 2006   .018262401
      .28050032  23354 2007     .0727332
       .3363202  23354 2008    .10305016
       .2380105  23354 2009    .21730775
      .27435163  23354 2010    .17933913
       .1882574  23354 2011    .08018815
      .12933803  23354 2012     .0367108
      .13023247  23354 2013    .04590091
       .0875644  23354 2014     .0792801
      .10940684  23354 2015    .12975203
       .1126476  23354 2016     .0865718
       .1067371  23354 2017    .03847034
        .112593  23354 2018    .03769615
      .07327507  23354 2019     .0325946
              .  23482 2015            .
     -.03725863  23482 2016    .17196487
       .0838336  23482 2017   .006330149
      .06860734  23482 2018    .07230487
      .06716071  23482 2019    .16031162
              .  35548 2010            .
      .08073009  35548 2011     .2175333
      .06489782  35548 2012    .16592413
      .03153868  35548 2013    .14124398
      .12834369  35548 2014     .1071185
      .27366617  35548 2015     .1575543
     .008280148  35548 2016    .08118208
      .18138783  35548 2017     .0983699
      .04564369  35548 2018    .08388908
       .1535621  35548 2019    .09693597
              .  36277 2019            .
              .  73119 2007            .
      -.2187101  73119 2008    .11269613
     -.08810956  73119 2009    .04728207
    -.015221082  73119 2010   .004915371
      -.1898774  73119 2011    .08920024
      .06828882  73119 2012   .012884152
      .04028456  73119 2013   .018245036
     -.09021691  73119 2014   .011943283
     -.07049803  73119 2015   .003504126
     -.05686605  73119 2016   .002715429
     -.03555109  73119 2017   .004974453
    -.020160647  73119 2018   .003349882
    -.020901645  73119 2019   .006533455
              .  78253 2007            .
      .10824244  78253 2008     .4219632
      .07220306  78253 2009     .3544374
      .05401027  78253 2010    .29174256
      .08861957  78253 2011    .29731396
      .06295991  78253 2012    .26283735
       .0724877  78253 2013    .12416243
       .0740323  78253 2014   .066596515
      .04624769  78253 2015    .04283552
      .05349103  78253 2016    .04954444
       .0869587  78253 2017    .05925526
      .07520478  78253 2018    .03266836
      .04871319  78253 2019   .004649362
              .  96387 2005            .
      .05931689  96387 2006    .18930587
      .14095491  96387 2007    .07943502
       .2139345  96387 2008     .2132215
       .2439766  96387 2009      .194736
      .08628706  96387 2010    .04191943
       .0750815  96387 2011   .016012168
    -.036328826  96387 2012   .014509422
     .012172202  96387 2013   .010469865
      .01317964  96387 2014   .006068038
              .  96387 2017            .
              .  96387 2018            .
       .0806975  96387 2019   .003180081
              . 183399 2003            .
       .1124124 183399 2004  .0030102064
      .09305374 183399 2005   .032619774
     .001790373 183399 2006     .1070643
      .07516242 183399 2007    .06367508
      .06079808 183399 2008    .04431409
      .13288586 183399 2009   .010256797
      .12886462 183399 2010  .0046243286
    -.017579628 183399 2011    .05166179
       .1762654 183399 2012    .27846223
      .07539347 183399 2013   .021887517
      .09011275 183399 2014   .010742505
      .02000759 183399 2015    .03758695
     .007259172 183399 2016  .0018883657
        .064887 183399 2017   .028821167
      .02076713 183399 2018   .005321114
      .07493762 183399 2019   .006550218
              . 271517 2008            .
              . 370768 2012            .
              . 370768 2017            .
     .029829383 370768 2018   .002499611
    -.026993506 370768 2019  -.001836474
              . 373258 2008            .
     .006679134 373258 2009  .0017098584
       .0995821 373258 2010     .1556926
      .05450929 373258 2011     .0284114
      .04182523 373258 2012  -.004090052
     .034272052 373258 2013    .03985122
       .1294517 373258 2014    .05851333
              . 389178 2011            .
    -.036407128 389178 2012     .2230384
     .008714513 389178 2013    .06719671
    -.032311615 389178 2014   .021149924
     .010369852 389178 2015 -.0008171236
    .0017769543 389178 2016  -.003356853
      .01919383 389178 2017   .002345431
      .01044142 389178 2018   .001763793
      .02649253 389178 2019  .0008395184
              . 455291 2019            .
              . 463750 2019            .
              . 528025 2016            .
       .3108932 528025 2017    .19945534
      .07746608 528025 2018     .2253392
      .11531787 528025 2019            .
              . 546359 2018            .
    end
    .
    Code:
     *Set the panel
    
    . 
    . xtset hhnumber year
    
    Panel variable: hhnumber (unbalanced)
     Time variable: year, 2001 to 2019, but with gaps
             Delta: 1 unit
    
    . 
    . 
    . 
    . *Regression 
    
    . 
    . xtreg savings income, fe vce(r)
    
    Fixed-effects (within) regression               Number of obs     =        207
    Group variable: hhnumber                        Number of groups  =         24
    
    R-squared:                                      Obs per group:
         Within  = 0.0270                                         min =          1
         Between = 0.2808                                         avg =        8.6
         Overall = 0.0651                                         max =         18
    
                                                    F(1,23)           =       3.87
    corr(u_i, Xb) = 0.1619                          Prob > F          =     0.0612
    
                                  (Std. err. adjusted for 24 clusters in hhnumber)
    ------------------------------------------------------------------------------
                 |               Robust
         savings | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
        income |   .1470432   .0747108     1.97   0.061    -.0075078    .3015943
           _cons |   .0593099   .0061843     9.59   0.000     .0465168     .072103
    -------------+----------------------------------------------------------------
         sigma_u |  .06111259
         sigma_e |  .06811295
             rho |  .44598686   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    .
    Code:
      *Regression classifying income into +ve and -ve
    . gen income_dum=.
    
    . replace income_dum=0 if income<0   // negative income
    
    . replace income_dum=1 if income>0    // 0 and positive income
    
    
    . (Method One)
    . xtreg savings i.income_dum, fe vce(r)
    
    Fixed-effects (within) regression               Number of obs     =        207
    Group variable: hhnumber                        Number of groups  =         24
    
    R-squared:                                      Obs per group:
         Within  = 0.0009                                         min =          1
         Between = 0.1890                                         avg =        8.6
         Overall = 0.0233                                         max =         18
    
                                                    F(1,23)           =       0.17
    corr(u_i, Xb) = -0.3171                         Prob > F          =     0.6849
    
                                  (Std. err. adjusted for 24 clusters in hhnumber)
    ------------------------------------------------------------------------------
                 |               Robust
         savings | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    1.income_dum |  -.0083484   .0203149    -0.41   0.685     -.050373    .0336762
           _cons |    .078862   .0179596     4.39   0.000     .0417098    .1160142
    -------------+----------------------------------------------------------------
         sigma_u |  .06702826
         sigma_e |  .06902011
             rho |  .48536236   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . Method 2
    . xtreg savings c.income##i.income_dum, fe vce(r) 
    
    Fixed-effects (within) regression               Number of obs     =        207
    Group variable: hhnumber                        Number of groups  =         24
    
    R-squared:                                      Obs per group:
         Within  = 0.0457                                         min =          1
         Between = 0.0808                                         avg =        8.6
         Overall = 0.0393                                         max =         18
    
                                                    F(3,23)           =       2.11
    corr(u_i, Xb) = 0.0044                          Prob > F          =     0.1271
    
                                         (Std. err. adjusted for 24 clusters in hhnumber)
    -------------------------------------------------------------------------------------
                        |               Robust
                savings | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    --------------------+----------------------------------------------------------------
                 income |  -.0672978   .3736112    -0.18   0.859    -.8401713    .7055758
           1.income_dum |  -.0220827   .0239208    -0.92   0.366    -.0715667    .0274013
                        |
    income_dum#c.income |
                     1  |   .2885602   .4170851     0.69   0.496    -.5742461    1.151367
                        |
                  _cons |   .0704953   .0238977     2.95   0.007     .0210591    .1199315
    --------------------+----------------------------------------------------------------
                sigma_u |  .06406465
                sigma_e |  .06782809
                    rho |  .47148914   (fraction of variance due to u_i)
    -------------------------------------------------------------------------------------
    Which one is more intutive and logical? Given these 2 context, which one should be used for further interpretation?
    If not ready-made answers, some clues in this regard can be helpful.

  • #2
    Lal:
    as -income- is a continuous variable, I would consider the following code (that searches for a possible turning point via linear + squared terms):
    Code:
    . xtreg savings c.income##c.income, fe vce(r)
    
    Fixed-effects (within) regression               Number of obs     =        207
    Group variable: hhnumber                        Number of groups  =         24
    
    R-squared:                                      Obs per group:
         Within  = 0.0287                                         min =          1
         Between = 0.2963                                         avg =        8.6
         Overall = 0.0572                                         max =         18
    
                                                    F(2,23)           =       2.32
    corr(u_i, Xb) = 0.1356                          Prob > F          =     0.1209
    
                                       (Std. err. adjusted for 24 clusters in hhnumber)
    -----------------------------------------------------------------------------------
                      |               Robust
              savings | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ------------------+----------------------------------------------------------------
               income |   .1041197   .1447039     0.72   0.479    -.1952232    .4034625
                      |
    c.income#c.income |   .2011425   .5392447     0.37   0.713    -.9143703    1.316655
                      |
                _cons |   .0598457   .0063424     9.44   0.000     .0467253     .072966
    ------------------+----------------------------------------------------------------
              sigma_u |   .0614505
              sigma_e |  .06824029
                  rho |  .44778944   (fraction of variance due to u_i)
    -----------------------------------------------------------------------------------
    
    .
    That said, I hope that you have more predictors in the right-hand side of your regression equation.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      I actually like combining indicator variables and continuous variables in this case, as lal has a substantive reason for choosing his/her indicator variable. I wrote a Stata tip on that, that you might find useful: https://journals.sagepub.com/doi/pdf...36867X20909707
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Dear Carlo Lazzaro
        Thanks for taking the time to give your insights. Based on the code you suggested, I think the interaction captures the non-linearities right? But can we have simple interpretation for that similar to the linear one (one unit increase in x corresponds....). Also, is there is some tests to check whether non-linearities exist, or on what basis will you go for a squared term?

        Finally, my post was based on some comments made by a referee in conference.Earlier I split the sample into postive and negative based on income and ran 2 seprate regressions so that I can compare the savings-income sensitivity in two groups. However, referee said this wrong (I dont know why).
        I have read a similar thread here in https://statisticalhorizons.com/asym...for-panel-data
        Asymmetric Fixed Effects Models for Panel Data. But dont know whether it must be used or not

        Comment


        • #5
          Lal:
          1) yes, the idea underlying linear+squared terms inclusion in theright-hand side of the regerssin equatioin is to search for possible non-linera relationship between regressor and regerssand;
          2) the interpretation is based on the type of turning point (if any), i.e., absolute minimum or maximum and the slope of first derivative to the right of the turning point (positive if minimum; negative if maximum);
          3) you can check the correctness of the functional form of the regressand that, under some conditions, can be considered a test of model misspecification) (see -linktest- to have an idea of the machinery):
          Code:
          . input float income long hhnumber int year float savings
          
           <snip>
          . end
          
          . xtset hhnumber year
          
          Panel variable: hhnumber (unbalanced)
           Time variable: year, 2001 to 2019, but with gaps
                   Delta: 1 unit
          
          . xtreg savings c.income##c.income, fe vce(r)
          
          Fixed-effects (within) regression               Number of obs     =        207
          Group variable: hhnumber                        Number of groups  =         24
          
          R-squared:                                      Obs per group:
               Within  = 0.0287                                         min =          1
               Between = 0.2963                                         avg =        8.6
               Overall = 0.0572                                         max =         18
          
                                                          F(2,23)           =       2.32
          corr(u_i, Xb) = 0.1356                          Prob > F          =     0.1209
          
                                             (Std. err. adjusted for 24 clusters in hhnumber)
          -----------------------------------------------------------------------------------
                            |               Robust
                    savings | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
          ------------------+----------------------------------------------------------------
                     income |   .1041197   .1447039     0.72   0.479    -.1952232    .4034625
                            |
          c.income#c.income |   .2011425   .5392447     0.37   0.713    -.9143703    1.316655
                            |
                      _cons |   .0598457   .0063424     9.44   0.000     .0467253     .072966
          ------------------+----------------------------------------------------------------
                    sigma_u |   .0614505
                    sigma_e |  .06824029
                        rho |  .44778944   (fraction of variance due to u_i)
          -----------------------------------------------------------------------------------
          
          . predict fitted, xb
          (41 missing values generated)
          
          . g sq_fitted=fitted^2
          (41 missing values generated)
          
          . xtreg savings fitted sq_fitted , fe vce(r)
          
          Fixed-effects (within) regression               Number of obs     =        207
          Group variable: hhnumber                        Number of groups  =         24
          
          R-squared:                                      Obs per group:
               Within  = 0.0369                                         min =          1
               Between = 0.2600                                         avg =        8.6
               Overall = 0.0827                                         max =         18
          
                                                          F(2,23)           =       2.45
          corr(u_i, Xb) = 0.1538                          Prob > F          =     0.1081
          
                                        (Std. err. adjusted for 24 clusters in hhnumber)
          ------------------------------------------------------------------------------
                       |               Robust
               savings | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                fitted |   5.023723   3.571151     1.41   0.173    -2.363767    12.41121
             sq_fitted |  -24.13753   20.23677    -1.19   0.245    -66.00047    17.72541
                 _cons |  -.1601648   .1497163    -1.07   0.296    -.4698765    .1495468
          -------------+----------------------------------------------------------------
               sigma_u |   .0601574
               sigma_e |  .06795007
                   rho |  .43939509   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          .
          In the abovementioned toy-example there's no evidence of model misspecification, as -sq_fitted- does not reach statistical significance.

          4) probably the referee wants to have an unique regression. If you run two different regressions, you cannot see how positive and negative -income- (when adjusted for the remaning predictors) influences the regressand.
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment


          • #6
            Dear Maarten Buis. Thanks for the comments. Hence, you suggest to go with Method2 right? The article you suggested is very important and when I glance through it I think if there is an option for centering, then continuous variable can be centered at a certain level and then interact with the indicator variable, right

            Comment


            • #7
              Thanks Carlo Lazzaro for such a detailed explanation with illustration (especially model correctness part). I am extremely grateful to you. Have a good day

              Comment

              Working...
              X