r2jags

strange jags.parallel error / avoiding lazy evaluation in function call

ⅰ亾dé卋堺 提交于 2019-12-18 08:57:40
问题 I have a function call (to jags.parallel ) that works when given a numerical argument like n.iter = 100 but fails when the argument uses a variable value, n.iter = n.iter . This looks like it might be a bug in jags.parallel A minimal reproducible example of the error: library(R2jags) model.file <- system.file(package="R2jags", "model", "schools.txt") J <- 8.0 y <- c(28.4,7.9,-2.8,6.8,-0.6,0.6,18.0,12.2) sd <- c(14.9,10.2,16.3,11.0,9.4,11.4,10.4,17.6) jags.data <- list("y","sd","J") jags

Using jags.parallel from within a function (R language Error in get(name, envir = envir) : object 'y' not found)

最后都变了- 提交于 2019-12-13 12:32:26
问题 Using jags.parallel from the command line or a script works fine. I can run this modified example from http://www.inside-r.org/packages/cran/R2jags/docs/jags just fine # An example model file is given in: model.file <- system.file(package="R2jags", "model", "schools.txt") #=================# # initialization # #=================# # data J <- 8.0 y <- c(28.4,7.9,-2.8,6.8,-0.6,0.6,18.0,12.2) sd <- c(14.9,10.2,16.3,11.0,9.4,11.4,10.4,17.6) jags.data <- list("y","sd","J") jags.params <- c("mu",

Saving jags.model in RData file

别等时光非礼了梦想. 提交于 2019-12-13 02:36:22
问题 Is there any way to save a jags.model() object into a RData or txt file ? To perform MCMC on a better computer, I have to save my model on one and using it in a new workspace. But I've some difficulty to use "save()" and "load()" function on R. Thanks for your advices. Added: I tried: jags <- jags.model('regression.bug', data = my.data, n.chains = 4, n.adapt = 1000) Then I would like save "jags" save( jags , file="jags.RData") It's look like if it's saved. But, when I try: ld.jags <- load(

RJAGS output Node inconsistent with parents

你说的曾经没有我的故事 提交于 2019-12-12 03:31:22
问题 Hi everyone I'm new in JAGS and currently doing a bayesian inference using mcmc through RJAGS. I've been trying my best to debug my code until I'm stuck with this error "Error in node e1[3] Node inconsistent with parents". e1<-c(1,1,0,1,1,0,0,1,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,1,1,0,0,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,0,1,1,0,0,1,1,1,1,0,1) e2<-c(1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,0,0,1,1,1,0,1,1,0,1,1,1,1,1) c1<-c(2412,3485,881,1515,1824,1603,865

Fit a bayesian linear regression and predict unobservable values

有些话、适合烂在心里 提交于 2019-12-04 04:49:33
问题 I'd like to use Jags plus R to adjust a linear model with observable quantities, and make inference about unobservable ones. I found lots of example on the internet about how to adjust the model, but nothing on how to extrapolate its coefficients after having fitted the model in the Jags environment. So, I'll appreciate any help on this. My data looks like the following: ngroups <- 2 group <- 1:ngroups nobs <- 100 dta <- data.frame(group=rep(group,each=nobs),y=rnorm(nobs*ngroups),x=runif(nobs

Fit a bayesian linear regression and predict unobservable values

你。 提交于 2019-12-02 01:47:07
I'd like to use Jags plus R to adjust a linear model with observable quantities, and make inference about unobservable ones. I found lots of example on the internet about how to adjust the model, but nothing on how to extrapolate its coefficients after having fitted the model in the Jags environment. So, I'll appreciate any help on this. My data looks like the following: ngroups <- 2 group <- 1:ngroups nobs <- 100 dta <- data.frame(group=rep(group,each=nobs),y=rnorm(nobs*ngroups),x=runif(nobs*ngroups)) head(dta) JAGS has powerful ways to make inference about missing data, and once you get the

jags.parallel - Error in get(name, envir = envir) : invalid first argument

故事扮演 提交于 2019-11-29 10:57:15
When using jags.parallel , I get the following error: > out <- jags.parallel(win.data, inits, params, "Poisson.OD.t.test.txt", + nc, ni, nb, nt); Error in get(name, envir = envir) : invalid first argument The same call using jags function runs OK. I have only found one thread on this topic , but there is only one speculative suggestion that does not apply nor work here. Reproducible code, taken from Introduction to WinBUGS for ecologists, see chapter 14.1 (slightly modified): set.seed(123) ### 14.1.2. Data generation n.site <- 10 x <- gl(n = 2, k = n.site, labels = c("grassland", "arable"))

jags.parallel - Error in get(name, envir = envir) : invalid first argument

假装没事ソ 提交于 2019-11-28 04:08:15
问题 When using jags.parallel , I get the following error: > out <- jags.parallel(win.data, inits, params, "Poisson.OD.t.test.txt", + nc, ni, nb, nt); Error in get(name, envir = envir) : invalid first argument The same call using jags function runs OK. I have only found one thread on this topic, but there is only one speculative suggestion that does not apply nor work here. Reproducible code, taken from Introduction to WinBUGS for ecologists, see chapter 14.1 (slightly modified): set.seed(123) ###