【发布时间】:2015-03-11 16:51:50
【问题描述】:
我正在使用 R2WinBugs 包。我想将之前在 R 脚本中计算的两个参数传递给模型函数
c0yy <- 0.1
syy <- 0.0001
#Model
model <- function(c0yy,syy){
#Likelihood
for(i in 1:n){
y[i] ~ dnorm(mu[i],cyy)
}
#Regression formula
for(i in 1:n){
mu[i] <- alpha + gamma * x[i]
}
#Priors for the regression parameters
alpha ~ dnorm(0,0.000001)
gamma ~ dnorm(0,0.000001)
#Priors for the precision parameter
cyy ~ dnorm(c0yy,syy)
#Monitored variables
beta <- gamma/(alpha-1)
}
filename <- file.path(tempdir(), "Olm.txt")
write.model(model, filename)
但我收到此错误
made use of undefined node c0yy
如果我在模型函数中替换 c0yy 和 syy 的值,它可以工作。有帮助吗?
谢谢
【问题讨论】: