# NOT RUN {
###############################################################
# HIV-AIDS Data
###############################################################
data(hiv)
attach(hiv)
###############################################################
# Working folder
###############################################################
work.dir <- NULL
###############################################################
# Response and design matrices
###############################################################
nsubject <- length(onsetL)
onset <- cbind(onsetL,onsetU)
failure <- cbind(failureL,failureU)
intercept <- rep(1,nsubject)
p <- 2
xonset <- cbind(IntO=intercept,trtO=trt)
q <- 2
xfailure <- cbind(IntF=intercept,trtF=trt)
###############################################################
# Predictions
###############################################################
grid <- matrix(c(rep(seq(0,30,len=30),1),
rep(seq(0,20,len=30),1)),nrow=2,byrow=T)
xpred <- matrix(c(rep(c(1,0),1),rep(c(1,0),1),
rep(c(1,1),1),rep(c(1,1),1)),
nrow=2,byrow=T)
colnames(xpred) <- colnames(cbind(xonset,xfailure))
###############################################################
# Initial state
###############################################################
state <- NULL
###############################################################
# Prior
###############################################################
prior<-list(a0=1,
b0=1,
q=0.5,
mub=10,
sigmab=200,
nu=4,
tinv=diag(1,2),
nub=6,
tbinv=diag(1,4),
m0=rep(0,4),
S0=diag(100,4),
maxm=40)
###############################################################
# MCMC
###############################################################
mcmc<-list(nburn=5000,
nskip=9,
ndisplay=100,
nsave=5000,
tune1=0.25,
tune2=1)
###############################################################
# Fitting the Model
###############################################################
fit1 <- LDPDdoublyint(onset=onset,failure=failure,
p=p,xonset=xonset,
q=q,xfailure=xfailure,
xpred=xpred,grid=grid,
prior=prior,
mcmc=mcmc,
state=state,
status=TRUE,
work.dir=work.dir)
fit1
summary(fit1)
###############################################################
# Getting Information for Predictions
###############################################################
# Without CI bands and intervals
fit1.pred <- predict(fit1)
fit1.pred
plot(fit1.pred)
# With CI bands and intervals
fit1.pred <- predict(fit1,compute.band=TRUE)
fit1.pred
plot(fit1.pred)
# }
Run the code above in your browser using DataLab