# NOT RUN {
## Sample calls:
# fits simulated response data included with this package to augmented hbbr model
# and then plots the estimated part-worth utilities.
# }
# NOT RUN {
data("simAugData")
hbA = hbbrAug.Fit(brdta= simAugData$brdtaAug, Z=simAugData$Z,
design=simAugData$design,
tune.param=list(tau=0.01, eta=NULL, df.add=2),
mcmc=list(burnin=500, iter=10000, nc=2, thin=10))
# define an appropriate function to plot the part-worth values...
partworth.plot = function(attr.lvl, beta.mns, nb=3, new=TRUE, pnt =15, cl=clrs)
{
#check dimension
k = length(attr.lvl) # no of attributes
bk = length(unlist(attr.lvl)) # no of levels acrosss attributes
if (bk - k != length(beta.mns)) stop("error 1")
mns = rep(0, length(unlist(attr.lvl)))
cntr = 0
for (j in 1:k)
{
for (i in 1:length(attr.lvl[[j]])){
cntr = cntr +1
if (i > 1) mns[cntr]= beta.mns[cntr-1-(j-1)]
}
}
indx = list()
j0=1
for (j in 1:k) {
j1 = (j0+length(attr.lvl[[j]])-1)
indx[[j]]= j0:j1
j0=j1+1
}
if (new) {
plot(c(1,bk), c(floor(min(beta.mns)*1.2),ceiling(max(beta.mns)*1.2)),
type="n", axes=FALSE, xlab="",ylab="")
axis(2, at=0:ceiling(max(beta.mns)*1.2), las=1, cex.axis=.7)
axis(4, at=floor(min(beta.mns)*1.2):0, las=1, cex.axis=.7)
}
vl=c()
for (j in 1:k)
{
points(indx[[j]], mns[indx[[j]]], type="b", pch =pnt, col=cl[j])
vl=c(vl, max(indx[[j]])+.5)
}
abline(v=vl,col="gray", h=0)
box()
}
# Plotting estimated betas (part-worth) for some selected baseline characteristics:
augattr.lvl = list(b1=paste("B1",1:3,sep=""),b2=paste("B2",1:3,sep=""),
r1=paste("R1",1:3,sep=""),r2=paste("R2",1:3,sep=""))
clrs = c("blue", "green4","orange4", "red3")
mns = hbA$del.means
# est. part-worth values
betmn1 = mns %*% matrix(c(1, 0, 1), ncol=1) # at mean age with disease staus=1
betmn2 = mns %*% matrix(c(1, 0, -1), ncol=1) # at mean age with disease staus=-1
betmn3 = mns %*% matrix(c(1, 1, -1), ncol=1) # at age = mean+1*SD, disease staus=-1
partworth.plot(attr.lvl = augattr.lvl, beta.mns = betmn1)
partworth.plot(attr.lvl = augattr.lvl, beta.mns = betmn2, new=FALSE, pnt=17)
partworth.plot(attr.lvl = augattr.lvl, beta.mns = betmn3, new=FALSE, pnt=16)
# Plotting true betas at those baseline characteristics
Del = simAugData$Del
clrs = rep("darkgrey", 4)
# true part-worth values
bmn1 = Del %*% matrix(c(1, 0, 1), ncol=1) # at mean age with disease staus=1
bmn2 = Del %*% matrix(c(1, 0, -1), ncol=1) # at mean age with disease staus=-1
bmn3 = Del %*% matrix(c(1, 1, -1), ncol=1) # at age = mean+1*SD, disease staus=-1
partworth.plot(attr.lvl = augattr.lvl, beta.mns = bmn1)
partworth.plot(attr.lvl = augattr.lvl, beta.mns = bmn2, new=FALSE, pnt=17)
partworth.plot(attr.lvl = augattr.lvl, beta.mns = bmn3, new=FALSE, pnt=16)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab