Announcement

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

  • Generating a duration variable - panel data

    Hi everyone,

    I'm conducting research looking at whether the extensions on unemployment benefits that were rolled out in the US from 2008-2013 resulted in longer unemployment spells.

    I'm looking to create a duration variable to denote an individual's unemployment duration (in terms of how many months an individual was unemployed). I have a series of "whether unemployed in month x" dummy variables that cover each month in each year from 2005-2015, which takes the value of 1 if unemployed in the particular month and 0 if employed in that particular month. Creating a simple total of the months that each individual was unemployed over the total time period (2005-2015) would be simple enough -- however, I want to account for the fact that each individual may have several separate instances of unemployment over the total time period.

    For example, an individual may have 2 separate unemployment spells -- one from January 2005 to March 2005, another from July 2008 to August 2008. Hence, I want to be able to calculate the unemployment duration for each individual and have some form of separation to account for the possibility of multiple unemployment spells. I need to know the length of each unemployment spell (on an individual level) to be able to figure out: whether an individual was eligible to receive unemployment benefit extensions, and how many weeks of unemployment benefit extensions an individual received. The length of unemployment benefit extensions an individual received and eligibility for unemployment benefit extensions are contingent on the duration of an unemployment spell.

    Any suggestions or guidance on how to code the unemployment duration variable would be much appreciated!

  • #2
    I'm not particularly experienced here, but I'd suggest the community contributed package -tsspell- available at SSC. Note that it presumes data in the long format rather than the wide format you describe.

    Comment


    • #3
      Hi Mike, thanks for the suggestion. I've gone through the tsspell manual but haven't been successful in applying the commands suggested there to my particular situation. After finding another similar question on Statalist and applying the suggested code to my problem, I've tried:

      Code:
      by id (mdate): gen spell_start = (_n == 1) | (whetherue == 1 & L.whetherue == 0)
      by id (mdate): gen spell_num = sum(spell_start)
      by id spell_num (mdate), sort: gen counter = _n
      However, upon analysing the result, it doesn't appear to have worked. The counter appears to resets to 1 at seemingly random times, and the spell_start variable gives the value of 1 for only every first observation of a particular individual, and 0 thereafter. This doesn't align with what I can observe from the data in the whetherue (whether unemployed) variable. The commands don't seem to be doing what I need them to do, which is to identify the start of an unemployment spell (which can be identified by the whetherue variable going from 0 in month t to 1 in month t+1), count how many periods an individual was unemployed (by summing the number of "1"s observed within an unemployment spell. Apologies if this is a somewhat daft question on the whole, as I am new to Stata.

      Can anyone offer any pointers?
      Last edited by Claire James; 07 Feb 2018, 14:12.

      Comment


      • #4
        I'm now thinking of modifying the code to include a spell_end variable -- something to the effect of:


        Code:
        bys id (mdate): gen spell_start = (_n == 1) | (whetherue == 1 & L.whetherue == 0)
        bys id (mdate): gen spell_end = (_n == 0 | (whetherue == 0 & L.whetherue == 1)
        bys id (mdate): gen spell_length = sum()
        bys id spell_length (mdate), sort: gen counter = _n
        However, I'm still unsure what to insert as conditions into gen spell_length command such that I can generate a variable that sums up the number of periods an individual was unemployed in a particular unemployment spell.
        Last edited by Claire James; 07 Feb 2018, 14:51.

        Comment


        • #5
          At worst, you can create a bunch of replace commands dealing with different lengths and use an if statement with the lag to make it stop when you exit the unemployment spell.

          Comment

          Working...
          X