我的源码如下,其中,taub[1:2 , 1:2]是一个协方差矩阵,它的逆taub2[1:2 , 1:2]服从Wishart分布。
model
{
for ( i in 1:I) {
for ( j in 1:NoVisits ) {
IntTime[Start+j-1]~dexp(lambda[i,j])
lambda[i,j]<- k[i,j]*(lambdaa[i,1]+lambdaa[i,2])+(1-k[i,j])*lambdaa[i,1]
k[i,j]~dbern(p)
}
}
for ( i in 1:I) {
p<-exp(pp)/(1+exp(pp))
pp~dnorm(pm,pv)
lambdaa[i,1] <-exp(lambdaalog[i,1] )
lambdaa[i,2] <-exp(lambdaalog[i,2] )
lambdaalog[i,1:2]~dmnorm(mub[],taub[1:2 , 1:2])
}
taub[1:2 , 1:2]<-inverse(taub2[1:2 , 1:2])
taub2[1:2 , 1:2] ~ dwish(R[ , ], 2)
pm~dnorm(-0.13, 0.001)
pv<-(1/pv2)
pv2~ dgamma(0.2, 0.1)
mub[1]~dnorm(0.04, 0.001)
mub[2]~dnorm(75, 0.001)
}
list(
NoVisits=c(4,5,9,13,14,34,12,12,7,26),
Start=c(1,5,10,19,32,46,80,92,104,111),
IntTime=c(101.18728,0.43793,78.98381,84.64679,11.86966,5.30372,3.77996,10.41298,322.28447,23.65847,51.94094,44.96256,0.3518,0.31278,47.1044,0.38145,51.76386,133.63374,3.2497,2.08358,1.3957,1.77537,2.34434,0.88446,2.40175,2.34836,1.03303,2.26494,0.54575,2.58738,305.48963,1.11025,1.39073,1.16223,1.6751,0.64492,20.73917,1.24143,86.11369,167.09158,0.60013,35.19377,0.7257,0.72089,12.53384,24.36262,0.41158,16.44356,0.30801,18.05034,19.37655,0.66023,0.17906,10.47063,0.88914,24.16075,14.46642,10.03867,12.32532,0.81004,13.77208,0.32718,0.53061,42.01017,10.791,0.48508,13.4481,21.60589,31.03709,21.53514,12.81948,9.7653,8.54452,9.6798,0.3886,13.55587,0.56849,0.43011,0.59748,1.77712,0.63402,1.02834,105.73851,2.3844,44.25245,1.12181,6.04204,90.65975,1.21531,0.24134,100.78663,0.54404,0.36588,1.15077,10.83418,0.48786,0.74062,0.56801,120.04232,1.6722,0.25873,132.82846,90.53738,0.83102,85.11902,0.46851,0.50872,0.75101,30.78906,202.11183,1.89977,1.61067,1.22062,0.52893,0.56786,1.83491,0.82244,1.19584,0.55438,2.006,2.35227,2.00613,1.33195,1.25278,1.26588,1.31076,0.99915,0.61415,0.48794,3.33559,1.19989,101.40746,1.42313,3.40521,0.88697,13.29708),
R = structure(.Data = c(1, 0, 0, 1), .Dim = c(2,2)),
I=10)