Click to display ⇲
Click to hide ⇱
##Model part model{ for (i in 1:N){ LS[i,1:2]~dmnorm(mu[1:2], inv_sig_LS[1:2,1: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]<-beta[1]*X[i,t-1] + beta[2]*(Z[i]-0.6442308) } } inv_sig_e2~dgamma(.001,.001) inv_sig_v2~dgamma(.001,.001) for (i in 1:2){ beta[i]~dnorm(0,.00001) par[i]<-beta[i] } mu[1]~dnorm(0,.00001) mu[2]~dnorm(0,.00001) par[3]<-mu[1] par[4]<-mu[2] inv_sig_LS[1:2,1:2]~dwish(sigs[1:2,1:2],2) sigs[1,1]<-1 sigs[2,2]<-1 sigs[1,2]<-sigs[2,1] sigs[2,1]<-0 par[5]<-1/inv_sig_e2 par[6]<-1/inv_sig_v2 sig_LS[1:2,1:2]<-inverse(inv_sig_LS[1:2,1:2]) par[7]<-sig_LS[1,1] par[8]<-sig_LS[1,2] par[9]<-sig_LS[2,2] } ## Starting values list(beta=c(0,0),inv_sig_e2=1,inv_sig_v2=1, mu=c(1,1), inv_sig_LS=structure(.Data=c(1,0,0,1),.Dim=c(2,2))) list( N = 104, T = 5.00000E+00, Y = structure(.Data= c( 1.17000E+01, 8.60000E+00, 7.10000E+00, 7.60000E+00, 8.50000E+00, 9.50000E+00, 8.90000E+00, 7.60000E+00, 8.00000E+00, 8.50000E+00, 9.00000E+00, 9.40000E+00, 8.60000E+00, 8.80000E+00, NA, NA, 8.30000E+00, NA, 8.00000E+00, 8.30000E+00, 1.10000E+01, 1.05000E+01, NA, 9.60000E+00, 9.70000E+00, 1.35000E+01, 1.24000E+01, 1.21000E+01, 1.17000E+01, 1.20000E+01, 1.15000E+01, 1.18000E+01, 1.19000E+01, 1.21000E+01, 1.09000E+01, NA, NA, 1.20000E+01, 9.60000E+00, 8.60000E+00, 1.01000E+01, 8.30000E+00, 9.00000E+00, NA, 7.70000E+00, 9.40000E+00, 1.15000E+01, 1.10000E+01, 1.00000E+01, 1.39000E+01, 8.40000E+00, 6.60000E+00, NA, 7.80000E+00, 8.20000E+00, 8.30000E+00, 8.50000E+00, 1.00000E+01, 8.50000E+00, 8.20000E+00, 7.40000E+00, 7.50000E+00, 5.50000E+00, 6.90000E+00, NA, 1.03000E+01, 1.07000E+01, 9.70000E+00, 8.70000E+00, 8.50000E+00, 9.50000E+00, 8.30000E+00, 9.40000E+00, 9.10000E+00, 9.10000E+00, 1.21000E+01, 1.14000E+01, 1.18000E+01, 1.22000E+01, 1.20000E+01, 8.00000E+00, NA, 6.90000E+00, 8.60000E+00, 7.90000E+00, 1.27000E+01, 1.17000E+01, 1.17000E+01, 1.07000E+01, 1.09000E+01, 8.40000E+00, 8.20000E+00, 8.30000E+00, 9.20000E+00, 9.20000E+00, 8.80000E+00, 1.01000E+01, 6.60000E+00, NA, 7.70000E+00, 1.24000E+01, 1.15000E+01, 1.12000E+01, 1.01000E+01, 1.02000E+01, NA, 1.00000E+01, 9.30000E+00, 8.50000E+00, 1.04000E+01, 1.03000E+01, 5.50000E+00, 8.60000E+00, 8.30000E+00, 9.80000E+00, 1.03000E+01, 9.40000E+00, 9.70000E+00, 7.80000E+00, 1.00000E+01, 9.10000E+00, 1.06000E+01, 1.08000E+01, 9.40000E+00, 9.50000E+00, 1.20000E+01, 1.13000E+01, 1.10000E+01, 1.04000E+01, 9.70000E+00, 9.10000E+00, 9.70000E+00, 1.08000E+01, 1.03000E+01, 8.80000E+00, 1.03000E+01, 1.16000E+01, 1.17000E+01, 1.01000E+01, 1.09000E+01, 8.90000E+00, 1.05000E+01, 9.80000E+00, 9.40000E+00, 8.60000E+00, 1.05000E+01, 8.40000E+00, 1.11000E+01, 9.40000E+00, 8.70000E+00, 1.01000E+01, NA, 9.80000E+00, 8.20000E+00, 8.30000E+00, 1.24000E+01, 1.17000E+01, 1.15000E+01, 1.09000E+01, 1.07000E+01, 8.60000E+00, 8.20000E+00, 7.00000E+00, 8.50000E+00, 8.10000E+00, 1.01000E+01, 1.17000E+01, 8.90000E+00, 8.70000E+00, 8.30000E+00, 1.12000E+01, NA, 8.90000E+00, 8.80000E+00, NA, 9.80000E+00, 1.03000E+01, 8.20000E+00, 8.90000E+00, NA, 1.03000E+01, 1.17000E+01, 1.13000E+01, 1.00000E+01, 1.05000E+01, 7.00000E+00, 8.60000E+00, 7.30000E+00, 7.50000E+00, 7.80000E+00, 1.23000E+01, 1.10000E+01, 1.13000E+01, 1.06000E+01, 1.14000E+01, 1.17000E+01, 1.13000E+01, NA, 1.03000E+01, 1.04000E+01, 1.03000E+01, 9.10000E+00, 1.04000E+01, 9.50000E+00, 1.02000E+01, 1.11000E+01, 8.60000E+00, 1.04000E+01, 8.50000E+00, 9.00000E+00, 1.24000E+01, 1.04000E+01, 1.03000E+01, 1.13000E+01, NA, 1.08000E+01, 1.00000E+01, 9.50000E+00, 8.00000E+00, 7.50000E+00, 1.22000E+01, 1.12000E+01, 1.09000E+01, 1.03000E+01, 1.07000E+01, 9.40000E+00, 9.00000E+00, 1.01000E+01, 8.50000E+00, 8.50000E+00, 9.70000E+00, 8.10000E+00, 1.24000E+01, 8.30000E+00, 7.00000E+00, 9.90000E+00, 8.50000E+00, 1.01000E+01, 8.30000E+00, 9.90000E+00, 1.14000E+01, 1.12000E+01, NA, 1.13000E+01, 1.02000E+01, 1.13000E+01, 1.13000E+01, 1.10000E+01, 1.10000E+01, 9.90000E+00, 1.06000E+01, 9.70000E+00, 8.80000E+00, 8.40000E+00, 9.30000E+00, 1.24000E+01, 1.02000E+01, 9.50000E+00, NA, 1.12000E+01, 1.02000E+01, 1.04000E+01, 9.70000E+00, 9.40000E+00, 1.02000E+01, 1.16000E+01, 1.15000E+01, 9.30000E+00, 1.07000E+01, 1.30000E+01, 1.12000E+01, 1.10000E+01, 1.08000E+01, 1.02000E+01, 1.09000E+01, 1.08000E+01, 1.15000E+01, 1.14000E+01, 1.10000E+01, 1.08000E+01, 9.30000E+00, 1.10000E+01, 7.10000E+00, 8.70000E+00, 7.90000E+00, 6.10000E+00, 6.40000E+00, 8.90000E+00, 8.20000E+00, 7.30000E+00, 1.11000E+01, 1.05000E+01, 1.15000E+01, 1.19000E+01, 1.04000E+01, 7.80000E+00, 8.30000E+00, 9.20000E+00, 8.50000E+00, 7.90000E+00, 1.09000E+01, 1.15000E+01, 1.14000E+01, 1.03000E+01, 1.05000E+01, 1.08000E+01, 1.16000E+01, 1.18000E+01, 9.80000E+00, 9.60000E+00, 1.16000E+01, 1.03000E+01, 1.04000E+01, 1.00000E+01, 1.01000E+01, 1.00000E+01, 1.20000E+01, 1.19000E+01, 1.21000E+01, NA, 1.23000E+01, 1.20000E+01, 1.17000E+01, 9.70000E+00, 1.17000E+01, 6.80000E+00, 8.30000E+00, 8.50000E+00, 7.50000E+00, 8.10000E+00, 9.00000E+00, 9.10000E+00, 8.90000E+00, 8.80000E+00, 8.60000E+00, 1.05000E+01, 1.12000E+01, 8.20000E+00, 1.06000E+01, 1.02000E+01, 1.09000E+01, 1.04000E+01, 1.05000E+01, 1.00000E+01, 1.01000E+01, 1.16000E+01, 1.15000E+01, 1.13000E+01, 1.10000E+01, 1.14000E+01, 1.00000E+01, 9.80000E+00, 1.01000E+01, 1.06000E+01, 1.00000E+01, 9.90000E+00, 1.04000E+01, 9.30000E+00, 8.80000E+00, 9.70000E+00, 1.34000E+01, 1.13000E+01, NA, 1.40000E+01, 1.14000E+01, 1.38000E+01, 7.10000E+00, 6.30000E+00, 1.41000E+01, NA, 1.26000E+01, 1.05000E+01, 8.80000E+00, 9.50000E+00, 1.08000E+01, 8.20000E+00, 7.80000E+00, 7.40000E+00, 8.50000E+00, 8.60000E+00, 9.70000E+00, 8.80000E+00, 9.80000E+00, 1.08000E+01, 1.07000E+01, 9.90000E+00, 9.00000E+00, 8.70000E+00, 8.50000E+00, 8.30000E+00, 1.18000E+01, 1.08000E+01, 1.18000E+01, 1.11000E+01, 1.08000E+01, 1.02000E+01, 8.10000E+00, 7.90000E+00, 8.00000E+00, 7.90000E+00, 1.07000E+01, 9.50000E+00, 8.40000E+00, 8.50000E+00, 1.01000E+01, 1.28000E+01, 1.17000E+01, 1.14000E+01, 1.09000E+01, 1.03000E+01, 8.70000E+00, 8.40000E+00, 8.30000E+00, 8.00000E+00, 7.90000E+00, 5.70000E+00, 6.10000E+00, 5.50000E+00, 7.70000E+00, 7.50000E+00, 1.09000E+01, 9.40000E+00, 1.04000E+01, 9.30000E+00, 9.90000E+00, 1.08000E+01, 1.19000E+01, 1.15000E+01, 1.04000E+01, 9.90000E+00, 1.20000E+01, 1.18000E+01, 1.13000E+01, 1.08000E+01, 1.17000E+01, 9.80000E+00, 8.20000E+00, 8.60000E+00, 8.80000E+00, 7.70000E+00, 1.07000E+01, 9.80000E+00, 1.10000E+01, 9.70000E+00, 9.90000E+00, 1.22000E+01, 1.07000E+01, 1.14000E+01, 1.13000E+01, 1.09000E+01, 7.50000E+00, 1.01000E+01, 6.60000E+00, 8.70000E+00, 7.10000E+00, 6.30000E+00, 7.80000E+00, 7.50000E+00, 6.30000E+00, 7.50000E+00, 1.04000E+01, 9.20000E+00, 8.60000E+00, 8.80000E+00, 1.07000E+01, 8.20000E+00, 8.30000E+00, 8.60000E+00, 7.30000E+00, 8.00000E+00, 9.90000E+00, 9.40000E+00, NA, 9.40000E+00, 9.50000E+00, 1.19000E+01, 1.16000E+01, 1.14000E+01, 1.18000E+01, 1.02000E+01, NA, 8.00000E+00, 7.80000E+00, 1.40000E+01, 7.90000E+00, 8.40000E+00, 9.30000E+00, 8.70000E+00, 9.80000E+00, 1.04000E+01, 8.10000E+00, 1.07000E+01, 5.90000E+00, 7.50000E+00, 7.40000E+00, 1.30000E+01, 1.25000E+01, 1.21000E+01, 1.18000E+01, 1.12000E+01, 9.00000E+00, 8.40000E+00, 1.26000E+01, 7.90000E+00, 8.20000E+00, 1.08000E+01, 1.10000E+01, 1.00000E+01, 1.03000E+01, 8.50000E+00, 1.14000E+01, 1.12000E+01, 1.05000E+01, 9.60000E+00, NA, 1.13000E+01, 1.07000E+01, 1.06000E+01, 1.01000E+01, 9.80000E+00 ), .Dim=c( 104, 5 )), X = structure(.Data= c( -1.17282E+00, -1.02367E+00, -1.09825E+00, -1.17282E+00, -1.09825E+00, 1.06440E+00, 1.06440E+00, -4.27081E-01, -1.17282E+00, -1.17282E+00, -1.02367E+00, -1.17282E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -5.01655E-01, 1.06440E+00, 8.40681E-01, -1.17282E+00, -1.17282E+00, -1.17282E+00, -8.74526E-01, -1.17282E+00, -1.17282E+00, -7.99952E-01, -7.25378E-01, -1.17282E+00, -1.17282E+00, -1.09825E+00, -4.27081E-01, -1.17282E+00, -7.25378E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.09825E+00, -1.02367E+00, -8.74526E-01, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -8.74526E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.09825E+00, -1.17282E+00, 1.06440E+00, -6.50804E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, -7.99952E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.09825E+00, -1.17282E+00, -1.02367E+00, -1.17282E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.02367E+00, 1.06440E+00, 9.89830E-01, -1.17282E+00, -1.09825E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -7.99952E-01, -9.49101E-01, -4.27081E-01, -1.09825E+00, -1.17282E+00, 9.89830E-01, 1.06440E+00, -1.02367E+00, 1.06440E+00, 1.06440E+00, 6.91533E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.02367E+00, -1.17282E+00, 1.06440E+00, -1.17282E+00, 9.89830E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.17282E+00, -1.17282E+00, 1.06440E+00, -7.25378E-01, -1.17282E+00, -7.99952E-01, 1.06440E+00, -1.17282E+00, 3.18661E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, -8.74526E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, 9.49387E-02, 1.06440E+00, 1.06440E+00, -1.09825E+00, -9.49101E-01, -1.17282E+00, -7.99952E-01, -1.17282E+00, -1.02367E+00, -1.09825E+00, 1.06440E+00, -6.50804E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 9.89830E-01, 1.06440E+00, -1.17282E+00, -7.99952E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, 4.67810E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.09825E+00, -1.17282E+00, -1.02367E+00, 3.18661E-01, -7.99952E-01, -2.77932E-01, 3.18661E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -5.42097E-02, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -4.27081E-01, -9.49101E-01, -1.17282E+00, -1.02367E+00, -1.09825E+00, -1.02367E+00, -1.09825E+00, -1.02367E+00, 1.06440E+00, -5.42097E-02, 1.06440E+00, -1.17282E+00, -1.09825E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -9.49101E-01, -9.49101E-01, 6.16958E-01, -1.17282E+00, -9.49101E-01, -1.17282E+00, 1.06440E+00, -1.17282E+00, -1.09825E+00, 9.89830E-01, 1.06440E+00, -1.17282E+00, -2.77932E-01, -1.09825E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -7.25378E-01, -1.17282E+00, -2.03358E-01, 1.06440E+00, -5.42097E-02, 6.91533E-01, 1.06440E+00, 1.06440E+00, -1.02367E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.09825E+00, -1.17282E+00, -7.99952E-01, 1.06440E+00, -1.09825E+00, -2.77932E-01, 3.18661E-01, 3.18661E-01, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 6.91533E-01, -5.76229E-01, -1.17282E+00, -1.17282E+00, -1.17282E+00, -1.17282E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -5.42097E-02, 1.06440E+00, 1.06440E+00, -1.02367E+00, -9.49101E-01, -1.17282E+00, -5.76229E-01, -9.49101E-01, -9.49101E-01, -4.27081E-01, 1.06440E+00, -1.02367E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, -1.09825E+00, -1.17282E+00, 6.91533E-01, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, 9.15255E-01, 1.06440E+00, 1.06440E+00, -9.49101E-01, 6.16958E-01, 3.18661E-01, 1.06440E+00, -1.17282E+00, -1.09825E+00, 3.18661E-01, 1.06440E+00, -1.17282E+00, -1.02367E+00, 3.18661E-01, -7.99952E-01, -1.17282E+00, -1.17282E+00, -1.09825E+00, -1.17282E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 9.15255E-01, -1.17282E+00, -9.49101E-01, 3.18661E-01, -7.99952E-01, -6.50804E-01, 3.93236E-01, 3.18661E-01, 1.06440E+00, -1.17282E+00, -5.42097E-02, 3.18661E-01, 6.91533E-01, -7.99952E-01, 3.18661E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, -1.17282E+00, -1.17282E+00, 1.06440E+00, -1.09825E+00, -4.27081E-01, -4.27081E-01, 3.18661E-01, -1.17282E+00, 3.18661E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.09825E+00, -1.09825E+00, -4.27081E-01, 1.06440E+00, -1.17282E+00, -9.49101E-01, 6.91533E-01, 1.06440E+00, -1.17282E+00, -1.02367E+00, -1.09825E+00, -5.42097E-02, -4.27081E-01, 3.18661E-01, 1.06440E+00, 1.06440E+00, 3.93236E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.09825E+00, -1.17282E+00, -5.42097E-02, 1.06440E+00, -1.17282E+00, 1.06440E+00, -1.02367E+00, -4.27081E-01, -1.17282E+00, -1.17282E+00, 6.91533E-01, 1.06440E+00, -1.09825E+00, -7.99952E-01, -8.74526E-01, -5.42097E-02, -1.17282E+00, -1.17282E+00, 1.06440E+00, 1.06440E+00, -1.17282E+00, -9.49101E-01, 1.06440E+00, 1.06440E+00, -1.17282E+00, -9.49101E-01, -1.09825E+00, -1.17282E+00, -1.17282E+00, -1.17282E+00, -1.09825E+00, -1.09825E+00, -1.17282E+00, 1.06440E+00, -7.99952E-01, 6.91533E-01, -1.17282E+00, -1.02367E+00, -9.49101E-01, -1.17282E+00, -1.09825E+00, -1.09825E+00, 1.06440E+00, 3.18661E-01, -1.17282E+00, -1.17282E+00, -1.02367E+00, -1.02367E+00, -4.27081E-01, 3.93236E-01, 1.06440E+00, -1.17282E+00, -1.17282E+00, -7.99952E-01, -7.25378E-01, -5.42097E-02, 6.91533E-01, 1.06440E+00, 1.06440E+00, 1.06440E+00, -1.02367E+00, -6.50804E-01, -1.17282E+00, -1.09825E+00 ), .Dim=c( 104, 4 )), Z =c( 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0 ) )