Announcement

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

  • Testing whether the coefficient of an independent variable is significantly different between two regression models

    Hi everyone,

    I am trying to find whether the coefficient of an independent variable (MA_SCORE_2018) is significantly different across two regression models. The models are essentially the same in terms of the dependent and independent variables, its just ran across two different samples. These subsamples are identified through two dummy variables, standardized and differentiated and the dataset is quite large (almost 200k observations).

    dataex example:
    Example generated by -dataex-. To install: ssc install dataex
    clear
    input double year long gvkey float tp_w double MA_SCORE_2018_w float(cash_ratio_w size_w rnd_sales_w roa_w lev_w capex_ratio_w differentiated standardized)
    1984 1001 .16448416 .1674201 .04881047 2.7891386 . .19720908 .2937235 .2264019 0 0
    1985 1001 .16208425 .0530939 .04273959 3.676174 0 .1834916 .5125712 .05079124 0 0
    1983 1003 .05230842 .048832 .23719077 2.1434722 . .25067416 .14069645 .017118068 0 0
    1984 1003 .03848721 .0081078 .03239898 2.1091218 . .10010921 .11527728 .03664604 0 0
    1986 1003 .06642607 .0695462 .016522693 2.680062 . .168792 .2579871 .03757027 0 0
    1987 1003 .02999958 .1106393 .029609775 2.7752104 . .006919337 .3433487 .03260192 0 0
    1988 1003 .13862799 .0730525 .018550368 2.789937 . -.22604422 .4748157 .018181818 0 0
    1989 1003 .2012118 .0283304 . 2.313426 . -.15154813 .4476209 .00672668 0 0
    1980 1004 .0923132 -.0183764 .036521215 4.419744 . .13310863 .467108 .02721637 0 0
    1981 1004 .1107164 -.0333748 .015388947 4.73315 . .1113213 .3832191 .02192639 0 0
    1982 1004 .1341084 -.0341477 .008967724 4.7121215 . .11837754 .3120642 .027190713 0 0
    1983 1004 .1629975 -.0444578 .008766432 4.921644 . .11082286 .11526802 .03872387 0 0
    1984 1004 .12026577 -.0505183 .0143303 5.046035 . .13769184 .18887423 .03942602 0 0
    1985 1004 .131641 -.0110314 .017797435 5.289715 . .13758844 .2869578 .04037078 0 0
    1986 1004 .11912672 -.0288378 .01109783 5.459973 . .14524163 .20540556 .04546325 0 0
    1987 1004 .12470282 -.0385843 . 5.652307 . .14270324 .2549553 .03254629 0 0
    1988 1004 .11895821 -.0431447 .012808966 5.876029 . .14324436 .26930535 .029083226 0 0
    1989 1004 .10643426 -.0293015 .010408704 5.962347 . .13907099 .2732156 .0473977 0 0
    1990 1004 .09594306 -.0577608 .004087294 5.940061 . .11042536 .22490117 .02338153 0 0
    1991 1004 .13114397 -.0493341 .005691146 5.979774 . .08774734 .23353425 .02078659 0 0
    1992 1004 .10579438 -.0543336 .006175527 5.900311 . .06367503 .25009653 .02442277 0 0
    1993 1004 .1509578 -.0513123 .04327796 6.034586 . .06969394 .27847165 .01432861 0 0
    1994 1004 .14150211 -.0827768 .05280944 6.054003 . .08164598 .28509632 .021307426 0 0
    1995 1004 .14601223 -.0793594 .07675301 6.081867 . .09719627 .27353454 .017236654 0 0
    1996 1004 .16556457 -.0692754 .09763324 6.272092 . .10418933 .2233678 .05719961 0 0
    1997 1004 .1823923 .0072931 .02568305 6.508111 . .11781066 .2650714 .026090173 0 0
    1998 1004 .17823347 -.0387679 .011353784 6.588418 . .12997536 .2495892 .04972407 0 0
    1999 1004 .12948997 -.0730754 .0016747684 6.607998 . .12015012 .27903044 .03015393 0 0
    2000 1004 .10363387 -.0696314 .01967503 6.553725 . .09170996 .2758964 .018713294 0 0
    2001 1004 .09407628 -.020128 .04860891 6.565545 . .03830898 .36641 .017054375 0 0
    2002 1004 .10364431 -.0847194 .04246011 6.531783 . .04477725 .3741715 .014462126 0 0
    2003 1004 .1100359 -.0698555 .05781822 6.564267 . .0669555 .3553656 .014501785 0 0
    2004 1004 .12875059 -.0677616 .05532141 6.596095 . .0843642 .3153435 .017799051 0 0
    2005 1004 .13777108 -.0726101 .12437233 6.886347 . .09386516 .3278083 .016648635 0 0
    2006 1004 .13168038 -.0773012 .078039 6.973199 . .11137442 .3070868 .02799745 0 0
    2007 1004 .0916583 -.0549248 .08031586 7.216717 . .12373037 .3898004 .022271495 0 0
    2008 1004 .0906213 -.089513 .08167267 7.228034 . .12056528 .3314558 .01998895 0 0
    2009 1004 .10780165 -.0799284 .0528766 7.313915 . .08950116 .29114708 .019223314 0 0
    2010 1004 .1314536 -.0529496 .03371021 7.440574 . .11522503 .26053295 .07329754 0 0
    2011 1004 .12115257 -.0370836 .03084276 7.694235 . .1014245 .360874 .04154482 0 0
    2012 1004 .08708078 -.1311681 .03523796 7.667111 . .11474566 .3316019 .017595582 0 0
    2013 1004 .10819527 -.1212202 .04055467 7.695985 . .11639009 .28824732 .012048192 0 0
    2014 1004 .10598049 -.1385657 .03610561 7.323171 . .05524752 .10165016 .030561056 0 0
    2015 1004 .1205993 -.1532222 .021635115 7.273856 . .094931 .10269745 .0612995 0 0
    2016 1004 .12469248 -.0984766 .006847949 7.31595 . .09853068 .10458081 .02233894 0 0
    2017 1004 .12029437 -.0913004 .020397455 7.329553 . .08296714 .11621959 .014429068 0 0
    1980 1005 .14479591 -.0137985 . 2.741098 . .12242002 .14247936 .16750516 1 0
    1981 1005 .11761284 -.0099996 . 3.1978564 . .13672386 .29187092 .09930556 1 0
    1980 1006 .08260663 .013385 .05983146 1.2697605 . -.308427 .036235955 .0033707866 1 0
    1981 1006 .06239303 .0113527 .016717326 1.373209 . .04812563 .005572442 .004052685 1 0
    1982 1006 .06503015 .0043919 .0453812 1.6010025 . .005849133 .08350141 .04517951 1 0
    1996 1006 . . . . . . . . . .
    1997 1006 . . . . . . . . . .
    1998 1006 . . . . . . . . . .
    2014 1006 . . . . . . . . . .
    1980 1007 .1988141 .0445193 .020836227 1.973942 . -.031809974 0 .003889429 1 0
    1981 1007 .15751144 -.0189678 .0842345 1.66222 . -.3118953 0 .010813887 1 0
    1982 1007 .24986905 -.0059622 .08365799 1.5845302 . .0014353086 0 .005126102 1 0
    1983 1007 .1999008 -.013504 .04856568 1.379773 . -.28761953 0 .0029761905 1 0
    1984 1007 .6268222 .084672 .05980448 1.2464575 . -.1627372 0 .079931 1 0
    1985 1008 .4205379 .0399167 .3316062 .830297 .4553191 -.52046674 .03626943 .006217617 1 0
    1982 1009 .10498463 -.0471618 .011561369 3.246063 . -.02471875 .6598155 .0521624 1 0
    1983 1009 .2087141 -.0528031 .02908416 2.089392 . .27889428 .7960114 .03898515 1 0
    1984 1009 .12415201 -.030711 .04059082 2.182562 . .27889428 .7358214 .19573796 1 0
    1985 1009 .10623775 .0084152 .007488862 2.3560312 . .27889428 .5620438 .1170727 1 0
    1986 1009 .09912 .0007847 .01772599 2.650421 . .27889428 .6327683 .03601695 1 0
    1987 1009 .14412823 -.0005919 .0009304782 2.853247 . .1626499 .6534248 .1944188 1 0
    1988 1009 .14951375 -.032399 .023863846 2.78606 . .23574027 .4867115 .1648887 1 0
    1989 1009 .11771304 -.0094724 .0009304782 3.261514 . .1843689 .633677 .2264019 1 0
    1990 1009 .12195998 -.0561442 .0009304782 3.47615 . .1934127 .648647 .16987784 1 0
    1991 1009 .24191046 -.0848615 .0013498692 3.571193 . .16367164 .5955454 .07666133 1 0
    1992 1009 .25650012 -.0580414 .0020011435 3.737098 . .18836954 .51465124 .11959215 1 0
    1993 1009 .1890048 -.0579758 .0080160005 4.1588364 . .1572574 .5911996 .2264019 1 0
    1994 1009 .190809 -.0825511 .0016948972 4.541282 . .13858716 .6292439 .2264019 1 0
    1980 1010 .07678463 -.1585324 .009730615 7.011654 .006284456 .153825 .3607069 .13785097 1 0
    1981 1010 .10675902 -.0951101 .009682732 7.123317 .0087680165 .13818045 .3727295 .10169206 1 0
    1982 1010 .07470114 -.068257 .010921986 7.0902 .009756465 .13259031 .3910101 .1047779 1 0
    1983 1010 .09658162 -.08896 .01236678 7.067373 .011778723 .08603808 .375305 .04338134 1 0
    1984 1010 .1269227 -.0798785 .011634152 7.059311 .00513188 .0754845 .748532 .09907162 1 0
    1985 1010 .1044029 -.024625 .010146158 7.301307 .0047806 .072458096 .7404664 .0616022 1 0
    1986 1010 .1877603 .0454888 .001353547 7.306142 .004898756 .07595641 .7721482 .06919673 1 0
    1987 1010 .8298298 -.1585324 .008570419 7.579686 .0038737126 .06478299 .6050774 .03758349 1 0
    1988 1010 .8298298 -.1585324 .01487815 7.595028 .0033678226 .06990497 .623316 .051217 1 0
    1989 1010 .6494641 -.1585324 .22938256 7.49831 .002756931 .08853184 .6786623 .08205923 1 0
    1990 1010 .8298298 -.1585324 .016428478 7.455234 .003201957 .10288116 .6556966 .0811996 1 0
    1991 1010 .069021314 -.1585324 .08478006 7.470943 .0029596405 .09886338 .6549438 .02550815 1 0
    1992 1010 .13964987 -.1585324 .04699394 7.442173 .002498844 .10159489 .6046861 .031089617 1 0
    1993 1010 .09226187 -.1585324 .007254846 7.418133 .00344403 .09035543 .4544579 .03528979 1 0
    1994 1010 .15222834 -.1585324 .03228472 7.503896 .002890933 .07547794 .4523167 .03977742 1 0
    1995 1010 .15280464 -.1585324 . 7.608771 .002701375 .07788471 .50932634 .05422165 1 0
    1996 1010 .16276477 -.1100367 . 7.704632 .0018488085 .08266474 .4888669 .05282611 1 0
    1997 1010 .14491734 -.1316998 . 8.065045 .00039848575 .05544903 .56775534 .03074215 1 0
    1998 1010 .1209753 -.1541932 . 8.088654 . .05790072 .5540171 .03122218 1 0
    1999 1010 .11319282 -.1497981 . 8.178471 . .05219734 .55483526 .05539653 1 0
    2000 1010 .16072196 -.0903859 . 8.241308 . .04709448 .5383845 .0522862 1 0
    2001 1010 .13627514 -.1352538 . 8.222312 . .04823937 .5118047 .0399667 1 0
    2002 1010 .23321554 -.1074724 . 8.2167635 . .04375422 .53172183 .029979743 1 0
    2003 1010 .08993687 -.1585324 .13464126 8.483036 . .03342232 .3849465 .046605 1 0
    1983 1011 .16236867 -.0406926 .014502026 1.5452193 . .14693965 .21603754 .2264019 0 0
    1984 1011 .1568212 -.0508412 .02601156 1.771897 . .13379803 .3356001 .2080925 0 0
    end
    [/CODE]
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 217197 observations

    Thank you in advance.

  • #2
    What you describe is a fairly common question so I link some previous answers:

    https://www.statalist.org/forums/for...o-coefficients
    https://www.statalist.org/forums/for...ent-subsamples
    https://www.stata.com/support/faqs/s...-coefficients/

    I would suggest using an interaction term.
    Best wishes

    (Stata 16.1 MP)

    Comment


    • #3
      Dear Felix Bittmann , thank you for suggesting these links.

      Is there any test that simply compares the coefficients of a particular independent variable in question, since essentially its the same data, just for two sets of samples differentiated by a dummy variable? I thought there would be simpler tests like testing means for two samples available?
      Last edited by Wali Ullah; 16 Aug 2021, 22:07.

      Comment


      • #4
        I am not aware of such a test when you need to compare coefficients, not means (then use ttest).
        However, the handling is rather simple, for example:

        Code:
        reg outcome i.groupvar##c.interestvar
        Simply looking at the interaction term tells you whether coefficients for interestvar are identical for both groups of groupvar.
        Best wishes

        (Stata 16.1 MP)

        Comment


        • #5
          Click image for larger version

