# Example 2 WINBUGS code # The dependent variable is y # x1 is the task (-1 for Boeing and 1 for Sunday) # x2 is the difference between upper and lower P(Yes) model { for( i in 1 : N ) { y[i] ~ dbeta(omega[i], tau[i]) # We reparameterize the beta distribution omega[i] <- mu[i]*phi[i] tau[i] <- (1-mu[i])*phi[i] # This is the location submodel mu[i] <- exp(lambda[i])/(1+exp(lambda[i])) lambda[i] <- (1-K[i])*(beta1 + beta2*x2[i] + beta3*x1[i] + beta4*x1[i]*x2[i]) # This is the dispersion submodel phi[i] <- exp(-kappa[T[i]]) # This is the composition submodel K[i] ~ dbern(P[i]) T[i] <- K[i] + 1 P[i] <- exp(m[i])/(1+exp(m[i])) m[i] <- theta1 + theta2*x1[i] } beta1 ~ dnorm(0.0, 1.0E-6) beta2 ~ dnorm(0.0, 1.0E-6) beta3 ~ dnorm(0.0, 1.0E-6) beta4 ~ dnorm(0.0, 1.0E-6) theta1 ~ dnorm(0.0, 1.0E-6) theta2 ~ dnorm(0.0, 1.0E-6) kappa[2] ~ dnorm(-8.0,10.0) kappa[1] ~ dnorm(0.0, 1.0E-6) } # Data list(N = 242, y = c(0.5,0.5498550725,0.5,0.5,0.30057971,0.5,0.200869565,0.15101449249999999,0.3504347825,0.5,0.5,0.1011594205,0.45014492749999996,0.45014492749999996,0.400289855,0.15101449249999999,0.5,0.200869565,0.4750724635,0.5498550725,0.5,0.5,0.6495652175,0.5,0.2507246375,0.400289855,0.30057971,0.5,0.4501449275,0.40028985499999997,0.5,0.40028985499999997,0.5,0.3504347825,0.30057970999999994,0.400289855,0.5,0.141043478,0.5,0.5,0.30057971,0.076231884,0.475072464,0.5,0.40028985499999997,0.1260869565,0.5,0.380347826,0.5,0.400289855,0.5,0.5,0.40028985499999997,0.4501449275,0.5,0.3504347825,0.5249275365,0.599710145,0.5,0.30057971,0.5,0.5,0.6495652175,0.151014493,0.400289855,0.5498550725,0.3504347825,0.5,0.5,0.5,0.5,0.5,0.016405797,0.375362319,0.5,0.5,0.5,0.30057971,0.5,0.5498550725,0.30057971,0.5,0.3504347825,0.5,0.5498550725,0.2507246375,0.5,0.4501449275,0.5498550725,0.749275362,0.7492753624999999,0.5,0.5,0.3504347825,0.5,0.5,0.30057971,0.4501449275,0.5,0.2507246375,0.40028985499999997,0.5,0.2257971015,0.175942029,0.5747826085,0.5,0.5,0.35043478250000004,0.475072464,0.69942029,0.5,0.195884058,0.400289855,0.5,0.5348985505,0.375362319,0.5,0.5,0.2507246375,0.4501449275,0.45014492749999996,0.3504347825,0.200869565,0.5,0.30057971,0.30057971,0.40028985499999997,0.45014492749999996,0.5,0.5,0.5,0.5,0.5,0.4501449275,0.35043478250000004,0.5,0.30057971,0.40028985499999997,0.5,0.5,0.30057971,0.5,0.15101449249999999,0.400289855,0.5,0.5,0.5,0.3005797105,0.5,0.45014492749999996,0.5,0.3504347825,0.30057971,0.5,0.3255072465,0.5,0.0662608695,0.40028985499999997,0.5,0.45014492749999996,0.9287536235,0.4501449275,0.30057971,0.4501449275,0.5,0.5,0.141043478,0.5,0.5,0.5,0.2507246375,0.325,0.5,0.25,0.275,0.45,0.3,0.275,0.5,0.45,0.425,0.325,0.25,0.5,0.225,0.55,0.5,0.35,0.45,0.425,0.45,0.45,0.475,0.5,0.475,0.475,0.45,0.525,0.3,0.5,0.4,0.5,0.575,0.45,0.525,0.475,0.5,0.525,0.5,0.5,0.5,0.525,0.35,0.35,0.475,0.475,0.55,0.45,0.4,0.475,0.325,0.35,0.5,0.525,0.425,0.5,0.5,0.6,0.525,0.45,0.575,0.6,0.475,0.475,0.575,0.625,0.525,0.225,0.5,0.5,0.1,0.625), x1 = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1), x2 = c(0.049855072,0.19942029,0.0,0.0,0.19942029,0.19942028999999994,0.0,0.099710145,0.099710145,0.099710145,0.0,0.099710145,0.099710145,0.099710145,0.19942029,0.099710145,0.049855072,0.0,0.049855072,0.099710145,0.39884057999999994,0.39884058,0.19942028999999994,0.79768116,0.29913043500000003,0.29913043500000003,0.29913043500000003,0.0,0.19942029,0.39884058,0.099710145,0.19942028999999994,0.5982608700000001,0.099710145,0.09971014399999995,0.149565217,0.099710145,0.0,0.099710145,0.19942029,0.19942029,0.049855072,0.049855072,0.139594203,0.19942028999999994,0.049855073,0.498550725,0.039884058,0.498550725,0.19942029,0.0,0.39884057999999994,0.19942028999999994,0.0,0.09971014399999995,0.19942029,0.049855073,0.59826087,0.39884057999999994,0.099710145,0.19942028999999994,0.19942028999999994,0.19942028999999994,0.149565218,0.19942029,0.5982608700000001,0.39884057999999994,0.498550724,0.149565217,0.149565217,0.19942029000000003,0.099710145,0.009971014,0.049855073,0.19942029,0.97715942,0.099710145,0.099710145,0.79768116,0.19942028999999994,0.19942029000000003,0.099710145,0.29913043500000003,0.19942028999999994,0.09971014499999997,0.099710145,0.39884057999999994,0.39884058,0.19942028999999994,0.498550724,0.79768116,0.099710145,0.099710145,0.19942028999999994,0.19942029,0.19942029,0.29913043500000003,0.19942029000000003,0.149565218,0.099710145,0.498550725,0.079768116,0.34898550700000003,0.049855072,0.179478261,0.79768116,0.5982608700000001,0.24927536200000003,0.049855073,0.59826087,0.19942029,0.08973913,0.19942029000000003,0.149565218,0.20939130400000003,0.249275363,0.049855073,0.009971015,0.19942029,0.099710145,0.099710145,0.6979710149999999,0.099710145,0.7179130439999999,0.19942029000000003,0.099710145,0.099710145,0.39884057999999994,0.29913043500000003,0.19942029,0.99710145,0.099710145,0.19942029,0.29913043500000003,0.19942029,0.079768116,0.19942029,0.19942028999999994,0.19942028999999994,0.099710145,0.14956521700000003,0.0,0.099710145,0.19942029,0.099710145,0.169507246,0.0,0.14956521800000003,0.079768116,0.099710145,0.099710145,0.19942029,0.099710145,0.009971015,0.14956521800000003,0.099710145,0.129623189,0.099710145,0.099710145,0.099710145,0.857507247,0.099710145,0.39884058,0.19942028999999994,0.19942029,0.049855073,0.0,0.099710145,0.099710145,0.009971015,0.099710145,0.4,0.4,0.45,0.4,0.7,0.3,0.35,0.35,0.6,0.55,0.3,0.3,0.9,0.1,0.4,0.8,0.4,0.7,0.75,0.7,0.45,0.6,0.5,0.19,0.55,0.7,0.55,0.4,0.55,0.5,0.6,0.65,0.55,0.55,0.29,0.5,0.65,0.1,0.3,0.7,0.35,0.5,0.55,0.6,0.55,0.45,0.2,0.55,0.25,0.55,0.6,0.05,0.6,0.15,0.4,0.05,0.4,0.35,0.55,0.55,0.5,0.2,0.2,0.4,0.6,0.15,0.24,0.04,0.14,0.15,0.4)) #Inits for one chain list(kappa = c(-2.0, -8.0), beta1 = -0.5, beta2 = 0.1, beta3 = -0.1, beta4 = 0.3, theta1 = 0.4, theta2 = 0.1, K = c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1))