# NOT RUN {
set.seed(20181223)
n = 5 # number of clusters
k = 50 # cluster size
N = n*k # total sample size
cluster.id = rep(1:n, each=k)
tau.error = 0.8
b = rnorm(n, 0, tau.error)
alpha = 2
beta1 = 1
beta2 = -1
beta3 = -2
sig.error = 0.5
censoring.rate = 0.02
x1 = rnorm(N,0.5,1)
x2 = rnorm(N,1.5,0.5)
trt.train = sample(c(1,2,3), N, prob = c(0.4,0.3,0.2), replace = TRUE)
trt.test = sample(c(1,2,3), N, prob = c(0.3,0.4,0.2), replace = TRUE)
error = rnorm(N,0,sig.error)
logtime = alpha + beta1*x1 + beta2*x2 + b[cluster.id] + error
y = exp(logtime)
C = rexp(N, rate=censoring.rate) # censoring times
Y = pmin(y,C)
status = as.numeric(y<=C)
res_sa <- sa(M.burnin = 10, M.keep = 10, M.thin = 1, status = status,
y.train = Y,trt.train = trt.train,trt.test = trt.test,
x.train = cbind(x1,x2),
x.test = cbind(x1,x2),
cluster.id = cluster.id, verbose = F,prior_c_function = c(
"runif(-0.6, 0)",# c(1,2)
"runif(0, 0.6)",# c(2,1)
"runif(-0.6, 0)", # c(2,3)
"seq(-0.6, 0, by = 0.3)", # c(1,3)
"seq(0, 0.6, by = 0.3)", # c(3,1)
"runif(0, 0.6)" # c(3,2)
),Q1 = 1, nCores = 1)
# }
Run the code above in your browser using DataLab