Last active
December 31, 2016 02:33
-
-
Save tvladeck/f050e1e4e398f91dc48b73723e72c1a5 to your computer and use it in GitHub Desktop.
bugs model for election analysis
This file contains 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
model { | |
for(i in 1:n_obs){ | |
hrc_votes[i] ~ dbin(p[i], n_votes[i]) | |
p[i] ~ dbeta(alpha[i], beta[i]) | |
# reparameterization of the beta distribution taken from this site | |
# http://bit.ly/2i880Oj | |
alpha[i] <- mu[i] * phi[i] | |
beta[i] <- (1-mu[i]) * phi[i] | |
logit(mu[i]) <- | |
mu_inter + | |
mu_white * white[i] + | |
mu_age * age[i] + | |
mu_diabetes * diabetes[i] + | |
mu_gini * gini[i] + | |
mu_income * income[i] + | |
mu_high_school * high_school[i]+ | |
mu_uninsured * uninsured[i] + | |
mu_unemployment * unemployment[i] + | |
mu_crime * crime[i] | |
log(phi[i]) <- | |
phi_inter + | |
phi_white * white[i] + | |
phi_age * age[i] + | |
phi_diabetes * diabetes[i] + | |
phi_gini * gini[i] + | |
phi_income * income[i] + | |
phi_high_school * high_school[i]+ | |
phi_uninsured * uninsured[i] + | |
phi_unemployment * unemployment[i] + | |
phi_crime * crime[i] | |
} | |
# diffuse, uninformative priors | |
# used ~ dnorm(0, 0.00001) for every parameter | |
# reminder: BUGS/JAGS uses precision (1/sigma) instead of sigma | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment