Announcement

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

  • How to compare effect independent variable over 2 periods?

    Dear Statalist,

    For my thesis I examine the effect of producing renewable energy on firms in the energy sector. In this, I want to compare the effect of the independent variable Renewable Generation between period 1 (2002-2010) and period 2 (2011-2018). My dependent var is a firms' equity beta and a control variable is firm size. How can I best formulate the appropriate model? I am using a fixed-effects model, but I am really interested in the appropriate way to formulate the right model.

    I thought about this, but I am not that skilled in statistics and therefore I have doubts:

    Beta = b0 + b1ReGen*period1 + b2ReGen*period2 + b3Firmsize*period1 + b4Firmsize*period2 + error

    I have also tried to just have ReGen instead of ReGen*period1, separate regressions for each period and to have my control variable as just firm size without the period interaction, but all models yield different answers. Can someone help me understand this and point me in the right direction for the appropriate model?

    (I hope I don't break some rules with this question.)

    Thanks in advance!

    Yours sincerely,

    Julian

  • #2
    Julian:
    the main issue here seems to rest on creating a two-level categorical variable (let's call it -period-) that includes both the current -period1- and -period2-.
    Then you may code something like (assuming that -ReGen- is continuous:
    Code:
    xtset firms year
    xtreg <depvar> c.ReGen##i.period c.Firmsize##i.period, fe
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thank you for your responds! What I understand from the code is that this makes an interaction between ReGen/Firmsize and the periodIn the period variable. I assume that it has the value 1 for period 1 and 2 for period 2? Do I have to include the ' normal' ReGen variable too? Also what is the difference between this and regressing the periods apart from each other? (I think all periods in one formula is better for estimating the standard error, but I don't know other differences and when I try to regress the periods separately the outcomes are very different.)
      Does this also work when:
      1. An industry variable that has 3 different outcomes is used instead of the period variable?
      2. when I want to see if a firm with its HQ in Europe has more pronounced outcomes, can I use an EU dummy instead of the period variable?
      3. When I want to split my sample in quantiles based on Firmsize, can i use the quantile variable instead of the period?
      I think the logic behind these 3 additional points is the same as with the period, but a confirmation would be welcome!

      Sorry for asking so many questions, I am just very curious about statistics but can't seem to find suitable explanations.

      Thank you very much for your time and effort!

      Kind regards,
      Julian

      Comment


      • #4
        Julian:
        1) It's a good habit to start from 0 (and not from 1) when you number different level of the same categorical variable (anyway, Stata will renumber them according to this approach).
        2) I'm not sure with what you man by "normal" ReGen. If my guess is correct, I think you mean the so called main conditional effect of that preedictor, which is included via ## notation.
        3) the difference between running one regression with two time period instead of two regression with one time period each, is that in the first case you have one intercept only (even though with -xtreg,fe- the intercept is immaterial: https://www.stata.com/support/faqs/s...effects-model/). More substantively, in yiur case you can test whether the two periods play any role (when adjusted for othere predictors) in exaplining variation in the regressand;
        4) the logic behind your possible categorical variables 1. and 2. is the same as with period. Quantiles can be more problematic as it is always the case when you categorize a continuous predictor.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hi Carlo,

          Thanks again for answering! I didn't know that a catergorical variable was the same as a dummy, so I'll use the 0 and 1 instead of 1 and 2. Do you know how I can interpret the outcomes of these regressions, and specially the ReGen*Period2? Is it like Regen (without an interaction) is the average change in Beta for firms in period1 for a 1 unit increase in ReGen and ReGen*Period is the incremental change in Beta for firms in period2 for a 1 unit increase in ReGen compared to period1?
          Also, could I modify this with including a Firmsize*Period to also see if Firmsize behaves differently in period 2 as opposed to period 1? Or does this affect the outcome of the other variables?

          For the quantiles: I have a variable that gives the lowest 33% of firms a 1, between 33-66% a 2 and above 66% a 3. Can't I use this to do the same as with Period here? The reason I want to examine these quantiles is because Firmsize seems to influence all my other variables very much (In that including this makes all other variables insignificant in this and other models I have with more control variables) and I want to investigate this.

          Sorry if I take up much of your time, but you are being very helpful to me! Also, happy easter!

          Kind regards,
          Julian

          Comment


          • #6
            Julian:
            let's skim through your questions:
            1) interaction. The best way to tame this beast is using a toy-example:
            Code:
            . use "https://www.stata-press.com/data/r16/nlswork.dta"
            (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
            
            . xtreg ln_wage i.race##c.age, fe
            note: 2.race omitted because of collinearity
            note: 3.race omitted because of collinearity
            
            Fixed-effects (within) regression               Number of obs     =     28,510
            Group variable: idcode                          Number of groups  =      4,710
            
            R-sq:                                           Obs per group:
                 within  = 0.1029                                         min =          1
                 between = 0.0592                                         avg =        6.1
                 overall = 0.0571                                         max =         15
            
                                                            F(3,23797)        =     909.93
            corr(u_i, Xb)  = -0.0287                        Prob > F          =     0.0000
            
            ------------------------------------------------------------------------------
                 ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                    race |
                  black  |          0  (omitted)
                  other  |          0  (omitted)
                         |
                     age |   .0176492   .0004093    43.12   0.000     .0168469    .0184516
                         |
              race#c.age |
                  black  |    .001983   .0007852     2.53   0.012     .0004438    .0035221
                  other  |  -.0050728   .0035945    -1.41   0.158    -.0121182    .0019726
                         |
                   _cons |   1.147786   .0102609   111.86   0.000     1.127674    1.167898
            -------------+----------------------------------------------------------------
                 sigma_u |  .41178331
                 sigma_e |   .3034504
                     rho |  .64806813   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            F test that all u_i=0: F(4709, 23797) = 8.56                 Prob > F = 0.0000
            
            . predict fitted, xb
            (24 missing values generated)
            The coefficient for -age- relates to the -white- level of the categorical variable -race-:
            Code:
            . list idcode race age fitted if _n==40
            
                   +---------------------------------+
                   | idcode    race   age     fitted |
                   |---------------------------------|
               40. |      4   white    24   1.571368 |
                   +---------------------------------+
            
            . di 1.147786+(.0176492)* 24
            1.5713668
            To see the interaction in action:
            Code:
            . list idcode race age fitted in 1/3
            
                 +---------------------------------+
                 | idcode    race   age     fitted |
                 |---------------------------------|
              1. |      1   black    18   1.501166 |
              2. |      1   black    19   1.520798 |
              3. |      1   black    20    1.54043 |
                 +---------------------------------+
            
            . di 1.147786+(.0176492+ .001983)*18
            1.5011656
            
            . di 1.147786+(.0176492+.001983)* 19
            1.5207978
            
            . di 1.147786+(.0176492+.001983)* 20
            1.54043
            The interaction coefficient for -black- race interacted with -age- sums up with the coefficient for -age- (see between brackets).

            To get how interaction works, I find often useful to ask Stata to provide the fitted values of the regression and then re-calculate them by hand for a small set of observations (like in the toy-example above.

            I would advise you to run:
            Code:
             
             xtset firms year xtreg <depvar> c.ReGen##i.period c.Firmsize##i.period, fe
            calculate the fitted values and then re-calculate them by hand and see if the latter overlap.

            2) as far as your quantile variable is concerned, yess you can add it among the set of predictors as a categorical variable.

            Happy Easter to you and your Dears, too.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Hi Carlo,

              Wow many thanks to you! This explains it perfectly and helps me tremendously. The example is a level-3 (i think its called this) categorical variable so this works also if I have a sort-of-dummy variable with 3 possible answers. That is perfect!

              I am going to run these regressions now and see if everything works fine.

              Thank you very much!

              Kind regards,
              Julian

              Comment


              • #8
                Hi Carlo,

                I have another question: If the interaction variable (lets say the ' race#c.age other' from your example) is insignificant. Can I interpret this as that the race: other causes no change in effect on age compared to race: white?
                Also: what is the interpretation when the interaction (like race:black and age) is significant but age only is not?

                Thanks in advance!

                Kind regards,
                Julian
                Last edited by Julian Neijzen; 12 Apr 2020, 10:29.

                Comment


                • #9
                  Julian:
                  1) it means that there's no evidence that the -other- level of the categorical variable -race- affects -age-;
                  2) it means that there's no evidence that the -white- level (ie, the reference category) of the categorical variable -race- affects -age-, wheras the opposite holds for the -black- level of the categorical variable -race-.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Hi Carlo,

                    At risk of spamming you senseless, am I interpreting it right that in the screenshot of stata; 'regen' is for period =0, period (I don't know why there is a 1 before the word) is period=0 and regen=0, and 'period# c.regen' 1 is change in regen when period = 1? I am confused as why the 1 is behind the regen in the interaction, because it seems like it could be that it is meant that a change of 1 in regen changes period by an X amount.

                    I am sorry for the endless stream of questions.

                    Kind regards,

                    Julian
                    Attached Files
                    Last edited by Julian Neijzen; 12 Apr 2020, 11:02.

                    Comment


                    • #11
                      Julian:
                      if you re-run your code adding -allbase- after -robust-, everything will be clearer.
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment


                      • #12
                        Thank you!

                        Comment


                        • #13
                          Hi Carlo,

                          I have one more question if u have a little time for me.
                          When I use:

                          xtreg <depvar> c.ReGen##i.period Firmsize, fe

                          What is the exact specified model that I am using? is it: <depvar> = b0 + b1ReGen + b2Period + b3ReGen*Period + b4Firmsize + error? And does this formula change if period was a categorical variable with 3 values (0, 1 or 2)? So b3ReGen*Period=1 + b4ReGen*Period=2?

                          I look forward to your answer.

                          Kind regards,
                          Julian
                          Last edited by Julian Neijzen; 15 Apr 2020, 03:46.

                          Comment


                          • #14
                            Julian:
                            1) you are actually coding:
                            Code:
                            xtreg <depvar> =b0 + b1ReGen + b2Period + b3ReGen*Period + b4Firmsize + error
                            2) no, the code does not change.
                            Kind regards,
                            Carlo
                            (Stata 19.0)

                            Comment


                            • #15
                              Hi Carlo,

                              Thank you for your quick answer!

                              Kind regards,

                              Julian

                              Comment

                              Working...
                              X