全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2362 2
2010-07-14
哪位大侠帮忙看看,我检查了很多很多遍,就是找不到没有附初始值的变量。。。但winbugs 总是提示有 uninitialized variables!!!! 我不想要winbugs 自动生成初始值

先谢谢啦


code:
model
{for(i in 1: N) {

# generate data

boxoffice[i] ~ dnorm(ubo[i], tau[1])
screen[i] ~ dnorm(uscr[i], tau[2])
ad[i] ~ dnorm(uad[i], tau[3])



meancc[i] ~ dnorm(cc[i], varn[1])
meansh[i] ~ dnorm(sh[i], varn[2])
jaccard[i] ~ dnorm(se[i], varn[3])


ability[i] ~ dnorm(-1, z)

#regress network attributes on latent V

cc[i]<- alpha[1]+gamma[1]*ability[i]+res[i,1]
sh[i]<- alpha[2]+gamma[2]*ability[i]+res[i,2]
se[i]<- alpha[3]+gamma[3]*ability[i]+res[i,3]


# regress bo, ad and screen on predictors

log(ubo[i])<-beta[1]+lamda[1]*ability[i]+delta[1]*res[i,1]+theta[1]*res[i,2]+zeta[1]*res[i,3] + eta[1]*log(screen[i])+ phi[1]*log(ad[i])+ pi[1]*comp[i] +kappa[1]*log(budget[i])

log(uscr[i])<- beta[2]+lamda[2]*ability[i]+delta[2]*res[i,1]+theta[2]*res[i,2]+zeta[2]*res[i,3]+kappa[2]*log(budget[i])

log(uad[i])<- beta[3]+lamda[3]*ability[i]+delta[3]*res[i,2]+theta[3]*res[i,2]+zeta[3]*res[i,3]+kappa[3]*log(budget[i])



}

# priors on regression parameters and precisions


for(i in 1: N) {res[i,1:3] ~ dmnorm (mean[1:3], tau.res[1:3, 1:3])}
tau.res[1:3, 1:3] ~ dwish(R[1:3,1:3],3)

R[1,1]<-1
R[2,2]<-1
R[3,3]<-1
R[2,1]<-R[1,2]
R[1,2]<-0
R[1,3]<-R[3,1]
R[3,1]<-0
R[2,3]<-R[3,2]
R[3,2]<-0
for (i in 1:3) {mean[i] <- 0}


for (j in 1:3) {varn[j] ~ dgamma(1, 0.001)}

for (j in 1:3) {tau[j] ~ dgamma(0.5, 0.5)}

z ~ dgamma(0.5, 0.5)


for (j in 1:3) {alpha[j] ~ dnorm(0,0.001);
gamma[j] ~ dnorm(0,0.001);
beta[j] ~ dnorm(0, 0.001);
lamda[j] ~ dnorm(0,0.001);
delta[j]~dnorm(0,0.001);
theta[j]~dnorm(0,0.001);
zeta[j]~dnorm(0, 0.001);
kappa[j]~dnorm(0,0.001)}

eta[1] ~dnorm(0,0.001)
phi[1] ~dnorm(0,0.001)
pi[1] ~dnorm(0,0.001)

}



初始值  :Initial values for chain 1:

list(alpha=c(0,0,0), gamma=c(0,0,0), beta=c(0,0,0),lamda=c(0,0,0), delta=c(0,0,0), theta=c(0,0,0), zeta=c(0,0,0), kappa=c(0,0,0), eta=c(0), phi=c(0), pi=c(0), z=1, tau=c(1,1,1), varn=c(1,1,1), tau.res=structure(.Data=c(1.0E-6,0,0,0,1.0E-6,0,0,0,1.0E-6),.Dim=c(3,3)))

Initial values for chain 2:

list(alpha=c(1,1,1), gamma=c(1,1,1), beta=c(1,1,1),lamda=c(2,2,2), delta=c(2,2,2), theta=c(2,2,2), zeta=c(2,2,2), kappa=c(2,2,2), eta=c(0), phi=c(0), pi=c(0), z=2, tau=c(0.5,0.5,0.5), varn=c(0.5,0.5,0.5), tau.res=structure(.Data=c(0.1,0,0,0,0.1,0,0,0,0.1),.Dim=c(3,3)))
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-10-6 15:31:08
你看看下面的 step 我按照这样解决了

STEP 8: Notice that in the lower left hand corner it says “initial values loaded but this or another chain contain uninitialized variables”.  It says this because all of the latent variables in the model (within the Bayesian framework) are also considered parameters and thus each individual’s latent variables need starting values too.  Rather than enter 500*3 starting values for all the latent variables, we use the “gen inits” button which allows Winbugs to specify the starting values.  Click on the “gen inits” button and notice that now it says “initial values generated, model initialized” in the lower left hand corner.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-10-6 23:51:57
楼主发了个急急急急急的帖子,然后一年多后终于有人回复了。:-)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群