# NOT RUN {
# Bioassay Data Example
# Cox, D.R. and Snell, E.J. (1989). Analysis of Binary Data. 2nd ed.
# Chapman and Hall. p. 7.
# In this example there are 150 subjects at 5 different stimulus
# levels, 30 at each level.
y<-c(rep(0,30-2),rep(1,2),
rep(0,30-8),rep(1,8),
rep(0,30-15),rep(1,15),
rep(0,30-23),rep(1,23),
rep(0,30-27),rep(1,27))
x<-c(rep(0,30),
rep(1,30),
rep(2,30),
rep(3,30),
rep(4,30))
# Initial state
state <- NULL
# MCMC parameters
nburn<-5000
nsave<-10000
nskip<-10
ntheta<-1
ndisplay<-100
mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,
ntheta=ntheta,ndisplay=ndisplay,tune=1.1)
# Prior distribution
prior <- list(alpha=1, d=2*log(3), p=0.5, beta0=rep(0,2),
Sbeta0=diag(1000,2))
# Fitting the model
fit1 <- CSDPbinary(y~x,prior=prior,mcmc=mcmc,state=state,
status=TRUE)
fit1
# Summary with HPD and Credibility intervals
summary(fit1)
summary(fit1,hpd=FALSE)
# Plot model parameters (to see the plots gradually set ask=TRUE)
plot(fit1)
# Plot an specific model parameter (to see the plots gradually
# set ask=TRUE)
plot(fit1,ask=FALSE,nfigr=1,nfigc=2,param="x")
plot(fit1,ask=FALSE,param="link",nfigc=1,nfigr=1)
# Table of Pseudo Contour Probabilities
anova(fit1)
# Predictive Distribution
npred<-40
xnew<-cbind(rep(1,npred),seq(0,4,length=npred))
pp<-predict(fit1,xnew)
plot(seq(0,4,length=npred),pp$pmean,type='l',ylim=c(0,1),
xlab="log2(concentration)",ylab="Probability")
# Adding MLE estimates
points(c(0,1,2,3,4),c(0.067,0.267,0.500,0.767,0.900),col="red")
# }
Run the code above in your browser using DataLab