## Conjugate priors model { for( i in 1 : N ) { y[i] ~ dnorm(mu[Z[i]], pre.phi[Z[i]]) Z[i] ~ dcat(lambda[1:2]) logp1[i]<-log(lambda[1])-.5*log(2*3.1415926)-.5*log(phi[1])-(y[i]-mu[1])*(y[i]-mu[1])/(2*phi[1]) logp2[i]<-log(lambda[2])-.5*log(2*3.1415926)-.5*log(phi[2])-(y[i]-mu[2])*(y[i]-mu[2])/(2*phi[2]) p1[i]<-exp(logp1[i])/(exp(logp1[i])+exp(logp2[i])) p2[i]<-exp(logp2[i])/(exp(logp1[i])+exp(logp2[i])) } lambda[1:2] ~ ddirch(alpha[1:2]) mu[1] ~ dnorm(0.0, pre.phi[1])I(mu[2],) mu[2] ~ dnorm(0.0, pre.phi[2]) pre.phi[1] ~ dgamma(0.001, 0.001) pre.phi[2] ~ dgamma(0.001, 0.001) phi[1]<- 1/pre.phi[1] phi[2]<- 1/pre.phi[2] } list(lambda=c(.5,.5), mu=c(0,0),pre.phi=c(1,1)) list(N=1000, alpha=c(1,1), y = c( 3.623655, 1.096953, 0.2174791, -0.1192961, -0.1662829, -0.1677109, 3.983588, 4.080929, -0.5506043, 3.446154, 1.458486, 0.5679601, 5.613555, 6.843197, 8.346835, 0.0829217, 0.4845252, 0.9529833, 9.925709, 2.405290, -0.496623, 5.941432, -0.03876942, -0.2704449, 8.783016, 6.435911, 0.5202152, -0.952514, 1.128270, 5.199736, 1.284314, 0.3487484, 0.6926328, 0.2722405, -0.07480314, 3.554874, -0.3873216, -0.8527172, 2.600382, 0.1962196, -0.5759651, 0.1960225, 4.652516, 2.377473, 1.080788, 2.767835, 1.948462, 6.120879, -2.204363, 3.990736, 0.09909687, 7.126, 3.266743, -0.781587, 1.385035, -1.515873, 0.7604969, 5.239476, -0.7810075, -2.112273, -0.8962548, -0.2322774, 4.062501, 3.943698, 2.981816, 4.646557, 0.4451306, -0.1587309, 6.044342, 0.4780666, 0.1718661, -1.126201, -0.9035515, 3.180276, 1.578719, -0.517471, 7.326191, 6.42566, 6.849982, -0.415488, 3.625519, -0.1552590, 7.197843, 1.239693, 0.621925, -0.7020599, 2.551053, 6.057402, 0.6773678, 4.805915, 4.827907, -0.004041946, 2.771336, 5.928311, 0.1181945, -1.325952, -0.5122566, -0.8158906, 7.582114, 0.4887226, 6.339158, -2.657906, 4.754902, 0.1716992, 6.739238, 0.3549349, -0.1702516, 9.05, -0.1736424, 1.982307, 6.356948, 3.675462, 2.819516, 6.769706, 2.706058, 4.738541, -0.1181318, 0.2812583, 0.5277446, 1.95751, 0.7315932, 3.903956, -0.2273726, 0.3340089, -0.2821605, -0.632348, -0.2247839, -1.545563, 1.579062, 1.485326, 4.412705, 4.011167, -1.937565, 5.322677, -0.881932, 0.4745573, 6.959735, -0.7297847, 0.2322833, -2.196259, 0.4946545, 4.14456, 2.041392, 4.954113, 4.219542, 1.221677, -1.392777, 0.8556374, 4.014428, 0.2187606, -0.4341343, 6.544354, -2.060578, 3.461978, 1.068309, 8.157756, 0.9458366, 6.046402, 6.082575, -0.2592742, 4.65038, -0.3045648, 0.7369507, 1.323881, 3.111926, 0.6268732, -0.9924578, 4.876031, 0.7379787, 6.229401, 0.3222742, 0.008661216, 1.561435, 0.7104481, 5.001778, 0.3719042, 5.469267, 0.815582, 0.996673, 1.784063, -0.1024761, -0.1350676, 2.676801, 0.5275363, 0.6095097, 5.024753, 0.1030021, 1.595923, 4.483312, 4.576315, 2.017268, -1.912675, 1.530236, -0.3475403, 0.05128359, 0.4003435, -0.09285293, 6.139883, 3.821568, 8.499429, 4.6956, 6.589402, 0.7725463, -1.219162, -0.3633373, 1.058960, -0.7983004, 0.1427686, 6.43814, -0.2092539, 1.725671, -2.506453, -1.198272, -1.332815, 5.562735, -0.7104682, -0.4897053, -1.099025, 4.606093, -0.2777012, 3.956358, 4.029228, 7.838752, 5.734394, 1.457112, 7.231546, 0.5809084, 0.7719262, -1.76562, -1.217048, 1.218291, 1.474356, 7.730132, -0.8816145, 0.2524417, 7.135295, 0.5402161, -1.101712, -0.9173628, 5.582344, -1.455339, 0.2919713, -0.9644966, -1.130084, -0.8928926, 8.037649, 0.1075949, 6.251007, -0.4821985, 5.20005, 0.2660408, 0.6548507, -0.4369367, 5.736901, 0.3397872, 3.366904, 0.1871713, 3.794976, 1.541892, 6.60401, 2.393942, 3.299319, -0.1389785, 0.7709464, -0.3151726, 5.705272, -0.3937707, -0.8259532, -1.384833, 4.624024, 1.639649, 4.145119, 0.7237797, 1.190548, -1.720183, 3.411727, -0.03507232, -0.2471328, 2.236088, 8.6309, -0.03259049, -0.2382083, 3.340350, 6.02946, 2.748736, 1.384109, 1.015702, 0.02352811, 9.05011, 1.55766, -0.6838386, -0.6544028, 5.094727, 0.5457705, 0.7954277, -0.1671122, 4.870676, 1.660272, -0.5628323, -1.127873, -0.3234324, 6.125928, -0.2651687, 2.207601, 0.09740675, 4.913892, -0.3639942, -0.7921131, 3.920344, 5.334927, 1.038880, 8.657327, 0.5121858, 1.562158, 1.187973, 7.757577, 0.526289, 5.047511, -1.427625, -0.7040735, 6.977588, 6.032281, 0.3773087, 2.033826, 7.91456, 0.3881107, 1.438528, 6.022596, 6.033989, 0.7944684, 4.439508, 0.04120003, 1.474817, 4.658797, -1.335061, 2.036218, -1.966324, -2.131961, -2.302296, -0.8628095, -1.358554, -0.3983539, -0.3961469, 4.47088, 5.651734, -0.5785541, -0.8107773, 3.996682, -1.119587, 6.14235, -0.02177812, -1.795661, -0.05859081, 0.857062, 3.600603, 6.587038, 0.1175803, -0.8906881, -1.262643, 7.935533, 0.5242744, 4.901638, 0.1328714, -0.821666, 1.432507, 0.05375414, 7.634952, 0.8972624, 5.366777, -1.31494, 4.37799, 6.981807, 0.1179211, 9.148644, -0.3297888, -1.762095, 6.220465, 4.868409, 0.5639891, 0.8999773, 4.315781, 6.268156, 4.351839, 0.06854247, 0.3595675, -0.2728393, -1.111156, -1.082906, 5.93535, 4.985832, -1.210783, -0.1803934, 4.2752, 8.40558, 9.956233, 0.1032254, -1.200655, 0.852402, -0.4280592, 0.9963288, 3.935061, 7.676003, -1.162172, -0.3600489, 4.837653, 0.7789647, 0.0966347, 0.9161357, 1.476657, 0.1338403, -0.5579741, 5.964886, 5.877733, 0.4190983, 3.596278, 0.658169, 6.99145, 0.2394932, -0.1566897, -0.1646109, -0.3777976, -0.2089164, 3.047487, 1.630284, 0.07273347, 8.110956, 8.422997, -0.673345, 0.1194130, -0.71995, 4.69401, 0.5505602, 0.8246965, 0.7400818, 1.600744, -0.06531223, 3.428916, 6.002062, 2.604528, 5.146743, 5.416529, 6.987324, 5.71066, -0.002089117, -0.2701018, -0.04333889, 1.324384, 7.430379, -0.6908572, 0.9388628, 2.531512, -0.5884002, -0.6193512, 0.8024731, -1.063799, -0.8016526, 6.938414, 0.3113894, -0.5781625, -2.151330, 3.100555, -2.120727, -1.257035, -0.06920343, 2.427636, 1.657297, -1.025360, 5.28459, 6.43068, 0.1862560, -0.7148229, -0.5490291, 0.4163974, 5.953244, -0.4691897, -0.842513, 6.40078, -0.4052144, -1.092413, -1.951578, 0.3596326, 1.865451, 6.685135, 4.40902, 0.4358727, 7.405479, 4.597718, 1.383152, 4.951614, 2.175282, 1.915639, -0.4758344, -0.6036503, -1.514612, 7.162896, 1.318003, -1.412232, 0.552603, 0.4506982, -1.850770, 4.783767, -2.445756, 0.1314774, 0.4778569, 3.951399, 6.42101, 2.45009, 3.136991, -0.874858, 6.321158, -0.3884848, 3.062558, 1.046135, 0.3140041, 0.2209138, -0.8541809, -0.8711546, 0.5609335, 8.496564, 0.3202174, -0.2983804, 0.3843068, 3.600886, 0.07764906, 7.145407, 0.594622, -0.892421, 0.7705422, -2.307180, 1.006365, -0.3422835, 2.678392, -1.197591, 2.145322, 0.1846409, 0.7794002, 3.983451, 4.97327, -1.787288, -0.3425656, -0.05134248, 5.283391, 0.2802641, 1.550394, 1.648273, 3.647180, -1.066113, -0.2799736, 0.612595, 7.35346, -0.564692, -0.6249344, -0.3373417, 1.056867, 1.204763, 4.931695, 3.742539, 0.21501, 2.804543, 6.918563, -0.1641983, -0.8996253, 5.156037, 1.768921, -0.1761440, 1.112957, 6.944134, 0.8969015, 5.51817, 6.046748, 6.459257, 4.051914, 0.1263439, 6.351357, 3.757005, -0.1381371, 3.027784, 5.385505, -1.748242, 4.554771, 4.98859, 6.639003, 6.057056, -1.837682, 9.03567, 3.946582, 0.4293811, 0.1641559, 5.435013, 1.369322, 6.879996, 2.765181, 4.605145, 3.800386, -1.426672, 1.135361, 0.9534309, 6.817315, 1.721287, 0.4695189, -0.3852664, 8.827872, -1.321806, 0.05587473, 0.655231, 7.897838, 5.375863, 7.955371, 0.2827649, 0.3560684, 3.428322, -0.5837052, -0.4698969, 6.118459, -0.5809885, 6.06481, 4.867193, 0.6883121, 3.62607, -0.09707656, 3.822432, 6.081629, 1.971046, -1.365076, -3.271462, 3.977379, 4.968187, 0.3695270, -0.06041946, 5.818001, 4.95346, 0.466167, 6.049069, -0.07857798, 7.78678, -1.000559, 1.356943, -0.02685115, 4.859117, -3.464197, -0.3763922, -1.99056, 6.048845, -0.06338856, 0.1887801, 0.9859042, 5.207603, 4.932657, 0.9780082, -0.1822467, 0.1606480, 0.8617028, 3.421722, -0.359635, 3.203479, 2.175159, 0.5638836, 1.462144, -1.480637, -1.287957, 3.506297, 4.417554, -1.858289, -0.6346996, -1.021108, -2.546529, 0.8819647, -0.1664624, -0.5632003, 0.7387368, 0.5604892, 0.1375200, -0.1687945, 0.3651818, -1.401764, 8.336203, 0.8318837, 4.574808, 1.948707, 0.5755491, 1.840602, 4.102608, 1.880644, 2.487911, -0.5194417, 6.025018, 1.062599, 6.170778, 4.40593, -0.3454069, -1.050014, 4.370917, 4.127605, 1.777873, -0.8667663, -1.142256, -1.125529, 0.6646164, 7.736442, 0.3145168, 0.7893892, 0.6793359, -1.662700, -0.06414228, 0.6796891, -1.458678, 3.354289, 0.6199114, 2.807004, 2.39061, -0.01595343, -0.3546487, 7.178551, -0.4462636, 5.875362, 2.901634, 3.112909, 3.02936, 1.128882, 1.486410, 4.564333, -0.08785533, 0.9414582, -1.901701, 4.97796, 5.512651, -0.1863617, 0.7592755, -0.07754513, 6.071236, 0.4285912, 0.9305101, 1.889225, -1.205019, 0.3539077, -0.9786053, 5.239267, 1.563514, 0.4323029, 2.611831, 7.345346, 6.541732, 0.7144983, 1.286564, 7.285618, -0.4277172, -0.8083875, 2.366710, -1.466326, 5.33495, 7.304883, 1.152153, 6.902972, 0.3234059, -1.585320, -0.2617203, -2.049927, -1.010745, 10.56947, 0.6352639, 1.532788, 3.868337, 4.821708, 5.453736, 6.13412, -1.034575, 5.210901, 6.034382, -0.9863176, 6.85009, -0.5156473, 0.1528912, 4.415647, 4.203104, 5.954109, 2.113211, 1.184788, 3.476852, 0.3786101, 3.265003, 7.055015, 0.6299458, -0.4697613, 0.2232904, -1.11594, -0.04241363, 1.148263, 3.787437, 0.1509171, 4.631692, 3.144919, 0.1762576, 3.784, 0.2736483, 1.624853, -0.1105426, 0.5415151, 1.695637, -0.9849835, 0.5490469, 3.565459, 1.984420, 3.974568, 0.1096648, -0.4022216, 6.092565, 1.427157, 0.434604, 1.100397, 7.052152, 1.860260, -0.8322556, 5.953829, -0.1642542, 0.03375984, -1.438278, -0.864863, -1.963516, 6.19412, 3.069697, 0.8421585, 6.134709, 0.9728607, -0.3239025, 0.5347682, 3.071665, 0.4570507, 0.4203694, 0.2684414, 7.848418, -0.2983825, 0.8142475, -0.933454, 5.667423, 0.855407, 5.335484, 1.019124, -0.7788112, 7.44709, 1.100260, 4.121441, 6.124425, 1.406054, 0.1390594, 1.304648, -1.256155, -0.9245837, 6.208028, 8.633988, -0.360939, 0.5874556, 1.185038, -0.2618013, -1.075133, -0.8313344, -1.550225, 1.181932, 4.644681, 1.135249, -0.4556776, -1.264781, 2.100717, -0.8601587, 1.872909, 6.10283, 0.7272144, 5.155327, 6.307467, -0.1710551, 7.516342, 5.784183, 5.567067, 4.626417, 0.4855419, 4.62874, -2.352517, 0.3418284, -0.4048766, 2.034763, 0.7917704, 0.5514321, 0.3742397, 7.851191, -0.8078994, -2.215916, 1.863918, -0.4585765, 3.919009, 3.096434, 0.502642, 5.161685, 6.075976, -0.4055948, 2.967874, 2.858776, -1.311859, -0.0894172, 0.2431607, 5.213724, 1.665073, 3.945278, 0.8933346, -0.3214089, 3.919633, 7.481147, -0.6789199, 0.4854114, 5.922061, 7.136073, -0.5089316, -0.382842, 0.8055636, 4.021418, -1.605956, -0.4610455, 0.5090829, 1.162763, -0.6174152, -1.713347, 3.793386, -1.238141, 0.4893514, 7.017945, -0.7083203, 0.622632, 4.628397, -1.445176, 1.046388, 2.379214, -0.02499280, 0.1280601, 0.8610709, -0.8570621, -0.2390020, -1.237624, 1.194486, -0.3824236, 5.450556, 0.7715736, 0.930861, -0.4208599, 4.130147, 2.217185, 3.921104, 0.2149174, 0.8789787, -0.9660943, 6.014163, 5.192055, -0.4898543, 2.124643, 0.7836893, -0.5218388, 3.803181, -1.877081, 0.3821996, 5.700625, -1.787191, 3.412175, 0.007665198, 0.01496623, -0.4545641, 2.017860, 4.804836, 8.374986, 0.2812190, 5.139301, -0.6753876, -1.705484, 0.8160214, -0.635348, 0.6029163, 0.68534, -0.1492801, 0.3182815, 0.6469437, -0.7623378, 5.10803, -0.1073129, 0.4823698, -0.3345013, -0.1493109, 1.064519, 5.620422, 3.957887, -0.680636, 6.82349, 0.6970043, 7.819763, 1.300713, 0.2729321, 1.167169, 8.19313, 1.567174, 1.044072, 1.092456, -0.4567341, 0.2262841, -1.096101, -0.8233387) )