全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
13814 21
2012-04-27
我的程序运行后有这样的错误提示:
错误于is.finite(x) : 没有为'list'类型实现默认的方法,这是什么意思?
> # R code with interface to Winbugs
>
> library(R2WinBUGS)   
> y<-read.table("D:/Bugs/jump.dat",header=TRUE)    #import data#
> N<-length(y)
> Xi0<-rep(0,N)   # Give initial values to state variables#
> J0<-rep(0,N)
> data<-list("N","y")  
> # Give initial values to the parameters for winbugs #
> inits <-function() {list ( tau=2,
+                    Jtau=2,
+                    mu=0,
+                    Jmu=0,
+                    lamda = 0.05, Xi=Xi0,J=J0)}
> parameters<- c("Sigma","JSigma","mu","Jmu","lamda","Xi","J")
> # quote the winbugs#
> jump.sim<-bugs (data, inits=inits, parameters, "model.bug", n.chains=3, n.iter=1000,debug=TRUE,
+                      DIC=TRUE,bugs.directory = "D:/Program Files/WinBUGS14/",working.directory = "D:/Bugs")
错误于is.finite(x) : 没有为'list'类型实现默认的方法
>


二维码

扫码加我 拉你入群

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

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

全部回复
2012-4-28 16:19:13
y<-read.table("D:/Bugs/jump.dat",header=TRUE)    #import data#
y=y[,1]
二维码

扫码加我 拉你入群

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

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

2012-4-28 21:32:59
epoh 发表于 2012-4-28 16:19
y
按照您的建议修改后又提示:
错误于FUN(X[[2L]], ...) : 不能改变因子的存储方式,这又是什么原因呢?
二维码

扫码加我 拉你入群

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

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

2012-4-28 22:09:20
铤而走险 发表于 2012-4-28 21:32
按照您的建议修改后又提示:
错误于FUN(X[[2L]], ...) : 不能改变因子的存储方式,这又是什么原因呢?
Error in FUN(X[[2L]], ...) :
  invalid to change the storage mode of a factor

这是数据格式问题
你数据传上来看看
二维码

扫码加我 拉你入群

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

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

2012-4-29 09:06:25
epoh 发表于 2012-4-28 22:09
Error in FUN(X[[2L]], ...) :
  invalid to change the storage mode of a factor
该程序是论坛上别人分享的,模型部分如下所示,数据在附件里,这是txt 格式的。请您帮忙看看到底问题在哪里!
modle {
     for (i in 1:N) {
              y ~dnorm(r,tau)    # tau corresponding to  
       r<-mu+Xi*J            # Xi corresponding to  #
       Xi[t]~dnorm(Jmu,Jtau)
        J[t]~dbern(lamda)
}
         Sigma<-1/sqrt(tau)
         JSigma<-1/sqrt(Jtau)
           mu~dnorm(0,1)       # prior distributions for parameters
           tau~dgamma(2, 2)
           Jmu~dnorm(0,1)
           Jtau~dgamma(2,2)
          lamda~dbeta(2,2)

}
jump.txt
大小:(5.52 KB)

 马上下载



二维码

扫码加我 拉你入群

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

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

2012-4-29 09:20:11
铤而走险 发表于 2012-4-29 09:06
该程序是论坛上别人分享的,模型部分如下所示,数据在附件里,这是txt 格式的。请您帮忙看看到底问题在哪 ...
我把y<-read.table("d:/Bugs/jump.dat")改为:y<-read.table("d:/Bugs/jump.txt")后可以运行了,但是Winbugs中什么结果也没有,运行的log 中视如下记录的,说各个参数都是update cannot be excuted,想请教是否程序本身有问题:
expected left pointing arrow <- or twiddles ~
data(D:/Bugs/data.txt)
command #Bugs:data cannot be executed (is greyed out)
compile(1)
inits(1,D:/Bugs/inits1.txt)
command #Bugs:inits cannot be executed (is greyed out)
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(5)
update(1000)
command #Bugs:update cannot be executed (is greyed out)
set(Sigma)
command #Bugs:set cannot be executed (is greyed out)
set(JSigma)
command #Bugs:set cannot be executed (is greyed out)
set(mu)
command #Bugs:set cannot be executed (is greyed out)
set(Jmu)
command #Bugs:set cannot be executed (is greyed out)
set(lamda)
command #Bugs:set cannot be executed (is greyed out)
set(Xi)
command #Bugs:set cannot be executed (is greyed out)
set(J)
command #Bugs:set cannot be executed (is greyed out)
set(deviance)
command #Bugs:set cannot be executed (is greyed out)
dic.set()
command #Bugs:dic.set cannot be executed (is greyed out)
update(1000)
command #Bugs:update cannot be executed (is greyed out)
coda(*,D:/Bugs/coda)
command #Bugs:coda cannot be executed (is greyed out)
stats(*)
command #Bugs:stats cannot be executed (is greyed out)
dic.stats()

DIC
history(*,D:/Bugs/history.odc)
command #Bugs:history cannot be executed (is greyed out)
save(D:/Bugs/log.odc)
save(D:/Bugs/log.txt)
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

分享

扫码加好友,拉您进群