楼主: Lisrelchen
1661 2

[Q & A]Defining a stepwise uniform distribution using WinBUGS? [推广有奖]

  • 0关注
  • 62粉丝

VIP

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
49957 个
通用积分
79.5487
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
I want to define a distribution in my model of the form: P(x=10)=0.10, P(x=15)=0.20, P(x=20)=0.70

The WinBUGS FAQ says it is possible construct my own discrete uniform distribution as a categorical variable with a uniform prior and which can take on the necessary integer values. See the blockerht example in the first part of the manual.

I looked the example up, I think it is this one: "A hierarchical t-distribution with unknown degrees of freedom"

At the model specification they do something like:
  1. for (n in 1:Nbins) {
  2.    prior[n] <- 1/Nbins;   # Uniform prior on v
  3. }
  4. k ~ dcat(prior[]);
复制代码

Which does define a discrete uniform. But I don't know how to get to the form I need. Can anyone help me?
二维码

扫码加我 拉你入群

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

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

关键词:distribution defining stepwise Uniform winbugs necessary something possible example values

本帖被以下文库推荐

沙发
Lisrelchen 发表于 2014-6-30 23:18:19 |只看作者 |坛友微信交流群
If I understand your question correctly, you do not need the loop...

  1. #BUGS script to obtain distribution
  2. m1<-"model{
  3.   ind ~ dcat(p[])
  4.   pmix <- x[ind]
  5. }"
  6. writeLines(m1,"m1.txt")

  7. #simulate from the distribution   
  8. library("R2OpenBUGS")
  9. m1.bug<-bugs(data = list(x=c(10, 15, 20), p=c(0.1,0.2,0.7)),
  10.              inits = NULL,
  11.              param = "pmix",
  12.              model = "m1.txt",
  13.              n.iter = 1100, n.burnin = 100, n.chains = 1, n.thin=1, DIC=FALSE)

  14. hist(m1.bug$sims.list$pmix)
复制代码

should work...

使用道具

藤椅
Lisrelchen 发表于 2014-6-30 23:18:50 |只看作者 |坛友微信交流群
I am learning how to do this myself. I wonder if you can do this:

prior[10] <- .1
prior[15] <- .2
prior[20] <- .7
x ~ dcat(prior[])

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 16:54