W*****r 发帖数: 193 | 1 model {
for (j in 1:J){
y[j] ~ dnorm(theta[j], tau.y[j])
theta[j] ~dnorm(mu.theta, tau.theta)
tau.y[j] <- pow(sigma.y[j], -2)
}
mu.theta ~ dnorm(0, 1.0E-6)
tau.theta <- pow(sigma.theta, -2)
sigma.theta ~ dunif (0, 1000)
either<-max(theta1,theta2,theta3,theta4, theta5, theta6, the7, theta8)
问题在这一行,我共有8个theta值。这样输入说“没有定义theta1...“
我想请教一下:应该怎么输入?
多谢多谢。会发包子的。
}
DATA
list(J=8, y = c(28, 8, -3, 7, -1,1,18,12), sigma.y=c(15,10,16,11,9,11,
10,18))
INITIAL VALUES
list(theta= c(0,0,0,0,0,0,0,0), mu.theta = 0, sigma.theta = 1) | W*****r 发帖数: 193 | 2 我知道max(a,b)
但这个(a,b)怎么表示8个theta呢?
难道都两个两个过一遍?
我试过 max(theta[j],theta[j+1])
还是不行撒 | l*********s 发帖数: 5409 | 3 1. theta[1] not theta1
2. max() takes only 2 arguments. | l*********s 发帖数: 5409 | 4 use sort function, which takes vector input
【在 W*****r 的大作中提到】 : 我知道max(a,b) : 但这个(a,b)怎么表示8个theta呢? : 难道都两个两个过一遍? : 我试过 max(theta[j],theta[j+1]) : 还是不行撒
| W*****r 发帖数: 193 | 5 好的,多谢
我先试下
【在 l*********s 的大作中提到】 : use sort function, which takes vector input
| W*****r 发帖数: 193 | 6 model {
for (j in 1:J){
y[j] ~ dnorm(theta[j], tau.y[j])
theta[j] ~dnorm(mu.theta, tau.theta)
tau.y[j] <- pow(sigma.y[j], -2)
}
mu.theta ~ dnorm(0, 1.0E-6)
tau.theta <- pow(sigma.theta, -2)
sigma.theta ~ dunif (0, 1000)
either<-max(sort[theta[1], theta[2],theta[3],theta[4]],sort[theta[5],
theta[6],theta[7],theta[8]]))
}
我又试了一下,说有variable未定义。BTW,我只用两个theta值的时候,either可以
set成node,density也可以显示。
多谢多谢。
DATA
list(J=8, y = c(28, 8, -3, 7, -1,1,18,12), sigma.y=c(15,10,16,11,9,11,
10,18))
INITIAL VALUES
list(theta= c(0,0,0,0,0,0,0,0), mu.theta = 0, sigma.theta = 1)
【在 W*****r 的大作中提到】 : 好的,多谢 : 我先试下
| l*********s 发帖数: 5409 | 7 do this:
thetaorder[1:8] <- sort(theta)
either <- tetaorder[8]
【在 W*****r 的大作中提到】 : model { : for (j in 1:J){ : y[j] ~ dnorm(theta[j], tau.y[j]) : theta[j] ~dnorm(mu.theta, tau.theta) : tau.y[j] <- pow(sigma.y[j], -2) : } : mu.theta ~ dnorm(0, 1.0E-6) : tau.theta <- pow(sigma.theta, -2) : sigma.theta ~ dunif (0, 1000) : either<-max(sort[theta[1], theta[2],theta[3],theta[4]],sort[theta[5],
| W*****r 发帖数: 193 | 8 好的,我再试一下。
十分感谢。
【在 l*********s 的大作中提到】 : do this: : thetaorder[1:8] <- sort(theta) : either <- tetaorder[8]
| l*********s 发帖数: 5409 | 9 sorry, I think the first line shall be sort(theta[])
【在 W*****r 的大作中提到】 : 好的,我再试一下。 : 十分感谢。
| W*****r 发帖数: 193 | 10 已经转20个到你id上
不知道那是不是包子
请注意查收
【在 l*********s 的大作中提到】 : sorry, I think the first line shall be sort(theta[])
| W*****r 发帖数: 193 | 11 好的
多谢
【在 l*********s 的大作中提到】 : sorry, I think the first line shall be sort(theta[])
|
|