PreMean <- matrix(ncol=3, nrow=2, byrow=TRUE) PreMean[1, ] <- c(1, -1, 0) PreMean[2, ] <- c(-0.8, 0, 0.8) PreZeta <- c(0.4, 1.8, 1) GenExpression <- function(x, cancertype, sdv) { rnorm(1, PreMean[x,cancertype], sdv) } GenSurvival <- function(funtype, cancertype, x1, x2, cancerprob) { # rm(.Random.seed) S <- runif(1, 0, 1) if(cancertype==1) { h <- 0.3*x1 + 0.4*x2 - 0.1 } if(cancertype==2) { h <- 0.5*(x1-x2)^2 + 1 } if(cancertype==3) { h <- 0.006*x1^3 - 0.2*x2 } if(funtype=="1") { -(log(S)/exp(-h)) } #survival function is Weibull exp((-log(S)/exp(-h))^(1/PreZeta[cancertype])) }