楼主: liangzaigeo
2580 6

帮忙看看这个winbugs程序那个地方错了 [推广有奖]

  • 0关注
  • 0粉丝

学前班

70%

还不是VIP/贵宾

-

威望
0
论坛币
10 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
113 点
帖子
2
精华
0
在线时间
2 小时
注册时间
2008-11-2
最后登录
2010-8-21

楼主
liangzaigeo 发表于 2010-8-6 11:14:54 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
#linear regression for storks
#number of chicks per pair as a fluncion of both rainfall and temperature in May
model
    {
         for(i in 1:N)
            {
                nbchicksperpair[i] ~dnorm(mu[i],tau)
                 mu[i]<-intercept+slope.temperature*temperature[i]+slope.rainfall*rainfall[i]
             }
            #priors for regression parameters
           intercept ~dnorm(0,0.001)
           slope.temperature ~ dnorm(0,0.001)
           slope.rainfall ~ dnorm(0,0.001)
           #piors for precision parameter
            tau ~ dgamma(0.001,0.001)
            #monitor the standard deviation
            sigma<-1/sqrt(tau)
}
#data
list(N=23,nbchicksperpair=
c(2.55,1.85,2.05,2.88,3.13,2.21,2.43,2.69,2.55,2.84,2.47,2.69,2
.52,2.31,2.07,2.35,2.98,1.98,2.53,2.21,2.62,1.78,2.30),temperature=
c(15.1,13.3,15.3,13.3,14.6,15.6,13.1,13.1,15.0,11.7,15.3,14.4,14.4,12.7,
11.7,11.9,15.9,13.4,14.0,13.9,12.9,15.1,13.0),rainfall=
c(67,52,88,61,32,36,72,43,92,32,86,28,57,55,66,26,28,96,48,90,86,78,87))
#initial values
list(intercept=0,slope.temperature=0,slope.rainfall=0,tau=0.01)


运行到load data的时候,出现expected variable name,检查了多次感觉没有出错啊。
麻烦各位大虾看看
二维码

扫码加我 拉你入群

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

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

关键词:winbugs WINBUG BUGS bug Win winbugs

沙发
coral033 在职认证  发表于 2011-3-1 16:10:11
# linear regression for storks
model
  {
  for (i in 1:N)
          {
            nbchicksperpair[i] ~ dnorm (mu[i],tau)
            mu[i] <- intercept + slope.temperature*temperature[i]+slope.rainfall*rainfall[i]
          }
    # priors for regression parameters
    intercept ~ dnorm (0,0.001)
    slope.temperature ~ dnorm (0,0.001)
    slope.rainfall~ dnorm (0,0.001)
   
    # priors for precision parameter
    tau~ dgamma (0.001,0.001)
   
    #monitor the standard deviation
    sigma <- 1/sqrt(tau)
  }

#data
list(N=23,nbchicksperpair=
c(2.55,1.85,2.05,2.88,3.13,2.21,2.43,2.69,2.55,2.84,2.47,2.69,2.52,2.31,2.07,2.35,2.98,1.98,2.53,2.21,2.62,1.78,2.30),temperature=
c(15.1,13.3,15.3,13.3,14.6,15.6,13.1,13.1,15.0,11.7,15.3,14.4,14.4,12.7,
11.7,11.9,15.9,13.4,14.0,13.9,12.9,15.1,13.0),rainfall=
c(67,52,88,61,32,36,72,43,92,32,86,28,57,55,66,26,28,96,48,90,86,78,87))
#initial values
list(intercept=0,slope.temperature=0,slope.rainfall=0,tau=0.01)
Out of difficulties, makes miracles.

藤椅
coral033 在职认证  发表于 2011-3-1 16:29:08
我的运行结果是可以的。
Out of difficulties, makes miracles.

板凳
coral033 在职认证  发表于 2011-3-1 16:34:01
1. Check model: open the Model Specification Tool
Watch out for the confirmation at the foot of the screen
2. Load data: Now highlight the 'list' in the data window
then click 'load data'
watch out for the confirmation at the foot of the screen
3. Compile model: Next, click 'compile'
watch out for the confirmation at the foot of the screen
4. Load initial values: highlight the 'list' in the data window
click 'load inits'
watch out for the confirmation at the foot of the screen
5. Generate Burn-in values: Open the Model Update Tool
Give the number of burn-in iterations (1000)
click 'update' to do the sampling
6. Monitor parameters: open the Inference Samples Tool
Enter 'intercept' in the node box and click 'set'
Enter 'slope_temperature' in the node box and click 'set'
Enter 'slope_rainfall' in the node box and click 'set'
7. Generate posterior values: enter the number of samples you want to take (10000)
click 'update' to do the sampling
8. Summarize posteriors: Enter '*' in the node box and click 'stats'
mean, median and credible intervals
95% Credible intervals
Out of difficulties, makes miracles.

报纸
liuqi99 发表于 2013-9-1 02:31:07
#linear regression for storks
#number of chicks per pair as a function of both rainfall and temperature in May
model
    {
         for(i in 1:N)
            {
                nbchicksperpair[i] ~dnorm(mu[i],tau)
                 mu[i]<-intercept+slope.temperature*temperature[i]+slope.rainfall*rainfall[i]
             }
            #priors for regression parameters
           intercept ~dnorm(0,0.001)
           slope.temperature ~ dnorm(0,0.001)
           slope.rainfall ~ dnorm(0,0.001)
           #piors for precision parameter
            tau ~ dgamma(0.001,0.001)
            #monitor the standard deviation
            sigma<-1/sqrt(tau)
}
#data
list(N=23,nbchicksperpair=c(2.55,1.85,2.05,2.88,3.13,2.21,2.43,2.69,2.55,2.84,2.47,2.69,2.52,2.31,2.07,2.35,2.98,1.98,2.53,2.21,2.62,1.78,2.30),
temperature=c(15.1,13.3,15.3,13.3,14.6,15.6,13.1,13.1,15.0,11.7,15.3,14.4,14.4,12.7,11.7,11.9,15.9,13.4,14.0,13.9,12.9,15.1,13.0),
rainfall=c(67,52,88,61,32,36,72,43,92,32,86,28,57,55,66,26,28,96,48,90,86,78,87))
#initial values
list(intercept=0,slope.temperature=0,slope.rainfall=0,tau=0.01)

地板
liuqi99 发表于 2013-9-1 02:39:34
#linear regression for storks
#number of chicks per pair as a fluncion of both rainfall and temperature in May
model
    {
         for(i in 1:N)
            {
                nbchicksperpair ~dnorm(mu,tau)
                 mu<-intercept+slope.temperature*temperature+slope.rainfall*rainfall
             }
            #priors for regression parameters
           intercept ~dnorm(0,0.001)
           slope.temperature ~ dnorm(0,0.001)
           slope.rainfall ~ dnorm(0,0.001)
           #piors for precision parameter
            tau ~ dgamma(0.001,0.001)
            #monitor the standard deviation
            sigma<-1/sqrt(tau)
}
#data
list(N=23,nbchicksperpair=
c(2.55,1.85,2.05,2.88,3.13,2.21,2.43,2.69,2.55,2.84,2.47,2.69,
2.52,2.31,2.07,2.35,2.98,1.98,2.53,2.21,2.62,1.78,2.30),temperature=
c(15.1,13.3,15.3,13.3,14.6,15.6,13.1,13.1,15.0,11.7,15.3,14.4,14.4,12.7,
11.7,11.9,15.9,13.4,14.0,13.9,12.9,15.1,13.0),rainfall=
c(67,52,88,61,32,36,72,43,92,32,86,28,57,55,66,26,28,96,48,90,86,78,87))
#initial values
list(intercept=0,slope.temperature=0,slope.rainfall=0,tau=0.01)

7
liuqi99 发表于 2013-9-1 02:39:59
红色为你错误所在

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-20 08:06