Code for survival analysis