# NOT RUN {
# Logistic regression example
X <- cbind(1, seq(-100, 100, by=0.25))
betavals <- c(-0.9, 0.2)
lodds <- X %*% betavals
prob1 <- as.numeric(1 / (1 + exp(-lodds)))
set.seed(9874)
y <- sapply(prob1, function(xx) {
sample(c(0, 1), 1, prob=c(1-xx, xx))
})
f1 <- mh.fit(N = 2000,
theta.init = rep(0, 2),
nu = c(0.03, 0.001),
qPROP = qprop,
qFUN = qfun,
logPOSTERIOR = logistic_posterior,
varnames = paste0("beta", 0:1),
y=y, X=X)
f1$accept / f1$N
# }
Run the code above in your browser using DataLab