首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R2WinBUGS -警告消息

R2WinBUGS -警告消息
EN

Stack Overflow用户
提问于 2011-11-15 22:39:17
回答 3查看 6K关注 0票数 3

我试着用这个例子来使用R2WinBUGS:

code

(请仅考虑以下部分:### 5.4。使用WinBUGS进行分析)

我收到以下错误消息:

代码语言:javascript
复制
Error in file(con, "wb") : cannot open the connection
In addition: Warning messages:
1: In file.create(to[okay]) :
  cannot create file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry_Rsave.odc', reason 'Permission denied'
2: In file(con, "wb") :
  cannot open file 'c:/Program Files/WinBUGS14//System/Rsrc/Registry.odc': Permission denied
Warning message:
running command '"c:/Program Files/WinBUGS14//WinBUGS14.exe" /par "D:/R2WinBUGS/normal/script.txt"' had status 1 
> 

我不确定这对于正确的功能是否至关重要(其他一切看起来都很好)。有没有办法摆脱这个?

谢谢。

克里斯蒂安

PS:

这是R代码:

代码语言:javascript
复制
library(R2WinBUGS)
setwd("D:/R2WinBUGS/normal")

y10 <- rnorm(n = 10, mean = 600, sd = 30) # Sample of 10 birds
y1000 <- rnorm(n = 1000, mean = 600, sd = 30) # Sample of 1000 birds

# Save BUGS description of the model to working directory
sink("model.txt")
cat("
model {

# Priors
 population.mean ~ dunif(0,5000)        # Normal parameterized by precision
 precision <- 1 / population.variance   # Precision = 1/variance
 population.variance <- population.sd * population.sd
 population.sd ~ dunif(0,100)

# Likelihood
 for(i in 1:nobs){
    mass[i] ~ dnorm(population.mean, precision)
 }
}
",fill=TRUE)
sink()

# Package all the stuff to be handed over to WinBUGS
# Bundle data
win.data <- list(mass = y1000, nobs = length(y1000))

# Function to generate starting values
inits <- function()
  list (population.mean = rnorm(1,600), population.sd = runif(1, 1, 30))

# Parameters to be monitored (= to estimate)
params <- c("population.mean", "population.sd", "population.variance")

# MCMC settings
nc <- 3                 # Number of chains
ni <- 1000              # Number of draws from posterior (for each chain)
nb <- 1                 # Number of draws to discard as burn-in
nt <- 1                 # Thinning rate

# Start Gibbs sampler: Run model in WinBUGS and save results in object called out
out <- bugs(data = win.data, inits = inits, parameters.to.save = params, model.file = "model.txt", 
n.thin = nt, n.chains = nc, n.burnin = nb, n.iter = ni, debug = TRUE, DIC = TRUE, working.directory = getwd())

ls()

out                 # Produces a summary of the object

names(out)

str(out)

hist(out$summary[,8])           # Rhat values in the eighth column of the summary
which(out$summary[,8] > 1.1)        # None in this case

par(mfrow = c(3,1))
matplot(out$sims.array[1:999,1:3,1], type = "l")
matplot(out$sims.array[,,2] , type = "l")
matplot(out$sims.array[,,3] , type = "l")

par(mfrow = c(3,1))
matplot(out$sims.array[1:20,1:3,1], type = "l")
matplot(out$sims.array[1:20,,2] , type = "l")
matplot(out$sims.array[1:20,,3] , type = "l")

par(mfrow = c(3,1))
hist(out$sims.list$population.mean, col = "grey")
hist(out$sims.list$population.sd, col = "blue")
hist(out$sims.list$population.variance, col = "green")

par(mfrow = c(1,1))
plot(out$sims.list$population.mean, out$sims.list$population.sd)

pairs(cbind(out$sims.list$population.mean, out$sims.list$population.sd, out$sims.list$population.variance))

summary(out$sims.list$population.mean)
summary(out$sims.list$population.sd)
sd(out$sims.list$population.mean)
sd(out$sims.list$population.sd)

summary(lm(y1000 ~ 1))
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-11-16 00:15:22

可能是windows UAC故障。默认情况下,UAC不允许程序员写入除用户文件夹以外的任何内容。您可以通过以管理员身份运行R来更改这一点。但我认为这会改变库文件夹,除非它被硬编码到Renviron.site中(在R\etc文件夹中),但我不是100%确定。

票数 7
EN

Stack Overflow用户

发布于 2013-03-31 02:22:31

我能够通过定义"bugs.directory“来解决这个问题。

out <- bugs(data = win.data,inits = inits,parameters.to.save = params,model.file = "model.txt",n.thin = nt,n.chains = nc,n.burnin = nb,n.iter = ni,debug = FALSE,DIC = TRUE,working.directory = getwd(),bugs.directory = 'c:/WinBUGS14')

票数 3
EN

Stack Overflow用户

发布于 2011-11-15 23:43:30

你的链接指向一个巨大的文件,这个文件跨越了一本书的许多章节。在评论部分,它说:

代码语言:javascript
复制
# You may have to add a 'working.directory' argument to calls to
# the function bugs().

你做过了吗?还有一堆特定于用户的东西,比如:

代码语言:javascript
复制
setwd("C:/_Marc Kery/_WinBUGS book/Naked code") # May have to adapt that

您是否对这些项目进行了适当的修改?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8138051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档