Announcement

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

  • Advice on survival analysis setup

    Hello everyone,

    I’m hoping to solicit some advice from those of you that are familiar with survival analysis. I’m still a bit new to the subject, but would like to get my feet wet with some firm-level data. I’ve read through a couple of helpful resources, but am still a bit puzzled as to properly stset this particular set up. The closest example that I can find related to my current setup on Statalist is this thread (https://www.statalist.org/forums/for...re-using-stset).

    Below there is a sample of my data. It’s confidential so it’s been heavily altered. The data a firm level data from Q1-2008 to Q3-2014. I have a firm id (firm), a quarterly variable (quarter), the employment count (emp), when the firm came into business (register_date), when the firm went out of business (termination_date), and the major industry (naics). I’ve removed the other covariates for simplicity.

    Here’s what I’ve done – I’m not sure if this is right, but would appreciate any feedback!

    Code:
    gen failure = 0
    replace failure = 1 if quarter == termination_date
     
    bys firm (quarter) : replace failure = . if  failure[_n-1] == 1
    bys firm (quarter) : replace failure = . if  failure[_n-1] == . & quarter >= termination_date
    bys firm (quarter) : replace failure = . if  employment    == . & quarter < termination_date
     
     
    stset quarter, failure(failure == 1)
    replace _t = _t – 191
    Here’s my data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(firm quarter) float employment str6 naics int(register_date termination_date)
    1 192   . "54" 204 207
    1 193   . "54" 204 207
    1 194   . "54" 204 207
    1 195   . "54" 204 207
    1 196   . "54" 204 207
    1 197   . "54" 204 207
    1 198   . "54" 204 207
    1 199   . "54" 204 207
    1 200   . "54" 204 207
    1 201   . "54" 204 207
    1 202   . "54" 204 207
    1 203   . "54" 204 207
    1 204  38 "54" 204 207
    1 205  55 "54" 204 207
    1 206   6 "54" 204 207
    1 207  66 "54" 204 207
    1 208   . "54" 204 207
    1 209   . "54" 204 207
    1 210   . "54" 204 207
    1 211   . "54" 204 207
    1 212   . "54" 204 207
    1 213   . "54" 204 207
    1 214   . "54" 204 207
    1 215   . "54" 204 207
    1 216   . "54" 204 207
    1 217   . "54" 204 207
    1 218   . "54" 204 207
    2 192   . "54" 204   .
    2 193   . "54" 204   .
    2 194   . "54" 204   .
    2 195   . "54" 204   .
    2 196   . "54" 204   .
    2 197   . "54" 204   .
    2 198   . "54" 204   .
    2 199   . "54" 204   .
    2 200   . "54" 204   .
    2 201   . "54" 204   .
    2 202   . "54" 204   .
    2 203   . "54" 204   .
    2 204  27 "54" 204   .
    2 205  39 "54" 204   .
    2 206  21 "54" 204   .
    2 207  20 "54" 204   .
    2 208  66 "54" 204   .
    2 209   5 "54" 204   .
    2 210   2 "54" 204   .
    2 211  29 "54" 204   .
    2 212  26 "54" 204   .
    2 213  24 "54" 204   .
    2 214   6 "54" 204   .
    2 215  10 "54" 204   .
    2 216  22 "54" 204   .
    2 217   5 "54" 204   .
    2 218  20 "54" 204   .
    3 192   . "51" 204 215
    3 193   . "51" 204 215
    3 194   . "51" 204 215
    3 195   . "51" 204 215
    3 196   . "51" 204 215
    3 197   . "51" 204 215
    3 198   . "51" 204 215
    3 199   . "51" 204 215
    3 200   . "51" 204 215
    3 201   . "51" 204 215
    3 202   . "51" 204 215
    3 203   . "51" 204 215
    3 204 220 "51" 204 215
    3 205 237 "51" 204 215
    3 206 215 "51" 204 215
    3 207 361 "51" 204 215
    3 208 225 "51" 204 215
    3 209 219 "51" 204 215
    3 210 338 "51" 204 215
    3 211 398 "51" 204 215
    3 212 123 "51" 204 215
    3 213  37 "51" 204 215
    3 214  37 "51" 204 215
    3 215   0 "51" 204 215
    3 216   . "51" 204 215
    3 217   . "51" 204 215
    3 218   . "51" 204 215
    4 192   . "53" 204   .
    4 193   . "53" 204   .
    4 194   . "53" 204   .
    4 195   . "53" 204   .
    4 196   . "53" 204   .
    4 197   . "53" 204   .
    4 198   . "53" 204   .
    4 199   . "53" 204   .
    4 200   . "53" 204   .
    4 201   . "53" 204   .
    4 202   . "53" 204   .
    4 203   . "53" 204   .
    4 204   6 "53" 204   .
    4 205  15 "53" 204   .
    4 206  35 "53" 204   .
    4 207  34 "53" 204   .
    4 208  49 "53" 204   .
    4 209  31 "53" 204   .
    4 210   7 "53" 204   .
    end
    format %tq quarter
    format %tq register_date
    format %tq termination_date
Working...
X