Announcement

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

  • Regression with Indicator Function splitting Independent Variable into 2 Subgroups

    Hi All,

    I'm working on trying to get the results from the following regression which is a formula used in previous research;

    Rt = β0 +β11(rt > 0)rt +β21(rt < 0)rt +t

    where 1(·) is an indicator function to differentiate between positive and negative changes in rt

    However I'm struggling because trying to use STATA's indicator function only supports dummy variables and that is not what I am trying to achieve as the rt does not only have a value of 1 or 0.
    I have also split up the variable rt into 2 variables depending on if rt <0 or >0 but when I try to regress Rt on these 2 variables there are no overlapping observations so the regress function does not work.

    Would you have any advice on how to run the regression above?

    Many thanks,
    Joris

  • #2
    You do not show us the code you used, which makes answering your question more difficult.

    I am guessing that to split your rt variable you used the code
    Code:
    generate rt_p = rt if rt>0
    generate rt_n = rt if rt<0
    which leaves missing values rather than zeroes when the condition is not fulfilled.

    Try instead
    Code:
    generate rt_p = cond(rt>=0,rt,0)
    generate rt_n = cond(rt<0,rt,0)
    Or perhaps something like this, using an indicator variable and factor variable notation for interaction.
    Code:
    generate pn = cond(rt>=0,1,2)
    regress Rt = i.pn#c.rt t
    Last edited by William Lisowski; 27 Sep 2020, 16:58.

    Comment


    • #3
      Thank you William,

      That is indeed the case. My concern with filling in the missing values with zero's was that I thought it could affect the outcome of the coeffiecients when I run the regression since it is not "ignoring" that variable when the condition of < 0 or > 0 is met but regressing it on the value of zero.

      However now typing this out I see how that might be nonsensical.
      Thank you again, I will try both your suggestions.

      Best,
      Joris

      Comment


      • #4
        William clearly has psychic powers as he was able to figure out what is going on based on your confusing and confused initial post.

        1. Stata does not have an indicator function as such, and it was not clear at all what you were referring to.

        2. An indicator function takes the value of 1 when something belongs to a specified set, and 0 otherwise. Hence indeed your concern was misplaced--an indicator function does not return missings, it returns either 1 or 0. Therefore you are not "filling in the missing values with zeros", these values are supposed to be 0s in the first place when the something does not belong to the set.

        3. What William does with the dummy variables can be more directly done as
        Code:
        generate rt_p = rt>=0
        generate rt_n = rt<0
        that is Stata understands logical conditions, and evaluates them to 1 if True and 0 if False. One might say that this is Stata's indicator function.






        Originally posted by Joris Jager View Post
        Thank you William,

        That is indeed the case. My concern with filling in the missing values with zero's was that I thought it could affect the outcome of the coeffiecients when I run the regression since it is not "ignoring" that variable when the condition of < 0 or > 0 is met but regressing it on the value of zero.

        However now typing this out I see how that might be nonsensical.
        Thank you again, I will try both your suggestions.

        Best,
        Joris

        Comment

        Working...
        X