jags

jags.parallel: setting less clusters than chains: “Error in res[[ch]] : subscript out of bounds”

帅比萌擦擦* 提交于 2019-12-12 13:20:20
问题 I have only 2 core CPU so logically I want to set only two parallel threads/clusters for jags.parallel . unfortunatelly, when I try it and the number of chains is 3 or 4, jags fails with an error: Error in res[[ch]] : subscript out of bounds Is lower number of threads (than chains) not allowed? I have not encountered such statement in the documentation. Anyway, it doesn't make sense to run 4 chains in 4 threads/clusters, when your CPU only has 2 cores! Threads will fight for CPU, caches won't

Possible directed cycle error in JAGS

瘦欲@ 提交于 2019-12-12 03:59:09
问题 I'm trying to fit a simplex model with poisson trick, the likelihood is Likelihood Simplex. The code is below model{ for (i in 1:n){ y[i] ~ dpois(lambda[i]) lambda[i] <- 0.5*log(phi[i]*(y[i]*(1-y[i]))^3) + 0.5*(1/phi[i])*d[i] d[i] <- ((y[i]-mu[i])^2)/(y[i]*(1-y[i])*mu[i]^2*(1-mu[i])^2) mu[i] <- beta0+beta1*income[i] + beta2*person[i] log(phi[i]) <- -delta0 } beta0 ~ dnorm(0,.001) beta1 ~ dnorm(0,.001) beta2 ~ dnorm(0,.001) delta0 ~ dnorm(0,.001) }" When I try to run the code with JAGS in R, I

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

Estimating unknown response variable in JAGS - unsupervised learning

不问归期 提交于 2019-12-11 11:34:10
问题 I am attempting to estimate response values of percentage cover ( COV ) from known distribution parameters. I can do this by specifying the response data as NAs in OpenBUGS (e.g. the code below) but JAGS won't allow this. Does anyone know how I can achieve this in JAGS? I think this falls into the category of 'unsupervised statistical learning' model { for (i in 1:n.sites) { # loop around sites # specify prior distribution forms for effectively unknown percentage cover COV[i] ~ dbeta(a[i], b

Specify a discrete weibull distribution in JAGS or BUGS for R

强颜欢笑 提交于 2019-12-11 06:12:37
问题 I am fitting a weibull model to discrete values using JAGS in R. I have no problem fitting a weibull to continuous data, but I run in to trouble when I switch to discrete values. Here is some data, and code to fit a weibull model in JAGS: #draw data from a weibull distribution y <- rweibull(200, shape = 1, scale = 0.9) #y <- round(y) #load jags, specify a jags model. library(runjags) j.model =" model{ for (i in 1:N){ y[i] ~ dweib(shape[i], scale[i]) shape[i] <- b1 scale[i] <- b2 } #priors b1

runjags object is too big

夙愿已清 提交于 2019-12-07 17:55:40
问题 I am trying to run JAGS using a new package runjags, because R2jags has a bug (the full model code is in the question https://stats.stackexchange.com/q/62006/5509): require("runjags") out <- run.jags("Poisson.OD.t.test.txt", params, win.data, nc, inits, nb*4/5, ni, nb*1/5) plot(out2, layout = c(4, 2)) It works as a charm, but the drawbacks of this package is that the runjags object returned by the run.jags function is already bundled with prepared charts and outputs and is too big. Just for

How to load rjags

半城伤御伤魂 提交于 2019-12-06 07:23:41
As with a lot of other people, I have issues loading and installing rjags. I get the error: library(rjags) Error : .onLoad failed in loadNamespace() for 'rjags', details: call: fun(libname, pkgname) error: Failed to locate any version of JAGS version 3 The rjags package is just an interface to the JAGS library Make sure you have installed JAGS-3.0.0.exe or higher from http://www.sourceforge.net/projects/mcmc-jags/files Error: package or namespace load failed for ‘rjags’ I am running R 3.2.2 on a PC (Windows 10), and have the JAGS programme installed at: C:\Program Files\JAGS\JAGS-4.0.0 Is

runjags object is too big

本小妞迷上赌 提交于 2019-12-05 22:30:57
I am trying to run JAGS using a new package runjags , because R2jags has a bug (the full model code is in the question https://stats.stackexchange.com/q/62006/5509 ): require("runjags") out <- run.jags("Poisson.OD.t.test.txt", params, win.data, nc, inits, nb*4/5, ni, nb*1/5) plot(out2, layout = c(4, 2)) It works as a charm, but the drawbacks of this package is that the runjags object returned by the run.jags function is already bundled with prepared charts and outputs and is too big. Just for comparison, the sizes of corresponding .Rdata files (2 chains, each of 500 saved iterations, 1000

How can I convert an mcmc.list to a bugs object?

一曲冷凌霜 提交于 2019-12-05 15:17:22
问题 I am using the rjags R library. The function coda.samples produces an mcmc.list , for example (from example(coda.samples) ): library(rjags) data(LINE) LINE$recompile() LINE.out <- coda.samples(LINE, c("alpha","beta","sigma"), n.iter=1000) class(LINE.out) [1] "mcmc.list" However, I would like to use the plot.bugs function, which requires a bugs object as input. Is it possible to convert an object from an mcmc.list to a bugs object, so that plot.bugs(LINE.out) ? Note that there is a similar

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