I am trying to find a logistic regression model in JAGS, but I have data in the form (# success y, # attempts n), and not a binary variable. In R, you can map the model to such data using glm (y / n ~) with the "weight" argument, but I don't know how to do this in JAGS.
Here is a simple example that, I hope, addresses what I'm trying to ask. Please note that I am using the rjags package. Thanks for any help!
y <- rbinom(10, 500, 0.2) n <- sample(500:600, 10) p <- y/n x <- sample(0:100, 10) # some covariate data <- data.frame(y, n, p, x) model <- "model{ # Specify likelihood for(i in 1:10){ y[i] ~ dbin(p[i], n[i]) logit(p[i]) <- b0 + b1*x } # Specify priors b0 ~ dnorm(0, 0.0001) b1 ~ dnorm(0, 0.0001) }"
r logistic-regression jags
Kirk Fogg
source share