# Binomial sampling distribution for data # unknown parameter is population proportion, p # model 1 model { y ~ dbin(p, n) p ~ dbeta( alpha, beta) } data list(y = 7, n = 50, alpha = 0.5, beta = 0.5) inits list(p = 0.1) list(p = 0.5) list(p = 0.9) The following are two versions of a model for the same data. We assume a normal sampling distribution for the data values. In model 2, we assume that the population precision is known, and the mean mu is the only unknown parameter. In model 3, we realistically assume that both population parameters are unknown. # Normal sampling distribution for data # Pretending we know precision # Population mean mu is unknown parameter # We can also estimate the posterior predictive distribution by monitoring y[19] # model 2 model { # likelihood for (i in 1:N) { y[i] ~ dnorm( mu, tausq ) } # priors mu ~ dnorm(0, 0.0001) } data list(y = c(29, 27, 34, 40, 22, 28, 14, 35, 26, 35, 12, 30, 23, 17, 11, 22, 23, 33, NA), N = 19, tausq = .02 ) inits for model 2 list(mu = 0) list(mu = 20) list(mu = 40) # Normal sampling density for data # Both mu and tausq unknown # model 3 model { # likelihood for (i in 1:N) { y[i] ~ dnorm( mu, tausq ) } # priors mu ~ dnorm(0, 0.0001) tausq ~ dgamma( 0.0001, 0.0001) sigmasq <- 1/tausq } Here is a different way to give data to WinBUGS. data list(N = 19 ) additional data y[] 29 27 34 40 22 28 14 35 26 35 12 30 23 17 11 22 23 33 NA END inits for model 3 list(mu = 0, tausq = 1) list(mu = 20, tausq = 100) list(mu = 40, tausq = 1000)