# Simulate data from binary regression model
set.seed(1234)
n <- 200
X <- cbind(1,matrix(runif(n=n*2, min=-5, max=5),ncol=2))
ystar <- X%*% c(1,1.5,-.5) + rnorm(n=n, mean=0, sd=abs(2*X[,1]))
y <- as.numeric(ystar>0)
## Set input arguments for a sequence of QRb models
Data <- list(y=y, X=X, p=seq(.1,.9,.1))
Mcmc <- list(R=5000, keep=1)
out <- QRseq(Method="QRb", Data=Data, Mcmc=Mcmc)
# Calculate predicted probabilities
pred <- QRb.pred(QRseq.obj=out, X=Data$X, burnin=2000)
# Make histogram of predicted probabilities
hist(pred,breaks=10)
# Calculate Percentage Correclty Classified (PCC)
mean(Data$y==as.numeric(pred>.5))
# Compare with logit model
mylogit <- glm(Data$y ~ 0 + Data$X, family=binomial(logit))
# Make histogram of predicted probabilities
hist(mylogit$fit,breaks=10)
# Calculate Percentage Correclty Classified (PCC)
mean(Data$y==as.numeric(mylogit$fit>.5))Run the code above in your browser using DataLab