Questions tagged [jags]

"JAGS is Just Another Gibbs Sampler. It is a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation not wholly unlike BUGS." (http://mcmc-jags.sourceforge.net/)

Filter by
Sorted by
Tagged with
41
votes
4answers
7k views

OpenBugs vs. JAGS

I am about to try out a BUGS style environment for estimating Bayesian models. Are there any important advantages to consider in choosing between OpenBugs or JAGS? Is one likely to replace the other ...
31
votes
1answer
6k views

For which distributions are the parameterizations in BUGS and R different?

I have found some distributions for which BUGS and R have different parameterizations: Normal, log-Normal, and Weibull. For each of these, I gather that the second parameter used by R needs to be ...
16
votes
2answers
5k views

What prior distributions could/should be used for the variance in a hierarchical bayesisan model when the mean variance is of interest?

In his widely cited paper Prior distributions for variance parameters in hierarchical models (916 citation so far on Google Scholar) Gelman proposes that good non-informative prior distributions for ...
14
votes
3answers
983 views

Bayesian variable selection — does it really work?

I thought I might toy with some Bayesian variable selection, following a nice blog post and the linked papers therein. I wrote a program in rjags (where I am quite a rookie) and fetched price data ...
13
votes
2answers
5k views

Parameters without defined priors in Stan

I've just started to learn to use Stan and rstan. Unless I've always been confused about how JAGS/BUGS worked, I thought you always had to define a prior ...
13
votes
1answer
5k views

Regularized bayesian logistic regression in JAGS

There are several math-heavy papers that describe the Bayesian Lasso, but I want tested, correct JAGS code that I can use. Could someone post sample BUGS / JAGS code that implements regularized ...
12
votes
1answer
5k views

How to generate predictions with rjags?

I've used rjags to run MCMC on a model, specified in the JAGS language. Is there a good way to extract that model and perform predictions with it (using the posterior distributions of my parameters)? ...
12
votes
2answers
4k views

How can I set up a zero-inflated poisson in JAGS?

I am trying to set up a zero-inflated poisson model in R and JAGS. I am new to JAGS and I need some guidance on how to do that. I've been trying with the following where y[i] is the observed ...
12
votes
2answers
584 views

MCMC converging to a single value?

I'm trying to fit a hierarchical model using jags, and the rjags package. My outcome variable is y, which is a sequence of bernoulli trials. I have 38 human subjects which are performing under two ...
11
votes
2answers
1k views

How do programs like BUGS/JAGS automatically determine conditional distributions for Gibbs sampling?

Seems like full conditionals are often quite difficult to derive, yet programs like JAGS and BUGS derive them automatically. Can someone explain how they algorithmically generate full conditionals for ...
10
votes
2answers
6k views

How can I model a proportion with BUGS/JAGS/STAN?

I am trying to build a model where the response is a proportion (it is actually the share of votes a party gets in constituencies). Its distribution is not normal, so I decided to model it with a beta ...
10
votes
2answers
5k views

Censoring/Truncation in JAGS

I have a question on how to fit a censoring problem in JAGS. I observe a bivariate mixture normal where the X values have measurement error. I would like to model the true underlying 'means' of the ...
10
votes
3answers
3k views

Weighted generalized regression in BUGS, JAGS

In R we can "prior weight" a glm regression via the weights parameter. For example: ...
10
votes
1answer
1k views

Managing high autocorrelation in MCMC

I'm building a rather complex hierarchical Bayesian model for a meta-analysis using R and JAGS. Simplifying a bit, the two key levels of the model have $$ y_{ij} = \alpha_j + \epsilon_i$$ $$\alpha_j =...
10
votes
2answers
1k views

Hierarchical models for multiple comparisons - multiple outcomes context

I've just been (re-)reading Gelman's Why we (usually) don't have to worry about multiple comparisons. In particular the section "Multiple outcomes and other challenges" mentions using a hierarchical ...
9
votes
4answers
3k views

Vector multiplication in BUGS and JAGS

In R, c(3,1,0) * c(2,0,1) == c(6,0,0). This is not dot product and it's not cross product. First, what is the name for this product, and second, does it work in WinBUGS, OpenBUGS and/or JAGS?
9
votes
1answer
5k views

Missing values in response variable in JAGS

Gelman & Hill (2006) say: In Bugs, missing outcomes in a regression can be handled easily by simply including the data vector, NA’s and all. Bugs explicitly models the outcome variable, and ...
9
votes
1answer
415 views

How many sides does a die have? Bayesian inference in JAGS

Problem I would like to do some inference on a system analogous to die with an unknown number of sides. The die is rolled several times, after which I would like to infer a probability distribution ...
9
votes
2answers
2k views

How can I generate a plot similar to that produced by plot.bugs and plot.jags from an mcmc.list? [closed]

R seems to be able to output nice summary plots from the bugs and jags objects generated by the functions R2WinBUGS::bugs and ...
8
votes
1answer
2k views

How does dinterval() for interval censored data work in JAGS?

I am trying to understand how dinterval() works in JAGS for censored data. I am modeling coarse data where I only have upper and lower bounds for each data point (not the true value). Here is a ...
8
votes
1answer
745 views

Combining data from different sources

I want to combine data from different sources. Let's say I want to estimate a chemical property (e.g. a partitioning coefficient): I have some empirical data, varying due to measurement error around ...
8
votes
1answer
700 views

What level to use when comparing subjects in a hierarchical Bayesian analysis?

Say that I have an experiment where I test the reaction time of a number of subjects where each subject makes many reaction time trials. In a Bayesian framework the reaction times ($y$) could be ...
8
votes
1answer
1k views

When making inferences about group means, are credible Intervals sensitive to within-subject variance while confidence intervals are not?

This is a spin off of this question: How to compare two groups with multiple measurements for each individual with R? In the answers there (if I understood correctly) I learned that within-subject ...
8
votes
1answer
5k views

Specify a Zero-inflated (Hurdle) Gamma Model in JAGS/BUGS

I'm trying to use a zero-inflated gamma model (or a gamma 'hurdle' model). The model is a mixture of logistic regression and generalized linear modeling. I can do this analysis in two steps: 1) do a ...
8
votes
3answers
2k views

Longitudinal models in R and WINBUGS or JAGS

I've tried to use R to fit some longitudinal models, mostly via lmer and nlme packages. However, it seems that many standard ...
8
votes
1answer
1k views

Hierarchical Bayesian analysis on difference of proportions

Why Hierarchical? : I've tried researching this problem, and from what I understand, this is a "hierarchical" problem, because you are making observations about observations from a population, rather ...
8
votes
2answers
1k views

Modelling a mixed model in JAGS/BUGS [closed]

I am currently in the process of implementing a model for soccer result prediction in JAGS. Actually, I have implemented several, but I have reached my most difficult challenge yet: A model described ...
7
votes
6answers
2k views

R2jags does not remove the burn in part sometimes?

I found out that the function jags() in the R2jags package sometimes does not remove the burn in part even with the option ...
7
votes
2answers
7k views

How to use the SD of a normal sampling distribution to specify the gamma prior for the corresponding precision?

The gamma distribution is a commonly used prior distribution for the precision ($1/sd^2$) of a normal distribution in Bayesian hierarchical modeling. I want to use an informed prior for the variance ...
7
votes
1answer
6k views

What is causing autocorrelation in MCMC sampler?

When running a Bayesian analysis, one thing to check is the autocorrelation of the MCMC samples. But I don't understand what is causing this autocorrelation. Here, they are saying that High ...
7
votes
1answer
2k views

Tips and tricks for getting good parameter estimates using Bayesian nonlinear regression

I've been playing around with fitting nonlinear models using rjags. Specifically 3 and 4 parameter sigmoid curves, e.g., ...
7
votes
1answer
1k views

Quantile regression in JAGS

I am trying to implement a simple quantile regression in R using JAGS: ...
7
votes
1answer
2k views

Bayesian mixed model regression with a between subjects factor

I'm trying to specify a model in JAGS/rjags with one between subjects factor (a, with two levels - Y, N) interacting with one repeated measures continuous variable x plus subject varying slopes and ...
7
votes
2answers
1k views

What level to use when making inferences on the group mean in a hierarchical Bayesian analysis?

(This question is a bit related to a previous question of mine, but that question was about between subject comparison while this question is specifically about making inferences the group mean.) ...
7
votes
2answers
456 views

First iteration in MCMC coda chain is different from initial values

I have my jags output object. In order to understand how MCMC coda chains work, I tried to see if first iteration in each MCMC chain is equal to the initial values supplied. And it is different! The ...
6
votes
2answers
1k views

Should coin flips be modeled as Bernoulli or binomial draws in RJags?

What is the best way to model coin flips as a hierarchical model? Do you say coin draws are a series of draws from Bernoulli trials or as one draw from a binomial distribution? That is something like ...
6
votes
1answer
5k views

Ordered logit in JAGS

I am trying to code a simple model with JAGS: ...
6
votes
1answer
2k views

Define Priors for Dirichlet Distribution parameters in JAGS

I'm defining a Multinomial-Dirichlet model in JAGS and want to assign some hyperpriors to the parameters of the Dirichlet distribution. In the WinBugs manual I read that "the parameters of Dirichlet ...
6
votes
1answer
4k views

How do I parameterize a Weibull distribution in JAGS / BUGS?

Based on the answer to a previous question, For which distributions are the parameterizations in BUGS and R different? I have been transforming R parameterizations to JAGS parameterizations, but I ...
6
votes
1answer
1k views

What's the Bayesian counterpart to Pearson product-moment correlation?

I was wondering what the counterpart to Pearson product-moment correlation would be in a Bayesian framework. Or if there are many alternatives, what would be the most convenient or conventional method....
6
votes
2answers
3k views

How to conditionally run element of JAGS script based on user supplied variable?

Background: I often find that when working with JAGS that I end up with a lot of JAGS scripts as I explore different models. After a while I might settle on a set of models that I'm going to report, ...
6
votes
2answers
3k views

Hierarchical multinomial logit with R/JAGS

I am working on a small project where I have to do a Choice Based Conjoint (CBC) analysis. In order to get the part-worths for the different consumers I need to estimate a hierarchical multinomial ...
6
votes
1answer
556 views

Does JAGS have an R front end like brms for Stan? [closed]

Does JAGS have an R front end like brms / rstanarm for Stan? Is anyone working on one for JAGS?
6
votes
1answer
4k views

How to specify the Wishart distribution scale matrix

I'm running the below Bayesian mixing model in R using the rjags package, but I am having difficultly in specifying the scale matrix for the Wishart distribution. Essentially, I want Sigma.inv to be a ...
6
votes
2answers
984 views

R - how to get standard error for a breakpoint/parameter in a piecewise regression

I'm new to asking questions here, so I hope this is a reasonable place for this. I am trying to fit a piece-wise regression. I expect my response (y) to increase from x0 to somewhere along x, then to ...
6
votes
0answers
2k views

Hyper-prior for negative binomial in hierarchical model using JAGS/BUGS

Below I'm using a negative binomial because it is more flexible than a simple poisson model. The data are counts $y$ of events for 16 individuals $x$. There are 14 counts (i.e. counting periods) for ...
6
votes
0answers
1k views

Label Switching in WinBugs/JAGS

I am using JAGS to estimate a Dirichlet Process Mixture of Normals. The code works well and the estimated density is accurate. However, I would like to know which component each observation is ...
5
votes
1answer
2k views

Right-censored survival fit with JAGS

Update: I got the JAGS model running and this eliminates the distracting part of my question. It's really about the proper preparation of data for dinterval() and inits. I can't find a concrete ...
5
votes
1answer
3k views

Calculate R-squared with JAGS and R

I have the following model that I am running in JAGS from R: ...
5
votes
2answers
5k views

Debugging JAGS and BUGS [closed]

I'm working on a not-too-fancy Bayesian model in R and JAGS. The goal is to isolate coder errors in a content analysis task. Code and output are given below. The larger question is how to go about ...