lab:projects:12bayesian_random_coefficients_lcsm:another_way
model{ for (i in 1:N){ R[i, 1] ~ dnorm(0,1) R[i, 2] ~ dnorm(0, 1) LS[i, 1]<-mu[1]+sigma[1]*R[i,1] LS[i, 2]<-mu[2]+rho*sigma[2]*R[i,1]+sigma[2]*sqrt(1-rho*rho)*R[i,2] Y[i,1]~dnorm(y[i,1],inv_sig_e2) y[i,1]<-LS[i,1] for (t in 2:T){ Y[i,t]~dnorm(y[i,t], inv_sig_e2) d[i,t-1]<-gamma[i,t-1]*y[i,t-1]+LS[i,2] y[i,t]<-d[i,t-1]+y[i,t-1] ## another way to deal this gamma[i, t-1]~dnorm(mugamma[i,t-1], inv_sig_v2) mugamma[i, t-1]<-beta0+beta1*X[i,t-1] + beta2*Z[i] } } inv_sig_e2~dgamma(.001,.001) inv_sig_v2~dgamma(.001,.001) beta0~dnorm(0,.00001) beta1~dnorm(0,.00001) beta2~dnorm(0,.00001) mu[1]~dnorm(0,.00001) mu[2]~dnorm(0,.00001) rho~dunif(-1,1) sigma[1]~dunif(0, 100) sigma[2]~dunif(0,100) sig_e2<-1/inv_sig_e2 sig_v2<-1/inv_sig_v2 para[1]<-mu[1] para[2]<-mu[2] para[3]<-sig_e2 para[4]<-sig_v2 para[5]<-sigma[1]*sigma[1] para[6]<-rho*sigma[1]*sigma[2] para[7]<-sigma[2]*sigma[2] para[8]<-beta0 para[9]<-beta1 para[10]<-beta2 } list(beta0=-.3, beta1=0,beta2=0,inv_sig_e2=1,inv_sig_v2=.1, mu=c(3,10), sigma=c(1, 1), rho=0) list( N = 5.00000E+01, T = 4.00000E+00, Y = structure(.Data= c( 4.23404E+00, 1.32844E+01, 1.46466E+01, 2.33524E+01, 2.14908E+00, 9.78653E+00, 2.70382E+01, 3.65719E+01, 3.13874E+00, 9.77582E+00, 1.60261E+01, 2.09036E+01, 5.11282E+00, 1.58505E+01, 3.31061E+01, 5.19310E+01, 4.87703E+00, 1.32259E+01, 1.79121E+01, 1.03362E+01, 1.98311E+00, 1.18585E+01, 2.10876E+01, 1.92877E+01, 5.47212E+00, 1.26731E+01, 2.04918E+01, 2.30256E+01, -6.80065E-03, 1.10423E+01, 2.60290E+01, 1.91622E+01, 5.11084E+00, 1.68880E+01, 2.82623E+01, 3.23386E+01, 3.18153E+00, 1.30804E+01, 2.40994E+01, 5.14015E+01, 3.04348E+00, 1.17282E+01, 2.03399E+01, 2.25818E+01, 4.81461E+00, 1.31417E+01, 2.17128E+01, 1.78869E+01, 3.03277E+00, 1.32119E+01, 1.73768E+01, 3.11319E+01, 1.71402E+00, 1.17253E+01, 2.37808E+01, 2.08102E+01, 3.58799E+00, 1.20675E+01, 2.03234E+01, 3.17517E+01, 3.21962E+00, 1.22840E+01, 2.35565E+01, 2.91010E+01, 6.19735E+00, 1.17647E+01, 2.65895E+01, 2.25164E+01, 2.09909E+00, 1.09637E+01, 8.30040E+00, 1.15004E+01, 3.61149E+00, 1.35752E+01, 1.91100E+01, 2.78649E+01, 5.81782E+00, 1.64120E+01, 1.97554E+01, 2.10915E+01, 1.70104E+00, 1.04412E+01, 2.58749E+01, 3.84123E+01, 7.10339E+00, 1.48618E+01, 2.71580E+01, 3.00041E+01, 4.37767E+00, 1.39435E+01, 2.32272E+01, 4.25704E+01, 4.22520E+00, 1.25732E+01, 1.66263E+01, 2.12438E+01, 4.68213E+00, 1.48841E+01, 2.25490E+01, 2.80671E+01, 2.64554E+00, 1.38908E+01, 2.47539E+01, 3.46717E+01, 5.05497E+00, 1.31801E+01, 2.13174E+01, 2.38821E+01, 4.23947E+00, 1.53044E+01, 1.49105E+01, 3.18620E+01, 4.03010E+00, 1.50678E+01, 2.61725E+01, 4.85673E+01, 2.95479E+00, 1.18974E+01, 9.21916E+00, 1.32482E+01, 2.88802E+00, 1.12735E+01, 1.60424E+01, 1.97418E+01, 3.06133E+00, 1.12464E+01, 1.84681E+01, 9.15314E+00, 4.50616E+00, 1.38978E+01, 2.58506E+01, 4.57109E+01, 3.68238E+00, 1.68993E+01, 1.81783E+01, 2.48254E+01, 5.56195E+00, 1.28138E+01, 1.97437E+01, 2.71259E+01, 7.20660E+00, 1.14999E+01, 2.69111E+01, 3.65339E+01, 3.15676E+00, 1.31574E+01, 1.05931E+01, 2.09977E+01, 2.55719E+00, 8.25013E+00, 2.50750E+01, 3.46040E+01, 9.85460E-01, 1.25908E+01, 2.08798E+01, 1.69063E+01, 3.95112E+00, 1.45803E+01, 1.36597E+01, 1.66281E+01, 1.39675E+00, 1.08481E+01, 1.83309E+01, 2.01725E+01, 4.90681E+00, 1.00314E+01, 1.77825E+01, 2.50305E+01, 4.11108E+00, 1.23962E+01, 3.33673E+01, 2.83138E+01, 2.89318E+00, 8.44652E+00, 2.12057E+01, 1.91462E+01, 1.40842E+00, 1.17782E+01, 1.44903E+01, 2.66688E+01, 5.42093E+00, 1.23948E+01, 2.76062E+01, 4.09934E+01, 2.71731E+00, 1.25005E+01, 1.29187E+01, 1.76844E+01, 4.63556E+00, 1.68435E+01, 1.82179E+01, 2.29786E+01, -1.85168E-01, 1.16842E+01, 1.63619E+01, 1.94785E+01, 1.71617E+00, 1.14681E+01, 2.13474E+01, 4.43694E+01 ), .Dim=c( 50, 4 )), X = structure(.Data= c( -8.87653E-02, 8.14119E-01, -1.16274E+00, -1.88688E-01, -1.11660E+00, -1.07114E+00, 7.04477E-02, 1.30248E+00, 2.38428E+00, 1.58751E+00, -8.58037E-01, -2.94048E-01, -2.07554E+00, -1.57987E+00, -5.68055E-02, -1.08180E+00, 2.70129E-01, 4.78497E-01, 4.58021E-01, -3.92343E-03, 1.48787E+00, -8.51051E-01, -8.33961E-01, 6.38412E-01, 4.19383E-01, 7.13331E-01, -8.13562E-01, 7.71553E-01, -1.88839E-01, -1.64818E+00, 1.32912E+00, 2.76874E-01, -1.37096E-01, -5.63047E-01, -1.60003E-02, -8.65532E-03, 5.50725E-01, -2.37192E+00, -6.14014E-01, 2.20681E+00, 1.65440E+00, -4.98169E-01, -3.59221E-01, 5.02011E-01, 5.81998E-01, 1.02983E-01, 8.57243E-01, -1.26046E+00, 8.59259E-01, 1.12566E+00, -1.71410E+00, 1.35089E+00, -7.64307E-01, 9.85834E-01, -2.40122E-01, -1.27499E+00, 4.75697E-01, 1.00145E+00, -3.53051E-01, 1.36803E-01, 6.28294E-01, -9.09355E-01, 1.21605E+00, -2.47853E-01, -8.60624E-01, -3.78015E-01, 3.23467E-01, 1.32409E+00, -2.24419E-01, 1.27209E+00, 5.23067E-01, 1.15431E+00, 1.01202E+00, -9.09038E-01, 2.63008E-01, -7.97392E-01, 8.17423E-02, -8.70621E-01, 2.81166E-01, 4.90124E-02, 1.17444E-01, -2.94430E-01, 7.88846E-01, 2.72886E-01, 5.31499E-01, 1.17909E+00, 1.61258E-01, -1.48111E-01, 2.52952E-01, 6.47164E-02, 7.55938E-01, -1.05433E+00, -1.08179E-01, -9.57834E-02, -1.10360E+00, 7.05996E-01, -2.00728E-01, 3.17171E-01, -1.48205E+00, 9.31669E-01, 7.57241E-01, -7.92316E-01, 1.33482E-03, 7.76769E-01, 8.03584E-02, -2.82534E-01, -3.01672E-01, 9.66714E-01, -1.01022E+00, 1.63710E-01, 8.38534E-01, 2.13153E+00, -1.43855E+00, -6.04834E-01, -3.22229E-01, 8.98923E-01, 1.17218E+00, 2.24101E+00, 4.85473E-01, -8.55590E-02, 9.10237E-01, 1.54365E+00, 1.00763E+00, -9.51643E-02, 1.46674E+00, 1.48368E+00, 1.69306E+00, -2.90179E-01, -6.65586E-01, -2.48867E-01, 2.76792E-01, 6.58765E-01, 6.51560E-01, -8.96694E-01, -4.44640E-01, 7.44132E-01, 5.36241E-01, 1.91411E-01, -3.74544E-01, -3.91907E-01, 5.00803E-02, -2.05469E+00, -1.73288E-01, 9.38950E-01, 2.65701E-01, 8.50842E-02, -9.06614E-01, 4.73214E-01, 2.35286E+00, -1.92283E+00, -7.20006E-01, 3.94607E-01, -7.25979E-01, 1.21420E-01, 2.39918E-02, 1.63516E-01, 5.04846E-01, 1.75267E+00, -6.51923E-01, -2.23516E+00, -7.48080E-01, 7.05284E-01, 7.47302E-01, -1.90801E+00, 5.04245E-01, 3.98684E-01, 2.22335E-01, 5.89681E-01, 7.78043E-01, -1.47458E+00, -1.48164E-01, -2.26917E+00, 2.06848E-01, -6.62376E-01, 1.40482E+00, 6.53021E-01, -4.99125E-01, -1.69649E-01, -1.08879E-01, 1.27213E+00, 5.47097E-02, -7.74974E-01, -1.65907E+00, 9.28118E-01, 7.34072E-01, 1.95174E+00, 1.00826E+00, 3.30395E-01, -2.85453E-01, 5.25410E-01, -5.26419E-01, 6.76883E-01, -9.68277E-01, -1.29115E+00, 2.93278E-01, -8.80198E-01, -2.14701E-01, -9.16919E-01, -5.81513E-01, 9.08934E-01 ), .Dim=c( 50, 4 )), Z =c( 1.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 1.00000E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 1.00000E+00, 0.00000E+00, 1.00000E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 0.00000E+00, 1.00000E+00, 0.00000E+00, 1.00000E+00 ) )
lab/projects/12bayesian_random_coefficients_lcsm/another_way.txt · Last modified: 2016/01/24 09:48 by 127.0.0.1