jags

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

心不动则不痛 提交于 2019-12-04 01:27:36
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 question on stats.SE that has been unanswered for over a month. That question had a bounty that ended on

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

Choosing Different Distributions based on if - else condition in WinBugs/JAGS

允我心安 提交于 2019-12-01 16:46:12
I am trying to write a Winbugs/Jags model for modeling multi grain topic models (exactly this paper -> http://www.ryanmcd.com/papers/mg_lda.pdf ) Here I would like to choose a different distribution based on a particular value. For Eg: I would like to do something like `if ( X[i] > 0.5 ) { Z[i] ~ dcat(theta-gl[D[i], 1:K-gl]) W[i] ~ dcat(phi-gl[z[i], 1:V]) } else { Z[i] ~ dcat(theta-loc[D[i], 1:K-loc]) W[i] ~ dcat(phi-loc[z[i], 1:V]) } ` Is this possible to be done in Winbugs/JAGS? Winbugs/JAGS is not a procedural language, so you cannot use the construct like that. Use step function. Quote

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) ###