Created
August 21, 2018 07:16
-
-
Save mbedward/850fe1923d9b87e3d3c5f9a66fb7e7ca to your computer and use it in GitHub Desktop.
Model observed proportions as Beta distributed with JAGS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some test data for proportions with mean 0.4 | |
p <- rbeta(20, 4, 6) | |
# JAGS model | |
modelTxt <- "model { | |
for(i in 1:length(p)) { | |
p[i] ~ dbeta(alpha, beta) | |
} | |
alpha <- mu * phi | |
beta <- (1-mu) * phi | |
logit(mu) <- a0 | |
phi ~ dexp(0.1) | |
a0 ~ dnorm(0, 1) | |
}" | |
model <- jags.model(textConnection(modelTxt), data = list(p=p)) | |
sims <- coda.samples(model, c("a0", "mu", "phi"), n.iter = 5000) | |
summary(sims) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment