#R Program to Calculate Survival Probability of Kidney Carcinoma Patients using Hypertabastic Proportional Hazards Model #'Time: Continuous (in months) #'Age: Continuous (in years) #'Gender: #' 0=Female 1=Male #'Race: #' 0=White 1=Hispanic 2=Asian 3=Black #'Histology: #' 0=Other 1=Adeno 2=Papillary 3=Clear 4=Renal #' 5=Chromophobe 6=Sarcomatoid 7=Granular #'Region: #' 0=Southwest 1=East 2=North 3=Pacific #'Stage: #' 0=Regional 1=Localized 2=Distant #'Grade: #' 0=Undifferentiated 1=Well 2=Moderate 3=Poor #'Site: #' 0=Other 1=No_Surgery 2=Cryo13 3=Thermal 4=Cryo23 5=Part_Neph/Part_Uret #' 6=Complete_Neph 7=Radical 8=Any_Neph #Read in Function Survival_Probability <- function(Time,Age,Gender,Race,Histology,Region,Stage,Grade,Site){ start = c(2,5,12,15,17,20) #Initialize input = c(Race,Histology,Region,Stage,Grade,Site) #Record part of input B = c(Age,Gender,integer(27)) #Create vector of parameters place = start + input #Set location in vector to be changed for(i in 1:6){if(input[i] == 0){}else{B[place[i]] = 1}} #Set vector locations = 1 Beta = -sum(B*c(-0.011576,-0.016056,-0.081035,-0.041793,-0.13937,0.228189,0.532579,0.565283, 0.323947,1.187381,-0.280902,0.376178,0.015638,0.068913,0.050401,1.221175, -1.420683,1.176737,0.999862,0.419985,-1.167472,0.736603,0.487928,0.440444, 1.012776,0.090548,-0.094567,-0.270463,-0.135374)) #Set beta values return(1/cosh(0.104941*(1-(Time)^0.331843*1/tanh((Time)^0.331843))/0.331843)^exp(Beta)) #Output } #Answer to Proposed Question Survival_Probability(Time = 60,Age=55,Gender=1,Race=0,Histology=1, Region=2,Stage=2,Grade=3,Site=7)