lab:projects:simple_mediation_model_data_generation_and_estimation_through_re-parameterization
## data generation model{ for (i in 1:n){ y[i]~dnorm(muy[i], pre_y) muy[i]<-iy + b*m[i] + c*x[i] m[i]~dnorm(mum[i], pre_m) mum[i]<-im + a*x[i] x[i]~dnorm(0,1) } } ## population parameter values list(n=500, iy=0, im=0, a=.39, b=.39, c=0, pre_y=1, pre_m=1) ## parameter estimation model{ for (i in 1:n){ y[i]~dnorm(muy[i], pre_y) muy[i]<-iy + b*m[i] + c*x[i] m[i]~dnorm(mum[i], pre_m) mum[i]<-im + a*x[i] } iy~dnorm(0, 1.0E-6) im~dnorm(0, 1.0E-6) a~dnorm(0, 1.0E-6) b~dnorm(0, 1.0E-6) c~dnorm(0, 1.0E-6) pre_y~dgamma(.001,.001) pre_m~dgamma(.001,.001) tau<-a*b } ## initial values list(iy=0, im=0, a=.39, b=.39, c=0, pre_y=1, pre_m=1) ## parameter estimation model{ for (i in 1:n){ y[i]~dnorm(muy[i], pre_y) muy[i]<-iy + tau/a*m[i] + c*x[i] m[i]~dnorm(mum[i], pre_m) mum[i]<-im + a*x[i] } iy~dnorm(0, 1.0E-6) im~dnorm(0, 1.0E-6) a~dnorm(0, 1.0E-6) tau~dnorm(0, 1.0E-6) c~dnorm(0, 1.0E-6) pre_y~dgamma(.001,.001) pre_m~dgamma(.001,.001) } ## initial values list(iy=0, im=0, a=.39, tau=.39, c=0, pre_y=1, pre_m=1) ## generated data list(n=500, m = c( 1.436,-1.171,-0.4665,0.9741,-0.8708, -2.092,-0.2641,-0.5893,0.1589,-0.6167, 1.899,0.3424,0.9494,0.02347,0.7029, 0.1858,0.1829,-1.777,-0.1004,0.8475, 0.4793,-1.098,-0.03153,2.309,0.95, -1.04,1.257,0.601,-1.145,-3.434, -0.6539,1.162,-1.53,0.5234,-1.886, 0.1827,1.447,-1.006,0.1696,-0.3526, -0.1517,1.01,-0.08137,0.1517,-1.289, -2.058,0.6589,-1.483,0.2432,-0.3459, -1.128,0.1029,0.2404,0.3797,0.03015, -0.6454,0.4905,-0.6488,-0.06781,-1.888, -0.223,-0.8946,1.317,-2.638,1.366, -0.8151,2.078,0.5277,0.2458,0.4059, -1.282,-0.9085,-0.5928,-2.242,-0.4842, 1.211,0.2836,0.3711,-0.8948,0.3163, -1.298,-0.0884,0.8404,-0.9896,-0.683, 0.1628,-1.63,-0.5291,1.804,-0.8317, 0.3505,0.8275,-0.8784,-0.5764,1.318, -0.3594,-0.1715,-0.7472,-2.555,-0.1681, 0.3191,-0.4486,-0.5813,-0.1759,-0.67, 1.331,1.458,0.8451,-1.177,0.1344, 1.263,-0.4336,-1.29,-0.07023,-2.041, 0.5815,-0.6285,-2.148,-0.7123,2.436, 1.503,-0.5858,0.832,-0.9761,1.043, 0.1624,-0.769,-0.3482,-1.923,0.1463, -0.7484,1.751,-0.8561,1.436,-0.7891, -0.2492,-0.3818,-0.1747,-1.277,0.4514, 0.7822,0.397,0.4374,0.2577,-0.01581, -1.326,-0.5177,-1.525,-0.2938,1.988, -0.3295,-0.1371,0.3817,2.287,1.689, 0.4547,1.312,2.366,-0.8429,0.7685, 0.4464,0.1602,-0.3536,-0.873,-0.09389, 2.085,0.6627,0.9558,0.2005,0.08684, -1.078,-0.7545,0.07803,-1.45,0.3453, -0.825,-0.5384,-0.1143,0.3356,-0.6841, 0.2168,2.384,-0.7358,0.5576,2.102, -1.307,-2.119,-1.075,-1.404,0.2923, 0.336,1.545,1.118,0.48,0.4341, -1.934,-0.8378,-1.609,-2.705,0.1818, -0.9606,-0.7144,-0.5728,-0.4411,0.3711, -0.5734,0.4098,-1.068,-1.25,0.7149, -1.229,2.342,1.002,0.3504,0.8357, -1.778,-0.6546,-0.9983,0.6044,1.238, 0.9593,-0.6025,-0.9919,1.978,0.1085, 0.1952,0.755,-0.6017,-1.099,1.007, 1.628,0.4166,-0.2523,0.3353,-0.5746, 0.9491,1.057,-1.443,0.5035,-0.9151, 1.096,0.6101,-0.5985,-0.2317,-0.7585, -2.043,1.597,0.6273,-0.5031,0.4019, 0.1514,-0.8808,0.9534,0.9813,1.126, 0.4795,1.874,-1.425,-1.108,-0.7763, -3.364,-1.855,-0.5678,0.3117,0.1886, -1.364,0.7258,-0.6085,0.1391,0.6842, -0.8186,-0.664,-0.6872,-0.4144,0.3495, -0.0818,0.5042,-1.476,-1.174,-1.077, 1.348,0.1384,0.6546,-0.1857,-1.505, 1.256,0.8542,-0.2156,0.5248,-0.3654, 0.96,0.1234,-0.9005,-0.7649,-0.9729, 1.06,-0.3832,-0.6747,-0.1787,-0.5101, 2.521,0.1646,-0.1807,-0.0286,0.4578, -0.6126,-1.691,-0.2452,1.722,-0.6831, 0.9817,-0.1898,0.2992,0.1249,1.747, -0.6866,-0.1562,1.422,0.0366,0.304, -1.105,0.7188,-0.6924,-0.7649,1.194, -0.7872,-0.1539,-0.01605,-0.009848,0.1008, -0.5643,1.525,-1.184,0.1287,0.008753, -2.199,-0.8976,-2.128,-0.783,-0.7575, 0.3494,1.242,1.248,0.0874,-1.895, -1.988,0.1851,0.2915,0.2943,-0.8573, -0.7638,1.708,0.2644,0.1571,0.1706, -0.1991,1.424,-0.9708,-0.2374,1.144, -0.6466,0.4739,1.466,-1.883,-2.287, 1.568,1.02,-0.2638,1.137,-0.2934, -2.086,-1.39,-0.3541,1.743,0.4782, -1.142,-1.891,-0.6322,-0.1719,1.443, -0.684,0.6401,-1.338,0.3834,-1.449, -0.0462,1.338,-1.903,-1.619,1.3, 0.8443,-0.1046,1.803,1.371,-0.101, -0.5042,-0.7125,0.6936,0.1582,0.04204, -1.004,-0.01064,-0.8496,-0.591,1.479, -0.7221,0.04977,-0.6239,1.66,-1.266, 1.195,-1.524,0.6237,0.6426,1.224, 0.3781,-1.4,-0.3907,0.4814,-0.5582, -0.218,-0.8199,-0.1623,0.1989,1.577, -1.642,1.04,1.068,-0.3191,0.9234, -1.838,1.771,1.492,-1.35,0.2338, -1.027,0.03282,-0.8525,-2.146,1.058, -1.825,-0.5398,-1.39,0.4023,-1.186, 0.4817,0.2259,-1.091,-0.6104,-0.5527, 1.245,-0.2359,-0.7365,2.101,-2.181, 0.3038,-0.2463,-1.523,2.341,0.1595, -0.7703,1.585,0.6356,0.902,-1.494, -2.572,0.04389,1.041,0.1249,0.6624, 0.2911,0.6164,-1.73,0.0205,-0.8785, 2.054,1.108,-0.4087,2.172,-1.411, -1.512,1.362,-0.4606,-0.1589,-0.2338, -2.262,-0.09985,-1.549,-0.9966,0.5889, -2.487,1.984,-2.071,1.094,-1.75, -0.1514,-0.6988,0.6209,-1.315,0.9067), x = c( 0.7268,-1.347,0.6934,-1.222,-0.7298, -1.966,0.2762,1.136,1.054,-0.7137, 0.9273,1.049,2.14,-0.2541,0.08295, 1.407,-0.9553,-0.8873,-0.1775,0.4261, 1.722,0.6593,-0.7972,0.7611,1.461, -0.2778,-0.8848,0.9539,0.4193,-0.4277, 1.842,-0.1409,-2.647,0.75,-0.4147, 0.2548,0.7219,-0.159,-2.653,0.2147, -0.7239,0.8159,-0.7998,0.2034,0.3791, 0.2171,2.135,-0.8989,-1.179,0.05538, 0.3722,-0.4464,-1.015,0.184,-0.3634, -0.1691,-1.109,-0.2463,0.642,-0.3319, 0.1069,-1.055,0.1845,-1.058,0.184, -0.05419,2.244,1.498,-1.364,2.066, -1.434,0.5002,0.06765,1.694,0.1112, -0.3343,-0.03049,0.316,0.5469,-0.9106, -0.4125,1.854,1.452,-0.05647,-0.3322, -0.9936,-0.2034,-1.505,-0.7053,0.3268, 0.1773,-0.8691,1.018,-0.1818,0.5156, -1.09,-0.5969,0.5746,-1.063,-0.2569, -0.5982,-0.1312,-0.01069,-0.654,0.7122, 0.5298,1.697,0.3725,-0.2945,0.7146, 0.7854,-0.4514,-0.9525,0.3845,0.6027, -0.08839,-1.329,-0.4016,-1.718,0.3138, 0.092,0.1521,0.7558,-0.716,0.2135, 0.5484,-1.215,0.3595,-3.513,0.3632, -0.9559,0.4596,-0.1413,0.4294,-0.4811, -0.5128,-0.6923,1.292,-2.155,0.645, 1.554,0.4515,1.811,-0.6378,0.4902, -1.598,1.596,-1.603,0.3102,3.131, 0.3326,0.5362,-1.433,1.801,-1.076, 0.3043,0.658,0.5718,0.291,0.1897, -0.1378,-0.9354,-0.7053,0.09473,-0.4491, 2.894,-0.1319,0.4497,-0.8367,0.1201, -0.8404,-0.1452,2.29,0.9126,-0.8858, -1.756,-0.1067,-0.9908,-1.735,-0.1651, -0.7916,1.949,0.1908,-0.4855,0.5741, -2.431,-0.7673,-1.18,-0.5578,-0.272, 0.9652,-0.03757,0.2586,1.314,-1.101, -1.639,0.0337,-1.07,-3.295,0.7595, -0.04146,0.05949,0.4275,-0.06416,-0.8153, 0.1289,-0.745,-0.8014,-0.5645,-0.009115, 0.149,1.512,0.4932,0.161,1.724, -1.625,0.6521,1.058,-0.4424,0.2412, 1.295,-1.384,0.5528,0.6105,-1.08, 0.3001,0.4374,-1.225,-1.907,0.03045, -0.1286,-0.753,0.6909,2.36,-1.487, 0.8161,1.97,0.2689,-0.3802,-1.208, -0.6632,-0.623,-0.2432,-0.321,-0.3938, -1.32,-0.745,0.2377,-0.1201,1.06, 0.6176,-0.2678,-0.1211,-0.1335,-0.06997, 0.2633,1.377,-1.509,-0.121,-1.193, -1.708,-0.7563,0.1986,-1.057,0.9926, -1.213,-0.003469,1.123,0.06806,-0.2227, -0.3434,-0.6391,0.4304,-0.3049,-1.463, 2.057,-0.5883,-1.086,-1.086,-2.4, 0.6919,0.9027,0.6235,0.7177,-0.4716, -0.1079,0.2252,-0.8069,-1.209,-0.9545, 1.05,1.765,-0.5672,2.009,-0.9457, 0.2028,-1.213,-0.04914,-0.9393,0.7501, 4.322,-2.569,-0.1927,-1.917,0.1292, -0.433,-0.6052,-1.273,-1.677,2.017, 0.8461,-0.01126,0.4789,0.3858,1.296, 0.03624,-0.2546,1.245,0.6492,0.6553, 1.33,1.644,-0.2538,0.6478,0.007408, -1.862,1.218,0.6993,-0.8529,0.4596, -0.1697,-1.135,-0.4093,0.2038,-0.5126, -1.526,0.6149,-1.888,1.321,-0.5856, -0.9781,1.128,0.4027,-0.934,-0.8022, -0.2632,-0.148,0.1274,-0.01173,-0.03498, -1.908,0.6809,-0.1095,-0.2336,2.108, -2.225,-1.75,-0.8272,0.9795,0.5742, -0.3473,0.5188,-1.56,-2.419,-0.8776, -0.09882,-0.6227,0.7189,1.568,0.1155, -0.4681,0.01116,-0.186,1.465,0.066, -0.6444,0.3426,0.5201,0.08685,1.381, -1.174,1.066,-1.068,0.08598,-1.399, 2.315,-0.5575,0.4512,0.07597,-0.3978, 0.06677,0.6314,1.335,0.6292,0.8647, -0.05519,-1.066,0.3567,0.4519,0.5633, -2.187,0.2228,-0.1939,-0.5851,1.049, -1.281,0.4073,-0.9578,0.1588,0.4504, 0.4141,0.1359,0.158,1.646,1.173, -0.1197,-0.6657,0.06411,0.8186,-1.352, -0.1267,-0.6129,0.7765,0.04691,1.194, -1.204,0.9653,-0.8278,0.2309,-1.013, -1.918,-0.313,-0.03788,-0.9375,1.734, -0.6493,-0.7435,-2.224,-0.0411,0.01718, -0.9088,0.04885,-0.2545,0.713,-0.8745, -0.3665,0.4951,1.328,-0.3757,0.7427, 0.6226,-0.7708,-0.1651,-0.8434,1.392, -1.939,-0.8351,-0.905,1.161,-1.225, -0.09806,-0.8582,1.01,0.1976,-0.4067, -2.095,1.013,1.35,0.7232,0.2442, -0.2188,0.7797,-0.947,0.2046,-0.4777, 0.4234,0.03716,1.08,3.338,-0.6489, -0.3239,-0.08111,-0.001173,-0.002428,-0.6389, 0.12,-0.7227,-0.7595,-0.04192,-0.266, -0.4492,0.173,-2.59,0.824,-0.2049, -1.391,-0.6091,-0.1188,-0.7259,0.1651), y = c( 1.687,-1.714,0.2075,-1.296,-0.1814, 0.03589,0.2371,1.225,0.02466,-2.097, -0.4938,1.111,-0.5632,-1.081,1.498, -1.087,0.09941,0.0673,-0.2853,1.5, 0.8961,-0.06093,0.2599,0.1511,0.5461, -0.6331,1.141,0.9293,-1.743,-0.08869, 0.3153,1.103,-0.4037,-0.9448,-1.617, -0.4861,-0.8862,1.691,0.7784,-0.7122, 0.7127,-1.399,0.7656,-0.3526,-0.5538, -2.122,1.258,-2.074,-1.791,0.391, -1.157,1.3,-0.5924,-0.7441,1.162, -1.462,-1.231,-0.05855,-0.5463,-0.4216, -1.265,-1.865,1.78,-1.163,-0.03796, -0.09314,-0.9131,-0.04154,0.5721,1.546, -1.072,0.424,-1.551,-1.449,-1.451, 0.003975,-0.7263,1.243,1.967,0.6332, -2.102,1.778,-0.8065,-0.08387,-0.1315, 0.3754,0.9006,-0.03687,0.9804,0.4776, -0.6221,0.7224,-1.555,-1.766,-0.3771, -2.413,0.3581,0.3079,-2.226,-0.5556, 0.8923,0.9566,-1.369,-0.2859,-0.609, 1.171,-0.1186,0.8114,0.009754,-0.04325, -1.171,-1.057,-1.74,1.286,-0.9632, -1.83,1.197,-0.6332,0.663,1.183, 1.705,0.4416,-0.1564,-0.703,-0.06847, -0.9842,1.488,0.1157,0.2919,0.01924, 1.327,-1.312,-0.4243,-0.4305,-2.085, -0.2928,1.013,-1.593,-0.9678,1.298, 0.7912,-0.317,-0.08425,1.458,0.7706, -1.166,-1.419,-0.1688,-0.9149,1.123, 0.6958,-0.6969,0.6228,0.676,1.457, 1.322,-1.696,-0.0688,1.691,-1.972, -0.3979,-1.393,-1.122,-2.913,-0.09618, -0.7747,-0.6834,0.6407,0.1402,-0.5672, -1.507,-1.533,-0.186,1.396,0.3528, -0.1158,-0.1836,0.8292,-0.8222,-0.08012, -0.5189,0.5861,-0.7875,-1.134,0.2881, 0.4013,1.564,-2.076,0.1847,-2.065, -0.9182,2.052,0.6697,-0.6635,-0.4018, -2.135,-1.4,-0.3134,-0.4548,1.729, 0.8628,0.008858,-0.8354,-0.5182,0.7914, 0.2187,0.6559,-1.418,-2.084,-0.6814, -0.3948,1.193,1.285,-0.4893,0.433, -0.6822,-0.8324,-0.3074,0.3353,0.1372, 0.008919,-1.524,0.08016,-1.038,1.422, -0.7331,0.5071,-0.9476,-0.9838,0.1618, 0.2304,1.295,0.8719,-1.188,0.4463, 1.098,-0.3193,-0.08922,-0.3336,-0.3688, -0.485,2.929,1.491,-0.07332,-1.316, -1.002,2.097,-0.6572,-0.3846,1.611, -1.762,0.6237,-0.119,0.7812,-1.247, -0.2639,1.175,0.1445,-0.8947,0.2752, 0.8782,-2.604,1.601,-0.2957,1.976, -0.6411,-0.6674,-0.5812,-0.06962,1.182, -0.8411,-1.497,1.449,-2.139,0.1012, -0.7806,1.46,-2.368,-1.543,-1.929, 0.1083,-0.1919,0.2848,0.8775,-0.1105, 0.8809,1.233,0.09585,1.375,1.501, 2.149,-1.092,-0.779,0.155,-0.3826, 0.9281,0.1473,-2.216,1.22,0.4968, 0.8307,-0.5249,-2.2,1.551,-0.4697, 1.654,-2.874,-0.6394,2.076,0.9251, 0.2806,-0.2932,0.4086,1.444,1.379, 1.216,0.9335,0.7638,-1.794,-0.4286, -0.2772,1.155,0.293,-0.5121,0.232, 0.2747,-2.224,-1.365,-0.8823,0.1042, 0.02244,1.81,1.033,-0.375,0.5643, -0.5779,0.3982,-1.514,-0.01897,-0.2866, 1.697,-0.781,2.356,-0.7563,-2.545, -0.2961,1.248,0.3145,0.6136,-0.4453, -2.697,0.3399,1.523,0.8787,0.7233, 0.1642,-0.1572,-1.28,-1.289,0.4266, 0.1741,-0.9849,0.4239,0.559,-0.8059, 1.345,1.593,-0.3292,1.862,-0.8412, -1.046,-1.601,0.9239,0.5314,-0.6535, -0.2766,-1.461,-0.5315,0.5657,0.009261, -1.503,0.5454,-0.9992,-1.126,-1.619, -0.2571,0.5168,-0.364,-0.9077,-1.326, 0.9009,-0.7814,2.018,1.296,1.111, -0.8488,-0.4723,1.175,0.9124,-1.075, -0.7559,0.4963,-1.49,0.7286,0.4911, -1.136,0.3133,-0.3466,-0.2766,-1.125, 0.8214,-1.329,1.403,0.2696,0.8149, -0.1539,-0.8218,1.433,0.1813,-0.312, 0.2997,-0.4102,0.1803,0.6539,-0.7835, -2.464,1.395,0.2545,-1.731,1.035, 0.9875,1.114,0.2249,-0.3621,-1.972, 0.2286,-0.7569,-0.6621,-1.565,-1.623, 0.502,-0.2006,-0.9711,-0.7298,-1.721, -0.05025,0.8711,-0.3697,-0.1123,0.8193, 1.333,1.652,-1.639,1.091,-1.102, 0.1978,0.2792,0.3392,0.792,-0.3127, 0.2465,1.7,-0.1506,-0.2354,-1.109, -2.894,0.7189,0.6475,1.59,0.5897, -0.5005,1.337,-0.6506,-1.207,-0.6223, 3.0,1.819,0.4871,1.393,-0.8504, -0.7558,1.261,0.2729,-0.4641,0.5883, 0.05071,-0.6145,-0.4008,0.5928,-0.9377, -0.7603,1.812,-1.354,-1.64,-0.428, 1.617,0.1358,1.538,1.142,-0.0807))
lab/projects/simple_mediation_model_data_generation_and_estimation_through_re-parameterization.txt · Last modified: 2016/01/24 09:48 by 127.0.0.1