User Tools

Site Tools


lab:zhang:bayesian_exploratory_factor_analysis_using_informative_priors

Bayesian exploratory factor analysis using informative priors

Data generation

model{
   for (i in 1:N){
     f[i,1:2]~dmnorm(muf[1:2], pre.phi[1:2,1:2])
     for (j1 in 1:6){
         muy[i,j1]<-l1[j1]*f[i,1]+l2[j1]*f[i,2]
         y[i,j1]~dnorm(muy[i,j1],pre.p[j1])
     }
   }
}
list(N=200, l1=c(.6,.6,.6,0,0,0), l2=c(0,0,0, .6,.6,.6),
muf=c(0,0),
pre.p=c(1.5625,1.5625, 1.5625, 2.78, 2.78, 2.78),
pre.phi=structure(.Data =c(1.33, -0.67, -.67, 1.33), .Dim = c(2,2)))

Data analysis

model{
   for (i in 1:N){
     f[i,1:2]~dmnorm(muf[1:2], pre.phi[1:2,1:2])
     for (j1 in 1:6){
         muy[i,j1]<-l1[j1]*f[i,1]+l2[j1]*f[i,2]
         y[i,j1]~dnorm(muy[i,j1],pre.p[j1])
     }
   }
muf[1]<-0
muf[2]<-0
for (i in 1:6){
  l1[i]~dbeta(.5, .5)
  l2[i]~dbeta(.5,.5)
  pre.p[i]~dgamma(.001,.001)
}

pre.phi[1:2,1:2]<-inverse(phi[1:2,1:2])
   phi[1,1]<-1
   phi[2,2]<-1
   phi[1,2]~dunif(0,1)
   phi[2,1]<-phi[1,2]
}

list( 
pre.p=c(1.5625,1.5625, 1.5625, 2.78, 2.78, 2.78),
phi=structure(.Data =c(NA, 0, NA, NA), .Dim = c(2,2)))

