#original data was 500 observations, 2 varying variables HOMAR and INSULIN. 3 time periods 


reshaped_data<-reshape(test.reshape, 

        direction = "long",

        varying = c("HOMA_M0", "HOMA_M3","HOMA_M6", "INSULIN_M0", "INSULIN_M3", "INSULIN_M6"),

        v.names = c("HOMAR", "INSULIN"),

        idvar = c("id"),

        timevar = "visit",

        new.row.names = 1:1500,

        times = 1:3)


Introduction to the Analysis of Survival Data in the Presence of Competing Risks

 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4741409/