Name:	scp.jpg
Views:	1
Size:	71.4 KB
ID:	1641304


          Dear Felix Bittmann , based on your suggestion, I ran the code with durable being a dummy variable that groups the two samples. Here are the results:



          Here scp is the outcome variable. My intention is to see whether the impact of MA_Score is different across the group (durable and non-durable, durable = 1 if a firm is from the durable sector goods industry). How do I intepret these results?
          Last edited by Wali Ullah; 17 Dec 2021, 01:04.

          Comment


          • #6
            Sorry for the late reply.

            You see that it is different. In durable = 0, the effect of MA is 3.3755
            In durable = 1, the effect is 3.3755 + 0.9073 = 4.2828

            That means, the effect of MA on the outcome is larger in the MA = 1 group. This difference is significant since the p value of the interaction term (0.907) is very low.
            Best wishes

            (Stata 16.1 MP)

            Comment


            • #7
              Wali:
              an useful way to get familiar with this kind of calculation, is to ask Stata to -predict- the fitted values and then re-calculate them by hand using the coefficients reported in the -regress- outcome table and the values of the predictors included in the right-hand side of your regression equation. If your calculation is correct, the results of the two approaches overlap.
              As an aside, I'm pretty confident that an inadvertent copy-and-past mishap occurred in Felix's excellent reply, as from Wali's outcome table (0.907) is actually (0.000).
              Kind regards,
              Carlo
              (StataNow 18.5)

              Comment


              • #8
                Thanks Carlo for the clarification. In parentheses I quoted the coefficient (0.907) to demonstrate which line I meant. So, to be clear, the coefficient of the interaction term is 0.907, and the corresponding p-value to this coef is 0.000.
                Best wishes

                (Stata 16.1 MP)

                Comment


                • #9
                  Felix:
                  I've found your reply absolutely clear, so that I could spot the litte ant (as we call in Italian minor, inadvertent typos, that I try, often unsuccessfully, to spot whenever I write in a hurry ).
                  All the best for the New Year and, again, congrats's on your bootstrap textbook.
                  Kind regards,
                  Carlo
                  (StataNow 18.5)

                  Comment

                  Working...
                  X