# loading a data set
data(survData)
Y <- survData[,c(1,2)]
cluster <- survData[,3]
lin.pred <- as.formula( ~ cov1 + cov2)
#####################
## Hyperparameters ##
#####################
## Weibull baseline hazard function: alpha1, kappa1
##
WB.ab <- c(0.5, 0.01) # prior parameters for alpha
##
WB.cd <- c(0.5, 0.05) # prior parameters for kappa
## PEM baseline hazard function:
##
PEM.ab <- c(0.7, 0.7) # prior parameters for 1/sigma^2
##
PEM.alpha <- 10 # prior parameters for K
## Normal cluster-specific random effects
##
Normal.ab <- c(0.5, 0.01) # prior for zeta
## DPM cluster-specific random effects
##
DPM.ab <- c(0.5, 0.01)
aTau <- 1.5
bTau <- 0.0125
##
hyperParams <- list(WB=list(WB.ab=WB.ab, WB.cd=WB.cd),
PEM=list(PEM.ab=PEM.ab, PEM.alpha=PEM.alpha),
Normal=list(Normal.ab=Normal.ab),
DPM=list(DPM.ab=DPM.ab, aTau=aTau, bTau=bTau))
###################
## MCMC SETTINGS ##
###################
## Setting for the overall run
##
numReps <- 2000
thin <- 10
burninPerc <- 0.5
## Settings for storage
##
storeV <- TRUE
## Tuning parameters for specific updates
##
## - those common to all models
mhProp_V_var <- 0.05
##
## - those specific to the Weibull specification of the baseline hazard functions
mhProp_alpha_var <- 0.01
##
## - those specific to the PEM specification of the baseline hazard functions
C <- 0.2
delPert <- 0.5
rj.scheme <- 1
K_max <- 50
s_max <- max(Y$time[Y$event == 1])
time_lambda <- seq(1, s_max, 1)
##
mcmc.WB <- list(run=list(numReps=numReps, thin=thin, burninPerc=burninPerc),
storage=list(storeV=storeV),
tuning=list(mhProp_alpha_var=mhProp_alpha_var, mhProp_V_var=mhProp_V_var))
##
mcmc.PEM <- list(run=list(numReps=numReps, thin=thin, burninPerc=burninPerc),
storage=list(storeV=storeV),
tuning=list(mhProp_V_var=mhProp_V_var, C=C, delPert=delPert,
rj.scheme=rj.scheme, K_max=K_max, time_lambda=time_lambda))
################################################################
## Analysis of Independent Univariate Survival Data ############
################################################################
####################
## WEIBULL ##
####################
##
myModel <- "Weibull"
myPath <- "Output/01-Results-WB/"
startValues <- vector("list", 2)
startValues[[1]] <- initiate.startValues(Y, lin.pred, survData, model=myModel)
startValues[[2]] <- initiate.startValues(Y, lin.pred, survData, model=myModel,
WB.alpha=1.12)
##
fit_WB <- BayesSurv(Y, lin.pred, survData, cluster=NULL, model=myModel,
hyperParams, startValues, mcmc.WB, path=myPath)
fit_WB
summ.fit_WB <- summary(fit_WB); names(summ.fit_WB)
summ.fit_WB
plot(fit_WB, tseq=seq(from=0, to=30, by=5))
plot(fit_WB, tseq=seq(from=0, to=30, by=5), plot.est = "BH")
names(fit_WB.plot <- plot(fit_WB, tseq=seq(0, 30, 5), plot=FALSE))
#########
## PEM ##
#########
##
myModel <- "PEM"
myPath <- "Output/02-Results-PEM/"
startValues <- vector("list", 2)
startValues[[1]] <- initiate.startValues(Y, lin.pred, survData, model=myModel)
startValues[[2]] <- initiate.startValues(Y, lin.pred, survData, model=myModel,
beta=rep(0.1,2))
##
fit_PEM <- BayesSurv(Y, lin.pred, survData, cluster=NULL, model=myModel,
hyperParams, startValues, mcmc.PEM, path=myPath)
fit_PEM
summ.fit_PEM <- summary(fit_PEM); names(summ.fit_PEM)
summ.fit_PEM
plot(fit_PEM)
plot(fit_PEM, plot.est = "BH")
names(fit_PEM.plot <- plot(fit_PEM, plot=FALSE))
###############################################################
## Analysis of Correlated Univariate Survival Data ############
###############################################################
####################
## WEIBULL-NORMAL ##
####################
##
myModel <- c("Weibull", "Normal")
myPath <- "Output/03-Results-WB_Normal/"
startValues <- vector("list", 2)
startValues[[1]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster)
startValues[[2]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster,
Normal.zeta=0.95)
##
fit_WB_N <- BayesSurv(Y, lin.pred, survData, cluster, model=myModel,
hyperParams, startValues, mcmc.WB, path=myPath)
fit_WB_N
summ.fit_WB_N <- summary(fit_WB_N); names(summ.fit_WB_N)
summ.fit_WB_N
plot(fit_WB_N, tseq=seq(from=0, to=30, by=5))
plot(fit_WB_N, tseq=seq(from=0, to=30, by=5), plot.est = "BH")
names(fit_WB_N.plot <- plot(fit_WB_N, tseq=seq(0, 30, 5), plot=FALSE))
#################
## WEIBULL-DPM ##
#################
##
myModel <- c("Weibull", "DPM")
myPath <- "Output/04-Results-WB_DPM/"
startValues <- vector("list", 2)
startValues[[1]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster)
startValues[[2]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster,
Normal.zeta=0.95)
##
fit_WB_DPM <- BayesSurv(Y, lin.pred, survData, cluster, model=myModel,
hyperParams, startValues, mcmc.WB, path=myPath)
fit_WB_DPM
summ.fit_WB_DPM <- summary(fit_WB_DPM); names(summ.fit_WB_DPM)
summ.fit_WB_DPM
plot(fit_WB_DPM, tseq=seq(from=0, to=30, by=5))
plot(fit_WB_DPM, tseq=seq(from=0, to=30, by=5), plot.est = "BH")
names(fit_WB_DPM.plot <- plot(fit_WB_DPM, tseq=seq(0, 30, 5), plot=FALSE))
################
## PEM-NORMAL ##
################
##
myModel <- c("PEM", "Normal")
myPath <- "Output/05-Results-PEM_Normal/"
startValues <- vector("list", 2)
startValues[[1]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster)
startValues[[2]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster,
Normal.zeta=0.95)
##
fit_PEM_N <- BayesSurv(Y, lin.pred, survData, cluster, model=myModel,
hyperParams, startValues, mcmc.PEM, path=myPath)
fit_PEM_N
summ.fit_PEM_N <- summary(fit_PEM_N); names(summ.fit_PEM_N)
summ.fit_PEM_N
plot(fit_PEM_N)
plot(fit_PEM_N, plot.est = "BH")
names(fit_PEM_N.plot <- plot(fit_PEM_N, plot=FALSE))
#############
## PEM-DPM ##
#############
##
myModel <- c("PEM", "DPM")
myPath <- "Output/06-Results-PEM_DPM/"
startValues <- vector("list", 2)
startValues[[1]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster)
startValues[[2]] <- initiate.startValues(Y, lin.pred, survData, model=myModel, cluster,
Normal.zeta=0.95)
##
fit_PEM_DPM <- BayesSurv(Y, lin.pred, survData, cluster, model=myModel,
hyperParams, startValues, mcmc.PEM, path=myPath)
fit_PEM_DPM
summ.fit_PEM_DPM <- summary(fit_PEM_DPM); names(summ.fit_PEM_DPM)
summ.fit_PEM_DPM
plot(fit_PEM_DPM)
plot(fit_PEM_DPM, plot.est = "BH")
names(fit_PEM_DPM.plot <- plot(fit_PEM_DPM, plot=FALSE))
Run the code above in your browser using DataLab