我在 Winbugs 中有一个分层线性模型。数据是纵向数据,由三个类别组成(红色 = 1,蓝色 = 2,白色 = 3)
k - 总观测值 =280
数据结构如下:
N[] T[] logs[] logp[] cat[] rank[]
1 1 4.2 8.9 1 1
1 2 4.2 8.1 1 2
1 3 3.5 9.2 1 1
2 1 4.1 7.5 1 2
2 2 4.5 6.5 1 2
3 1 5.1 6.6 2 4
3 2 6.2 6.8 3 7
#N = school
#T = time
#logs = log(score)
#logp = log(average hours of inputs)
#rank - rank of school
#cat = section red, section blue, section white in school
我的模型在语法上是正确的,但是当我尝试加载数据时,我得到 error = 'expected square bracket at the end]'
model {
# N brands
# T time periods
for (k in 1:K){
for (i in 1:N) {
for (t in 1:T) {
logs[k,i,t] ~ dnorm(mu[k,i,t], tau)
mu[k,i,t] <- bcons +bprice*(logp[t] - logpricebar)
+ brank[cat[t]]*(rank[t] - rankbar)
}
}
}
# C categories
for (c in 1:C) {
brank[c] ~ dnorm(beta, taub)}
# priors
bcons ~ dnorm(0,1.0E-6)
bprice ~ dnorm(0,1.0E-6)
bad ~ dnorm(0,1.0E-6)
beta ~ dnorm(0,1.0E-6)
tau ~ dgamma(0.001,0.001)
taub ~dgamma(0.001,0.001)
}
我遵循加载数据的标准流程,选择 N,然后在对话框中按“加载数据”。
有人可以帮我解决这里的问题吗?