list(N=200, y = structure(.Data = c(
-2.226,-0.1909,-1.194,-1.218,-1.153,
-0.6484,0.8834,-0.08889,-0.6603,-0.6184,
0.2678,-0.2329,0.2418,0.4796,-0.005651,
0.1539,0.1769,-0.1913,0.1777,0.4438,
-0.984,0.776,0.8142,1.485,0.2186,
-0.356,-0.35,0.3692,0.6646,-0.7837,
-2.954,-0.7462,-1.149,-0.2208,-0.5557,
-0.02962,0.7973,2.989,2.072,1.432,
1.242,1.122,-0.5304,2.044,0.1183,
-0.346,-0.1987,-0.428,-0.5017,0.149,
-1.003,-0.5784,0.2037,-0.6927,-1.568,
-0.9764,-1.015,-0.5815,-0.387,0.1545,
0.4218,-1.777,-0.9423,-2.122,0.2523,
-0.2183,-0.9066,-0.336,0.5689,-0.9381,
-1.663,-1.068,-0.7496,0.4776,0.5958,
0.2396,1.017,0.8639,0.5751,0.7271,
1.392,0.4388,0.8046,0.4908,0.4248,
-0.02883,-0.2789,-0.4718,0.3386,-0.8753,
-1.467,-0.2995,-0.3247,-0.6781,-0.6361,
-1.261,-0.01459,0.5477,-0.502,-0.9546,
0.5431,-0.9155,0.5047,-0.1684,0.002057,
1.183,0.4236,0.5199,-0.3558,-0.5064,
-0.05382,-0.06526,0.3703,-0.3352,-0.2779,
-0.2824,0.01704,1.078,-1.062,0.424,
-0.8289,-0.3397,-0.1966,-0.198,-1.125,
-0.2564,1.716,-0.1124,1.013,1.313,
1.046,0.4722,-0.07736,-1.156,0.3975,
-2.92,-0.4288,-0.7261,1.362,1.429,
0.3993,1.299,-0.3297,1.079,-1.353,
-0.8337,-0.4457,-0.64,-0.8712,-0.1116,
-0.8131,1.31,-0.03067,0.2197,0.6118,
1.063,1.223,0.08734,0.4912,1.205,
-0.09431,-0.2288,2.181,-0.9352,0.2186,
-0.9484,0.2775,0.8156,-0.9119,-0.791,
-0.807,-0.158,-0.2914,-0.198,1.069,
-0.5249,-0.1907,0.3874,-0.9315,-0.8732,
-0.05397,-0.8427,0.378,1.034,0.473,
0.6313,0.3688,-0.2574,-0.279,0.8597,
0.2696,-1.015,-0.8616,0.04148,1.194,
0.0233,-0.6,-0.5718,-1.688,-1.659,
-0.382,-2.224,-1.42,-1.456,0.9567,
2.152,0.1032,-0.9624,-0.3296,-0.4887,
-1.548,0.7375,-0.9474,-0.9847,-0.205,
-0.5354,0.4339,-0.5444,-1.025,-1.201,
-1.018,-0.3731,-0.02057,-0.3771,-0.3502,
0.2374,-0.1654,0.5921,0.01221,1.035,
2.106,0.009944,-0.9289,-0.1397,0.8624,
-0.3719,-0.1356,1.783,-0.2937,1.382,
-0.367,0.3323,-0.2227,-0.6077,-1.187,
-0.06861,0.3062,-1.562,-2.249,-0.1987,
-1.757,-1.696,0.0439,0.3691,0.9241,
-0.3861,-0.5759,-0.1416,0.9141,-0.7872,
0.9702,1.268,0.3763,0.4708,-0.5497,
-1.013,-1.175,-0.6155,0.5105,-0.62,
-0.4945,1.095,0.5165,-0.9384,0.3821,
0.1974,-0.4223,-0.7687,-1.113,0.3898,
0.8322,0.3599,-0.3311,-0.1566,-0.7388,
-0.6836,-0.5663,-0.8341,-0.2028,-0.965,
0.2878,-0.1185,-0.4329,0.87,-1.261,
0.788,-0.9321,-2.421,-1.61,-1.717,
1.287,-0.253,-0.4522,1.365,1.599,
1.614,1.025,2.922,-0.1321,1.073,
0.3457,1.592,0.1001,0.7602,-0.4232,
-0.6262,0.04412,0.7712,-1.289,-1.338,
-0.6758,0.1984,-1.187,-0.4781,-0.4422,
-0.2371,-0.1081,0.6318,0.1979,0.4696,
-0.3926,1.717,-0.3154,0.4647,-0.04605,
0.3411,-0.343,0.1227,1.357,0.972,
0.8744,0.9653,-0.9847,0.472,-0.7419,
0.6947,0.4228,-0.4808,-0.7091,1.31,
-0.07029,-1.007,-1.295,-0.5052,-0.7712,
0.5178,-1.211,0.3574,0.6526,-0.8994,
1.098,0.08478,-0.001652,0.2926,-1.229,
0.6618,0.779,0.8203,-0.5954,-1.148,
-0.2977,-1.0,-0.758,-0.544,-1.923,
-0.3021,0.1649,-0.2217,0.6742,-0.4798,
0.1497,0.0892,0.865,0.9744,-0.5878,
0.6981,0.5351,-0.6232,-0.612,-0.4863,
-2.115,-1.071,-0.5678,-0.4193,-0.2189,
-0.1671,-0.1068,1.144,0.4157,1.24,
1.212,1.969,-1.787,-1.906,-0.9364,
-0.8574,-1.708,-1.312,0.03527,1.198,
-0.8455,-0.02193,0.3907,0.8987,-1.811,
-0.1012,0.2867,0.7043,0.02996,0.4287,
2.782,1.821,0.812,-0.3135,0.117,
2.134,0.1591,1.125,0.6528,-0.4335,
-0.4163,-0.5928,2.764,0.7757,1.499,
1.842,0.5229,-0.1083,-0.3151,-1.362,
-1.217,-0.5144,0.4038,-0.4099,-0.9341,
-0.9721,-0.5759,-0.6528,-0.4316,-0.79,
-0.05896,0.6186,-0.1265,0.3685,0.1707,
1.84,-1.036,-0.309,0.5567,1.046,
1.76,0.8818,-1.2,-0.8885,1.505,
-0.3607,-0.4122,-0.8119,-1.343,0.01754,
-0.02285,-0.09451,0.1128,0.2629,-2.046,
0.2923,-1.623,-2.428,-0.9375,-1.505,
-0.8846,-0.7928,-1.303,1.561,0.911,
0.4494,-0.9673,0.4312,0.4063,-1.067,
-2.388,0.2333,-0.28,-1.15,0.05733,
-0.315,-1.253,-1.126,0.1718,-0.03528,
0.7218,0.3121,-1.522,-0.9081,1.71,
-0.2941,0.1116,0.7847,1.411,1.328,
-0.0547,0.2827,1.826,0.005829,1.079,
-0.4271,-0.9674,-0.8148,-0.9485,-1.284,
-0.121,-1.41,-0.7316,-0.491,-0.3332,
0.1047,1.281,1.471,0.07661,1.114,
-0.2338,-0.1775,0.8104,-0.5222,-1.555,
-0.941,-1.386,-0.7018,-0.1512,-0.9339,
1.384,1.021,2.002,0.3377,-0.5025,
-0.2748,1.256,-0.4366,0.3171,0.3035,
-1.258,-1.047,0.4461,-0.3459,-0.1996,
0.3003,0.2878,-0.5318,-0.6399,0.3354,
1.504,-0.5155,-0.3451,0.9308,1.72,
0.5527,1.311,-0.3649,0.925,0.602,
-0.5937,-0.01715,-0.8124,0.6286,1.209,
0.8553,-0.03556,-0.1483,-0.878,-0.321,
-0.2624,-0.1715,0.4466,1.257,0.5406,
-1.103,-1.639,-0.2425,0.2419,-0.5908,
1.201,-0.3543,-0.1043,-1.297,1.297,
-0.03019,2.928,0.7601,0.329,0.7731,
-0.7779,-0.05815,-1.583,-0.8141,-0.4516,
-0.3181,0.6384,-0.7268,-0.1309,-1.265,
-0.2235,-0.5267,0.1161,1.212,-1.375,
-0.7177,-0.4091,-0.2255,-0.5207,-0.9694,
0.2479,-0.3588,-0.4998,-0.1227,1.105,
0.6904,-0.8466,-0.3515,-0.241,0.1586,
2.015,0.222,-0.6937,-0.3756,-0.8896,
0.08073,0.5166,-0.3248,0.3401,2.028,
0.7476,0.786,1.178,0.07436,0.304,
-1.267,-0.07095,0.809,0.2975,2.068,
1.228,0.7717,1.277,0.4307,0.6771,
1.15,-0.6647,-0.9406,-1.147,-1.147,
-1.424,-0.7754,-2.118,-0.7313,0.2323,
0.1597,-1.549,0.2414,-2.5,0.8806,
0.9177,0.1564,-0.3037,-0.4018,-0.1504,
-0.03665,-0.3018,-0.3515,-0.19,-1.413,
-0.396,-0.2783,-0.2036,-0.3503,0.6402,
0.7277,0.8939,-0.4765,-0.531,0.351,
-1.033,-0.2744,-0.1389,0.4896,-1.05,
-0.1057,0.2538,-0.7512,-1.846,-0.897,
0.2702,-0.3871,0.5335,0.006379,-0.1215,
-0.3858,-0.3986,0.3669,-0.6563,1.887,
0.5433,0.4616,0.2386,1.503,-0.2036,
-0.9248,-1.198,-0.2404,0.4203,0.4081,
0.4245,1.624,0.06924,1.363,1.642,
2.328,0.5883,1.855,2.401,1.166,
1.001,1.122,1.111,2.588,0.4247,
0.2679,-0.3222,-0.879,0.5358,-1.712,
-0.2218,-0.3282,0.4286,-0.1599,0.8434,
0.3475,1.141,-0.7258,0.1301,-0.9203,
-0.5556,-0.4484,0.3496,0.05017,0.5485,
-0.7097,-0.5437,-1.374,-0.772,0.01814,
1.092,-0.6385,-1.278,0.2287,0.1271,
-0.5307,0.4797,-0.6386,-1.304,-1.454,
-0.408,-0.6286,-0.4908,-0.7532,0.4009,
1.366,1.246,0.1645,1.412,0.9068,
0.6568,-0.5553,-1.015,0.354,-0.02125,
0.1595,-0.1184,-0.04798,-0.08557,0.2309,
0.5089,-0.3775,-0.5552,0.9324,-0.8372,
-1.059,-0.3019,-0.528,0.6339,0.9171,
0.2469,0.3572,-0.3818,-0.6421,0.6075,
-0.436,0.4937,0.1874,0.705,0.3845,
-0.9227,-1.042,-0.07705,-1.007,-0.4671,
-1.01,-0.2491,0.7991,-0.03121,-0.1522,
-0.8759,-0.04598,-0.4627,-1.506,0.3,
0.4439,0.4887,0.4336,1.395,1.216,
0.06394,-0.01459,-0.01007,-0.5006,-2.096,
-0.6639,-1.796,0.7087,1.128,0.8323,
-2.062,0.3513,-1.713,0.2815,-0.3599,
-0.3878,0.2386,1.943,1.872,-0.1982,
0.3721,-0.4918,-0.04013,1.062,-0.4619,
-0.1908,-1.121,-0.9181,-0.613,-0.6386,
0.2502,-0.5919,-0.4978,-0.2544,0.7802,
-0.7007,-0.1233,0.4659,0.09699,1.364,
-0.8947,-1.927,0.1746,-0.397,-0.6165,
-1.17,0.3026,0.7749,0.3981,0.8288,
-0.2024,0.4153,-1.324,-0.8616,-0.5739,
-0.5191,-0.6676,-0.4807,-0.1564,0.2422,
-0.3723,0.6467,-0.04328,0.156,0.4715,
-0.1906,-0.3816,0.7196,0.4681,-1.283,
-2.134,-0.1985,-1.102,-0.2741,-1.588,
-1.541,-0.7095,-0.574,0.3598,-0.7003,
0.2653,-0.391,-1.028,0.02481,-1.275,
1.374,-0.008511,-0.1931,0.2244,0.1811,
-0.7472,0.05422,-0.3519,-0.1375,1.012,
-1.144,0.4145,-0.2788,0.6069,-1.24,
-0.01166,-0.4213,0.7064,0.6222,-0.1725,
0.9153,-2.635,-0.6719,-1.283,-0.6997,
-0.7872,-1.013,-0.6486,-1.931,-0.851,
-0.1046,-1.563,-0.39,-1.227,-1.84,
-1.56,0.7114,-0.5102,0.3976,0.7787,
0.3141,-0.3228,0.3348,-0.2202,0.2597,
0.6167,0.7919,-0.5057,-0.4547,0.427,
-1.365,1.13,-0.337,0.5247,0.3828,
0.2478,0.7066,0.5192,0.1413,-0.4766,
-0.6607,-0.5111,-2.24,0.962,1.2,
-0.3038,-0.3353,-0.5637,-0.3039,0.0219,
0.2642,-1.574,0.4143,0.6316,0.4091,
-0.1531,0.105,0.3541,-0.2993,1.093,
0.2687,0.1116,0.7805,0.3042,1.789,
1.141,0.62,-1.984,-0.09801,0.442,
0.00111,-1.245,-0.3443,-1.392,-0.2184,
0.2542,0.06558,0.8205,-1.064,-0.2255,
-1.351,1.589,-1.583,0.05253,-1.986,
0.8908,-0.03761,0.7609,0.9891,-1.076,
0.7183,0.1665,0.3442,-0.1988,0.09824,
0.2751,1.263,1.513,0.2582,0.1635,
1.79,0.6303,0.6317,-0.4637,-2.13,
-0.9924,1.686,-0.154,0.1189,1.649,
0.3611,1.2,-0.3706,0.09056,-1.001,
1.466,-0.1633,-0.87,0.7874,0.747,
1.385,-0.9772,-0.5205,-1.688,-0.813,
-0.9437,-0.5735,0.4421,1.941,-0.2863,
0.9134,0.6152,0.7236,-0.3889,0.4715,
-1.189,-1.049,-0.3279,0.09802,0.8231,
1.24,0.1391,0.3567,0.2174,1.641,
1.204,0.308,-0.1731,-0.7138,-0.6799,
-0.6056,-0.6549,-1.605,-1.251,-1.002,
-0.9453,-1.083,1.27,-0.118,-0.9271,
-0.04509,-0.6348,-1.375,1.311,-0.4966,
-0.9266,-0.256,-1.238,-1.15,0.5601,
0.3004,1.846,-0.1574,0.8155,0.318,
0.1824,-0.3141,-0.8353,-0.5935,-1.084,
-1.064,1.432,0.1977,3.274,1.048,
1.544,1.241,0.3464,0.756,-0.4227,
-0.4096,0.4706,0.7649,0.4248,2.369,
0.4647,0.781,1.772,1.846,0.1711,
0.6603,-0.7089,0.3023,-0.4291,0.7073,
-0.09096,-0.6432,-0.06086,1.198,0.5579,
1.831,-1.966,-1.22,-0.585,-0.8388,
-1.723,-1.208,-2.343,-1.238,-1.165,
1.534,0.6241,0.243,1.174,0.5896,
1.289,1.324,0.9977,0.5515,-0.4412,
-0.8692,0.3114,1.475,0.7815,1.21,
-0.4669,-0.9058,0.4909,-0.2916,-0.4174,
0.7902,1.467,1.049,1.946,0.9489,
0.9283,0.1522,1.74,-1.145,1.11,
-1.14,-0.8966,-0.8255,-1.067,-1.183,
-0.3122,-1.803,-1.411,-1.093,-0.1447,
0.7377,0.8836,-0.4036,-0.7121,-0.1187),
.Dim = c(200,6)))
lab/zhang/bayesian_exploratory_factor_analysis_using_informative_priors.txt · Last modified: 2016/01/24 09:48 by 127.0.0.1