# High coefficient values in Bayesian compared to non-Bayesian logistic regression

I'm trying to move from a non-Bayesian logistic regression model to a Bayesian one (using R + jags). The model in this test scenario contains one categorical predictor. Here's some dummy data:

testdata <- data.frame(y=c(rep(0,43),rep(1,7),rep(0,45),rep(1,5)),x=c(rep("A",50),rep("B",50)))
table(testdata$y, testdata$x)
A  B
0 43 45
1  7  5


Now, using testdata\$y as the predicted variable and testdata\$x as a predictor, let's run a simple logistic regression:

nonbayesian.model <-glm(y ~ x,data=testdata,family="binomial")


This gives the following results:

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)  -1.8153     0.4076  -4.454 8.43e-06 ***
xB           -0.3819     0.6231  -0.613     0.54


This is how I am currently trying to construct a Bayesian version:

writeLines("model{
for (i in 1:Ntotal) {
y[i] ~ dbern(p[i])
logit(p[i]) <- beta0 + beta.x[x[i]]
}

beta0 ~ dnorm(0, 0.01)

for (j in 1:2) {
beta.x[j] ~ dnorm(0,0.01)
}

}", "jagsmodel.txt")

jagsModel <- jags.model("jagsmodel.txt",
data=list(y=testdata$y,x=testdata$x, Ntotal=nrow(testdata)))

post <- coda.samples(jagsModel, variable.names=c("beta.x"), n.iter=5000)


Looking at the summary of the Bayesian version, I get something like:

           Mean    SD Naive SE Time-series SE
beta.x[1] 5.056 3.818  0.05400          1.209
beta.x[2] 4.642 3.803  0.05378          1.200


What puzzles me is why the means in the summary of the Bayesian model are so high. I suspect I'm doing something terribly unreasonable in setting the priors in the jags model specification (I was just trying to get an uninformative starting point by setting up normally distributed priors with a small sd).

• It won't really help you solve your problem but on a side note : I would not say that a normal distribution with that low of a variance is considered uninformative – Riff Feb 7 '17 at 9:39
• Well, I do think that's something I need to consider. Increasing the sd of the normal distributions does seem to make the coefficient values less radical. – jharme Feb 7 '17 at 10:05
• The less informative prior is generally considered to be a uniform distribution I would say. (and I think a uniform prior would yield the coefficient of the non-bayesian model, but I am in no way a bayesian user) – Riff Feb 7 '17 at 10:10