Announcement

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

  • Identifying an event within groups

    Hi!

    I have a panel (id year) data with variables including msa (categorical 1,2, 3), wm_38 (binary) , and wm_310 (binary).
    A problem is that a value of the wm_38 is not consistent in a way that in id 1. If you look at the wm_310 value over the years for id1, the value is all zero between 2004-2007 and turns on after that.
    However, the value is turned on and off for id2 between 2012 and 2014. This is the problem that I've been trying to fix. I am not able to identify a sort of consistent pattern for all ids in the data set (300k+ obs).

    Would there be a way to fix a random event across the ids and years?



    Code:
    clear
    input byte id int year byte(msa wm_38 wm_310)
    1 2004 1 0 0
    1 2005 1 0 0
    1 2006 1 0 0
    1 2007 1 0 0
    1 2008 1 0 1
    1 2009 1 0 1
    1 2010 1 0 1
    1 2011 1 0 1
    1 2012 1 0 1
    1 2013 1 0 1
    1 2014 1 0 1
    1 2015 1 0 1
    1 2016 1 0 1
    1 2017 1 0 1
    1 2018 1 0 1
    1 2019 1 0 1
    1 2020 1 0 1
    2 2004 1 0 0
    2 2005 1 0 0
    2 2006 1 0 0
    2 2007 1 0 0
    2 2008 1 0 0
    2 2009 1 0 0
    2 2010 1 0 0
    2 2011 1 0 0
    2 2012 1 1 0
    2 2013 1 0 0
    2 2014 1 1 0
    2 2015 1 1 0
    2 2016 1 1 0
    2 2017 1 1 0
    2 2018 1 1 0
    2 2019 1 1 0
    2 2020 1 1 0
    3 2004 1 0 0
    3 2005 1 0 0
    3 2006 1 0 0
    3 2007 1 0 0
    3 2008 1 0 0
    3 2009 1 0 0
    3 2010 1 0 0
    3 2011 1 0 0
    3 2012 1 0 0
    3 2013 1 0 0
    3 2014 1 0 0
    3 2015 1 0 0
    3 2016 1 0 0
    3 2017 1 0 0
    3 2018 1 0 0
    3 2019 1 0 0
    3 2020 1 0 0
    .    . . . .
    end
    Another example is following

    Code:
    input byte id int year byte(msa gro_2 gro_4 gro_6 gro_8 gro_10)
    1 2004 1 1  0 6  4  5
    1 2005 1 1  0 5  4  6
    1 2006 1 1  0 5  4  6
    1 2007 1 1  0 4  4  6
    1 2008 1 1  0 5  4  7
    1 2009 1 1  0 5  4  7
    1 2010 1 1  0 5  4  7
    1 2011 1 1  0 5  4  7
    1 2012 1 1  0 5  4  7
    1 2013 1 1  0 4  4  9
    1 2014 1 1  0 4  4  9
    1 2015 1 1  0 4  4 10
    1 2016 1 1  0 4  5 10
    1 2017 1 1  0 4  4 10
    1 2018 1 1  0 4  4 10
    1 2019 1 1  0 4  4 10
    1 2020 1 1  0 4  4 10
    2 2004 1 3  0 2  4  5
    2 2005 1 2  0 4  4  5
    2 2006 1 2  0 4  4  5
    2 2007 1 1  0 4  4  5
    2 2008 1 2  0 4  4  5
    2 2009 1 2  0 4  4  5
    2 2010 1 2  0 4  4  5
    2 2011 1 2  0 4  4  4
    2 2012 1 2  0 4  4  4
    2 2013 1 2  0 5  3  4
    2 2014 1 2  0 5  3  4
    2 2015 1 2  0 5  3  4
    2 2016 1 2  1 5  3  4
    2 2017 1 2  0 5  3  4
    2 2018 1 2  0 5  3  4
    2 2019 1 2  0 5  3  4
    2 2020 1 2  0 5  3  4
    3 2004 1 3 11 5 12  6
    3 2005 1 0  0 0  0  0
    3 2006 1 0  0 0  0  0
    3 2007 1 3 12 4 13  7
    3 2008 1 3 13 5 13  8
    3 2009 1 3 13 5 14  8
    3 2010 1 3 13 4 14  8
    3 2011 1 3 13 4 14  8
    3 2012 1 3 13 4 15  8
    3 2013 1 2 13 7 13  9
    3 2014 1 3 13 8 14  9
    3 2015 1 3 13 8 14  9
    3 2016 1 3 13 8 14  9
    3 2017 1 3 13 8 14  9
    3 2018 1 3 13 8 14  9
    3 2019 1 3 14 8 14  9
    3 2020 1 3 14 8 14  9
    .    . . .  . .  .  .
    end
    Last edited by Priver JM; 03 Oct 2022, 11:40.

  • #2
    It is not super clear what your problem is. I understand that you want to identify which id has non-consistent pattern. But what is your definition of consistent pattern? Is having wm_38 changing from 0 to 1 and then back to 1 non consistent? Why is that so? More clarification is probably needed.

    Comment


    • #3
      Sorry about that. The problem is the value changed randomly indicated as bold numbers. So the consistent pattern will be having same values as 0 before the value increases. For id2, the value should be changed as 1 from 2017 to 2020 in the second example.

      Comment


      • #4
        You mean that your values should always be increasing?

        Comment


        • #5
          Not necessarily. If there is no event, the values do not increase by time.
          Put it simply, if the event happens for id 1 and in year t and the event should be observed in the following year t+1 as 1. There should not be a gap between the events in t+1, t+2, .. t+n.

          Comment

          Working...
          X