Questions tagged [jags]

a cross-platform Gibbs sampler similar to BUGS for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo simulation.

A cross-platform Gibbs sampler similar to BUGS for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo simulation.

Available at http://mcmc-jags.sourceforge.net.

472 questions
395
votes
1 answer

Representing Parametric Survival Model in 'Counting Process' form in JAGS

I'm trying to build a survival model in JAGS that allows for time-varying covariates. I'd like it to be a parametric model — for example, assuming survival follows the Weibull distribution (but I'd like to allow the hazard to vary, so exponential is…
jwdink
  • 4,824
  • 5
  • 18
  • 20
13
votes
3 answers

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

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"),…
David LeBauer
  • 31,011
  • 31
  • 115
  • 189
11
votes
1 answer

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

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…
user662239
  • 145
  • 2
  • 6
10
votes
1 answer

Logistic regression when response is a proportion (using JAGS)

I am trying to fit a logistic regression model in JAGS, but I have data in the form of (# success y, # attempts n), rather than a binary variable. In R, one can fit a model to data such as these by using glm(y/n ~ ) with the "weights" argument, but…
Kirk Fogg
  • 521
  • 5
  • 14
9
votes
1 answer

Weird output of poisson GLM with an iid random effect in r

I am trying run rjags in R (via Rstudio) to estimate parameters alpha&beta and hyperparameter tau.nu of the model following: y_i|x_i~pois(eta_i), eta_i=exp(alpha + beta*x_i + nu_i), nu_i~N(0,tau.nu) there is my code: #generating data N = 1000 x =…
Yuki
  • 125
  • 5
7
votes
1 answer

Is it possible to run multiple chains with JAGS on multiple cores (subdividing chains)

I’m wondering if it’s possible to subdivide 3 chains in JAGS on 5 or 6 cores, for example. Here is my code: library(parallel) # There is no progression bar using parallel jags.parallel(data = d$data, inits =…
M. Beausoleil
  • 3,141
  • 6
  • 29
  • 61
7
votes
1 answer

Syntax error from rjags

I'm trying to fit a hierarchical model with rjags for the first time; it looks pretty simple on paper, but I'm getting an "Error parsing model file: syntax error on line 5 near "[" " that I'm totally not able to interpret. Can you help me and tell…
user115318
7
votes
1 answer

Cauchy prior in JAGS

I'm building a multi-level Bayesian model using rJAGS and I would like to specify a Cauchy prior for several of my parameters. Is there a way to do this in JAGS, or do I need to switch to STAN? My JAGS model is below. I'd like to replace the…
Emily
  • 825
  • 3
  • 10
  • 20
7
votes
1 answer

Rjags error message: Dimension mismatch

I'm trying to study Bayesian analysis based on book "Doing Bayesian Data Analysis: A Tutorial with R, JAGS, and Stan (2015)". In this book, there are examples. So, I'm trying to replicate this example in R. However, I have got an error message in…
kmangyo
  • 1,147
  • 1
  • 12
  • 13
6
votes
1 answer

Three-level nested mixed-effects model

I am trying to model a three-level nested linear mixed effects model in rjags (by three-level: multiple observations for multiple individuals within multiple groups). There are unique sets of individuals in the groups. The equivalent model in lme4…
user2957945
  • 2,353
  • 2
  • 21
  • 40
6
votes
2 answers

if/else statement for defining a distribution in JAGS

In JAGS I'd like to define a Poisson distribution for parameter w[i] which is also truncated (greater than or equal to 2) if another parameter, e[i], is greater than 0. Essentially I want it to represent: w[i] ~ ifelse( e[i] > 0, dpois(mu) T(2,) ,…
james_980
  • 75
  • 1
  • 4
6
votes
2 answers

Manipulating mcmc.list object in R

I have used JAGS called via rjags to produce the mcmc.list object foldD_samples, which contains trace monitors for a large number of stochastic nodes (>800 nodes). I would now like to use R to compute a fairly complicated, scalar-valued function of…
Jacob Socolar
  • 1,172
  • 1
  • 9
  • 23
6
votes
1 answer

Parallel RJAGS with convergence testing

I'm modifying an existing model using RJAGS. I'd like to run chains in parallel, and occasionally check the Gelman-Rubin convergence diagnostic to see if I need to keep running. The problem is, if I need to resume running based on the diagnostic…
sjc
  • 1,117
  • 3
  • 19
  • 28
6
votes
1 answer

How can I save a JAGS model object in R?

I am using the package rjags to do MCMC in R and I would like to save the output of the function jags.model for later use in another R session. Here is a simple example for the mean of a Normal distribution: library(rjags) N <- 1000 x <- rnorm(N, 0,…
sieste
  • 8,296
  • 3
  • 33
  • 48
6
votes
2 answers

How to combine multiple chains from rjags into one chain in R?

I typically call JAGS from rjags with several chains for diagnostic purposes (e.g., 4 chains). After that I often want to do some post processing on the posterior parameter estimates (e.g., use predicted values, compute additional statistics).…
Jeromy Anglim
  • 33,939
  • 30
  • 115
  • 173
1
2 3
31 32