楼主: nieveblanca
1979 3

[问答] 请教R中运行WINBUGS问题。 [推广有奖]

  • 0关注
  • 0粉丝

高中生

20%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
220 点
帖子
25
精华
0
在线时间
13 小时
注册时间
2010-2-26
最后登录
2016-6-2

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
做了好久改了好久还是有问题存在。百度了谷歌都不好用。
哪位仁兄帮帮忙。。。
MODEL:
model {
for ( i in 1:N) {

   y ~ dnorm(mu, tau)
   mu <- b0 + b1*log(x)
   
   }
  tau ~ dgamma(0.001, 0.001)
  b0 ~ dnorm(0, 1.0E-6)
  b1 ~ dnorm(0, 0.00001)
  sigma <- sqrt(1/tau)
}

Code R:
path.bug <- "G:/ej52/"
path.WBs <- "C:/Program Files/WinBUGS14/"
install.packages('R2WinBUGS')
library(R2WinBUGS)
Iter <- 2000
Burn <- 1000
Thin <- 5
Chain <- 2
notes<-c(9.6,7,5,8,8.4,6.4,6.1,9.1,8.8,5.7,8.9,6.1,6.5)
sexe <-c(1,1,1,1,1,1,0,0,0,0,0,0,0)
N<- length(notes)
dades <- list(N=N, y = notes, x1 = sexe)
inicials <- list(list(tau=0.1, b0=100, b1=100),list(tau=100, b0=-100, b1=-100))
parametres <- c("b0", "b1", "sigma")
model<- bugs(dades, inicials, parameters.to.save=parametres,
               model.file=paste(path.bug,"MODELsessio5.bug",sep="")
               , bugs.directory=path.WBs,
               n.iter=(Iter*Thin+Burn),n.burnin=Burn, n.thin=Thin, n.chains=Chain, debug=T, DIC=F
               ,working.directory=getwd())
print(model , digits=2)
summary(modelF)


就一直出现一样的问题
错误于bugs.run(n.burnin, bugs.directory, WINE = WINE, useWINE = useWINE,  :   Look at the log file andtry again with 'debug=TRUE' to figure out what went wrong within Bugs.


二维码

扫码加我 拉你入群

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

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

关键词:winbugs WINBUG BUGS bug Win 百度 谷歌

本帖被以下文库推荐

沙发
xingzhaoh 发表于 2013-1-9 08:24:31 |只看作者 |坛友微信交流群
我也想知道

使用道具

藤椅
nieveblanca 发表于 2013-1-9 08:28:00 |只看作者 |坛友微信交流群
有没有人有没有人等待解答 解答继续等待解答~~

使用道具

板凳
epoh 发表于 2013-1-9 17:10:40 |只看作者 |坛友微信交流群
SAVE THE FOLLOWING MODEL IN FILE "MODELsessio5.bug" or "MODELsessio5.txt"
and place in c:\nieveblanca\MODELsessio5.bug
#-----------------------------
  1. model {
  2. for ( i in 1:N) {
  3.    y[i] ~ dnorm(mu[i], tau)
  4.    mu[i] <- b0 + b1*log(x1[i])
  5.    
  6.    }
  7.   tau ~ dgamma(0.01, 0.01)
  8.   b0 ~ dnorm(0, 0.01)
  9.   b1 ~ dnorm(0, 0.01)
  10.   sigma <- sqrt(1/tau)
  11. }
复制代码
#-----------------------------

###in R Console
library(R2WinBUGS)
#Data:
x1 = c( 1.0,  1.5,  1.5,  1.5, 2.5,   4.0,  5.0,  5.0,  7.0, 8.0,  8.5,  9.0,  9.5, 9.5,  10.0, 12.0, 12.0, 13.0,
                   13.0, 14.5, 15.5, 15.5, 16.5, 17.0, 22.5, 29.0, 31.5)
y = c(1.80, 1.85, 1.87, 1.77, 2.02, 2.27, 2.15, 2.26, 2.47, 2.19, 2.26, 2.40, 2.39, 2.41, 2.50, 2.32, 2.32, 2.43,
                   2.47, 2.56, 2.65, 2.47, 2.64, 2.56, 2.70, 2.72, 2.57)
N=length(y)


#y <- c(9.6,7,5,8,8.4,6.4,6.1,9.1,8.8,5.7,8.9,6.1,6.5)
#x1 <-c(1,1,1,1,1,1,0,0,0,0,0,0,0)
#N<- length(y)
dades <- list("N", "y", "x1" )
inicials <- list(list(tau=1, b0=0, b1=1))
parametres <- c("b0", "b1", "sigma")
model<- bugs(dades, inicials, parameters.to.save=parametres,
               model.file="MODELsessio5.bug",n.chains=1,n.thin=1,debug=TRUE,DIC=TRUE,
                     n.iter=2000,n.burnin=1000,working.directory = "c:/nieveblanca/",
                     bugs.directory="d:/WinBUGS14/")
               
print(model , digits=4)

Inference for Bugs model at "MODELsessio5.bug", fit using WinBUGS,
1 chains, each with 2000 iterations (first 1000 discarded)
n.sims = 1000 iterations saved
             mean     sd     2.5%      25%      50%      75%    97.5%
b0         1.7608 0.0470   1.6680   1.7317   1.7615   1.7900   1.8490
b1         0.2778 0.0201   0.2385   0.2655   0.2775   0.2903   0.3163
sigma      0.0970 0.0146   0.0729   0.0865   0.0954   0.1055   0.1280
deviance -52.0948 2.7305 -55.2100 -54.1700 -52.7500 -50.8850 -45.1283

DIC info (using the rule, pD = Dbar-Dhat)
pD = 3.1 and DIC = -49.0
DIC is an estimate of expected predictive error (lower deviance is better).
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 精彩帖子

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

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

GMT+8, 2024-6-26 23:45