# NOT RUN {
##############################################################
# Fertility data example:
# The following are Sperm Deformity Index (SDI) values from
# semen samples of men in an infertility study. They are
# divided into a "condition" present group defined as those
# whose partners achieved pregnancy and "condition" absent
# where there was no pregnancy.
#
# Aziz et al. (1996) Sperm deformity index: a reliable
# predictor of the outcome of fertilization in vitro.
# Fertility and Sterility, 66(6):1000-1008.
#
##############################################################
"pregnancy"<- c(165, 140, 154, 139, 134, 154, 120, 133,
150, 146, 140, 114, 128, 131, 116, 128,
122, 129, 145, 117, 140, 149, 116, 147,
125, 149, 129, 157, 144, 123, 107, 129,
152, 164, 134, 120, 148, 151, 149, 138,
159, 169, 137, 151, 141, 145, 135, 135,
153, 125, 159, 148, 142, 130, 111, 140,
136, 142, 139, 137, 187, 154, 151, 149,
148, 157, 159, 143, 124, 141, 114, 136,
110, 129, 145, 132, 125, 149, 146, 138,
151, 147, 154, 147, 158, 156, 156, 128,
151, 138, 193, 131, 127, 129, 120, 159,
147, 159, 156, 143, 149, 160, 126, 136,
150, 136, 151, 140, 145, 140, 134, 140,
138, 144, 140, 140)
"nopregnancy"<-c(159, 136, 149, 156, 191, 169, 194, 182,
163, 152, 145, 176, 122, 141, 172, 162,
165, 184, 239, 178, 178, 164, 185, 154,
164, 140, 207, 214, 165, 183, 218, 142,
161, 168, 181, 162, 166, 150, 205, 163,
166, 176)
#########################################################
# Estimating the ROC curve from the data
#########################################################
# Initial state
statex <- NULL
statey <- NULL
# Prior information
priorx <-list(alpha=10,m2=rep(0,1),
s2=diag(100000,1),
psiinv2=solve(diag(5,1)),
nu1=6,nu2=4,
tau1=1,tau2=100)
priory <-list(alpha=20,m2=rep(0,1),
s2=diag(100000,1),
psiinv2=solve(diag(2,1)),
nu1=6,nu2=4,
tau1=1,tau2=100)
# MCMC parameters
nburn<-1000
nsave<-2000
nskip<-0
ndisplay<-100
mcmcx <- list(nburn=nburn,nsave=nsave,nskip=nskip,
ndisplay=ndisplay)
mcmcy <- mcmcx
# Estimating the ROC
fit1<-DProc(x=pregnancy,y=nopregnancy,priorx=priorx,priory=priory,
mcmcx=mcmcx,mcmcy=mcmcy,statex=statex,statey=statey,
statusx=TRUE,statusy=TRUE)
fit1
plot(fit1)
#########################################################
# Estimating the ROC curve from DPdensity objects
#########################################################
fitx<-DPdensity(y=pregnancy,prior=priorx,mcmc=mcmcx,
state=statex,status=TRUE)
fity<-DPdensity(y=nopregnancy,prior=priory,mcmc=mcmcy,
state=statey,status=TRUE)
# Estimating the ROC
fit2<-DProc(fitx=fitx,fity=fity)
fit2
plot(fit2)
# }
Run the code above in your browser using DataLab