由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教高手:如何在winbugs里使用max(a,b)function?
相关主题
WinBUGS 先验分布设置的问题question about r code "order"
Winbugs 求助, 要崩溃了...用EM求的MLE,但是observed likelihood 怎么算呢
WinBUGS 先验分布设置的问题sas help, how to manipulating on the format value
请问,如何保存这个WinBUGS程序采的样本请教大牛关于factorizatics theorem 来证明sufficent statistics
【求助】JAGS code for model specification请教一个transpose的问题,在线等
jags code help, 谢谢!sas adv 63题 52
sas 求助!!! 如何求-1 lag ?sas code 求教
WINBUG initials发包子求助SAS code
相关话题的讨论汇总
话题: theta话题: dnorm话题: max话题: theta1话题: pow
进入Statistics版参与讨论
1 (共1页)
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[])
1 (共1页)
进入Statistics版参与讨论
相关主题
发包子求助SAS code【求助】JAGS code for model specification
求教一个简单的data step 牛肉包jags code help, 谢谢!
求教:怎样reshape data in Rsas 求助!!! 如何求-1 lag ?
用 sas 分组问题WINBUG initials
WinBUGS 先验分布设置的问题question about r code "order"
Winbugs 求助, 要崩溃了...用EM求的MLE,但是observed likelihood 怎么算呢
WinBUGS 先验分布设置的问题sas help, how to manipulating on the format value
请问,如何保存这个WinBUGS程序采的样本请教大牛关于factorizatics theorem 来证明sufficent statistics
相关话题的讨论汇总
话题: theta话题: dnorm话题: max话题: theta1话题: pow