Helper function for Event history analysis