I need to create two dummies based on the events arrangement frequency repetition rule . Events appear according to a rule . Two different dummies needed:
a)Expected a dummy the takes value 1 if the event took place in the year that was expected according to the frequency repetition rule.
b)Unexpected is a dummy that takes value 1 if the event took place in a year other than expected according to the frequency repetition rule.
A sample of date is given. The example was created manually so human mistakes might have occurred .
GroupA has a periodicity of 3 and most of the cases the event is repeated reguarly as expected.
GroupG has a periodicity of 4 but there are case where the event took place earlier ie in 1990,1993 and 2007.
Gaps in the data are present and events are missing. For those cases standard treatment of missing observations for dummies is applied.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year str48 group float event int peyear byte frequency float(exepcted unexepcted) 1945 "groupA" -5977 1943 3 . . 1946 "groupA" -4843 1946 3 . . 1947 "groupA" -4843 1946 3 . . 1948 "groupA" -4843 1946 3 . . 1949 "groupA" -3674 1949 3 . . 1950 "groupA" -3674 1949 3 . . 1951 "groupA" -3170 1951 3 . . 1952 "groupA" -3170 1951 3 . . 1953 "groupA" -3170 1951 3 . . 1954 "groupA" -2043 1954 3 . . 1955 "groupA" -2043 1954 3 . . 1956 "groupA" -1483 1955 3 . . 1957 "groupA" -1483 1955 3 . . 1958 "groupA" -405 1958 3 . . 1959 "groupA" -405 1958 3 . . 1960 "groupA" -405 1958 3 . . 1985 "groupG" 9284 1985 4 . . 1986 "groupG" 9284 1985 4 . . 1987 "groupG" 9284 1985 4 . . 1988 "groupG" 9284 1985 4 . . 1989 "groupG" 10901 1989 4 . . 1990 "groupG" 11055 1990 4 . . 1991 "groupG" 11055 1990 4 . . 1992 "groupG" 11055 1990 4 . . 1993 "groupG" 12336 1993 4 . . 1994 "groupG" 12336 1993 4 . . 1995 "groupG" 12336 1993 4 . . 1996 "groupG" 13414 1996 4 . . 1997 "groupG" 13414 1996 4 . . 1998 "groupG" 13414 1996 4 . . 1999 "groupG" 13414 1996 4 . . 2000 "groupG" 14709 2000 4 . . 2001 "groupG" 14709 2000 4 . . 2002 "groupG" 14709 2000 4 . . 2003 "groupG" 14709 2000 4 . . 2004 "groupG" 16137 2004 4 . . 2005 "groupG" 16137 2004 4 . . 2006 "groupG" 16137 2004 4 . . 2007 "groupG" 17425 2007 4 . . 2008 "groupG" 17425 2007 4 . . 2009 "groupG" 18174 2009 4 . . 2010 "groupG" 18174 2009 4 . . 2011 "groupG" 18174 2009 4 . . 2012 "groupG" 19161 2012 4 . . 2013 "groupG" 19161 2012 4 . . 2014 "groupG" 19161 2012 4 . . end format %ty year format %d event
Thank you
Mario Ferri
0 Response to Event repetition dummy
Post a Comment