Announcement

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

  • Survival analysis using panel data

    Dear sir, madam,

    I have a question regarding certain data management challenges that would allow me to perform a survival analysis using panel data from the Panel Study of Income Dynamics. I am analyzing the period leading up to the decision for an individual to become an entrepreneur.

    To be able to perform a survival analysis (to stset the data) I need to create a spell length variable which I want to do on the basis of the data available to me. The commands that I have been using are as follows:

    generate BusStart = 0
    bysort ID (year): replace BusStart=1 if (BusOwn[_n]==1 & BusOwn[_n-1]==0)

    BusOwn is a dummy variable that equals 1 if an individual owns a business at year n. My aim is to only analyse the first business start of any individual. The commands that I have been using however create a dummy that is 1 whenever a person owns a business in period n after not having owned a business in period n-1. Therefor it is possible that a single person has more than one period where BusStart == 1, and indeed it does occur.
    ID BusStart BusOwn year
    5170 1 1 1996
    5170 0 1 1997
    5170 0 0 1999
    5170 1 1 2001
    5170 0 0 2003
    Is there an easy way to create a dummy variable (BusStart) that only equals 1 at time n if all previous periods of BusOwn equal zero?
    ID BusStart BusOwn year
    5170 1 1 1996
    5170 0 1 1997
    5170 0 0 1999
    5170 0 1 2001
    5170 0 0 2003

    Thanks in advance.

    Kind regards,
    Joel
    Last edited by Joel de Bruijn; 23 Oct 2018, 09:36.

  • #2
    search tsspell

    Comment


    • #3
      Hi Stephen,

      Thank you for your reply. I have posted the example below again in the proprietary format, apologies for not doing that earlier. I will give tsspell (and tsset) a try.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(ID BusStart BusOwn) int year
      5170 0 0 1985
      5170 0 0 1986
      5170 0 0 1987
      5170 0 0 1988
      5170 0 0 1989
      5170 0 0 1990
      5170 0 0 1991
      5170 0 0 1992
      5170 0 0 1993
      5170 0 0 1994
      5170 0 0 1995
      5170 1 1 1996
      5170 0 1 1997
      5170 0 0 1999
      5170 1 1 2001
      5170 0 0 2003
      5170 0 0 2005
      5170 0 0 2007
      5170 0 0 2009
      5170 0 0 2011
      5170 0 0 2013
      5170 0 0 2015
      end
      Kind regards,
      Joël

      Comment


      • #4
        Hi Stephen, Statalist members,

        Thank you for your suggestion:
        Originally posted by Stephen Jenkins View Post
        search tsspell
        I have been working with the tsspell command but I am running into a few issues. My aim is to define episode's (or spells) as starting at age 25 and ending as soon as a business is owned for the first time. To achieve this I attempted to use the command below.

        tsspell, cond(Age > 25 & BusOwn == 0)

        My concern is that I haven't defined my command ensuring that only one spell is created per ID. Individual 5170 now has three spells, I only want to keep the first spell.

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float ID byte(_seq _spell _end) float BusOwn int year float Age
        5170 0 0 0 0 1985 20
        5170 0 0 0 0 1986 21
        5170 0 0 0 0 1987 22
        5170 0 0 0 0 1988 23
        5170 0 0 0 0 1989 24
        5170 0 0 0 0 1990 25
        5170 1 1 0 0 1991 26
        5170 2 1 0 0 1992 27
        5170 3 1 0 0 1993 28
        5170 4 1 0 0 1994 29
        5170 5 1 1 0 1995 30
        5170 0 0 0 1 1996 31
        5170 0 0 0 1 1997 32
        5170 1 2 1 0 1999 34
        5170 0 0 0 1 2001 36
        5170 1 3 0 0 2003 38
        5170 2 3 0 0 2005 40
        5170 3 3 0 0 2007 42
        5170 4 3 0 0 2009 44
        5170 5 3 0 0 2011 46
        5170 6 3 0 0 2013 48
        5170 7 3 1 0 2015 50
        end

        Is there a (better) way to define the command to measure spells that I am after, starting at age 25 and ending when an individual owns a business?

        Thanks.

        Kind regards,

        Joël de Bruijn

        PS. An earlier version of this message concerned a problem with spells not ending at BusOwn != 0, however, this issue has been solved by using & instead of if.
        Last edited by Joel de Bruijn; 25 Oct 2018, 07:58.

        Comment

        Working...
        X