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/)
298
questions
2
votes
1
answer
1k
views
JAGS Multinomial mixture model with missing data
I am trying to fit a multinomial mixture model to data from a stream depletion survey. The data were collected by selecting a stream site that is a standard length (usually 150-200m depending on width)...
0
votes
1
answer
441
views
Predict values from complex Rjags model
It's the first time I'm working with R2Jags, MCM chains and Bayesian models and I'm having trouble to compute the predicted values for my model.
The model is based on research by Hallmann et al. 2017, ...
3
votes
1
answer
415
views
Hierarchical Version of Bayesian Change Detection Model in JAGS
I am trying to create a hierarchical changepoint detection model in JAGS, estimating group difference in changepoint based on individual changepoints in scores for an outcome variable (fictional in ...
0
votes
1
answer
295
views
How to use the parameters estimated by MCMC?
Considering this example, taken from the coursera course "Bayesian Statistics: Techniques and Models",
Dataset:
...
0
votes
0
answers
27
views
Conditional structure with 4 conditionals in JAGS
I'm using JAGS for Bayesian estimation.
Ideally, I would like to define 4 different scenarios (x=a, x=b, x=c, x=d). Depending on the scenario, some different actions should be done.
My problem is that ...
0
votes
0
answers
41
views
Definition of priors for GLM
I am building a generalized linear model using the logit function in R using JAGS. Whenever I saw code people only define priors for the parameters of the model, but never for parameters of the ...
1
vote
0
answers
67
views
rjags - implementing a weighted multivariate normal distribution [closed]
I am trying to implement a weighted multivariate normal distribution in JAGS 4.3.0
Here is the code I used:
...
1
vote
0
answers
15
views
How do I incorporate sample size as a random variable in a latent interval censored model
I've got a dataset wherein only every third success in a series of n trials is observed. I had originally used the following Bayesian model:
$$
y_i \sim \mathtt{floor}(z_i / 3) \\
z_i \sim B(n_i, p_z) ...
2
votes
1
answer
95
views
Is it correct to use the posterior distribution from a Bayesian model in other analysis?
I have written a Bayesian model in JAGS that I use to calculate the growth rates of several plant populations as well as their variance while taking into account the observation error during the ...
0
votes
0
answers
59
views
Bayesian model (Gibbs sampling) with frequency data for non-standard distribution
I have the following model.
\begin{align}
X &= D\,(F+S\,(1+G)) \\
D &\sim \mathrm{Exp}\,(\lambda) \\
F &\sim \mathrm{Unif}\,(0,1) \\
S &\sim \mathrm{Poi}\,(\sigma) \\
G &\sim \...
0
votes
0
answers
21
views
How to make predictions with parameters obtained from a zero-inflated Poisson model with Bayesian approach?
I have a dataset with one response variable and one explanatory variable. Here is my zero-inflated Poisson model with a Bayesian approach.
...
0
votes
0
answers
10
views
Arithmetic using summary means of the MCMC chains, differ from when I do the arithmetic directly using each row of the MCMC chains
I am trying to calculate the 'absolute risk difference' and 'needed to treat' (NNT). NNT is 1/(absolute risk difference) where the absolute risk difference is just the rate of an event in one ...
0
votes
0
answers
16
views
Bayesian modeling of data at different cluster level
I have the following data:
The response variable Y and the independent variable X2 were collected at state level (lowest level), while X1 are only available at country level.
The general form of my ...
1
vote
0
answers
46
views
Power of Bernoulli likelihood in Jags (R2jags) [closed]
In a fixed power prior model, the model is set up as:
$$ \pi(p_i \mid \alpha,\mathcal{D}_0) \propto L(p_i\mid \mathcal{D}_0)^{w} \pi(p_i) $$
Suppose that the event follows a Bernoulli distribution ...
0
votes
0
answers
67
views
What Bayesian priors are diffuse on the log scale?
I am trying to come up with priors for the intercept and coefficients of a Bayesian regression model on the log scale, but I can't get the resulting distribution of the prior to be diffuse once I log ...
1
vote
0
answers
74
views
Predicting from a Gamma Hurdle Model in JAGS
I fit a gamma hurdle model to invertebrate biomass data and am having trouble predicting from the model. I've been using these posts extensively to try to set it up:
Gamma hurdle model for continuous ...
1
vote
0
answers
149
views
Why am I getting very different results from jags and stan
Why am I getting different results from jags and stan in a simple linear regression model?
Using Sepal.Length ~ Petal.Length in the ...
0
votes
0
answers
215
views
Bayesian Multiple Regression with Interaction
I want to perform a Bayesian analysis (multivariate regression with an interaction term) using this model:
DEP ~ beta0 + beta1X1 + beta2X2 + beta3(X1X2)**
DEP = Dependent variable (continuous)
X1 = ...
0
votes
0
answers
113
views
Bayesian Inference with a Normal Likelihood and Gamma Prior
I am fairly new to (the eye-opening world of) Bayesian inference and machine learning and I am stuck at a inference problem that is important to my current research, where I want to introduce Bayesian ...
1
vote
0
answers
106
views
extracting subset of iteration in jags.samples() in r
Using rjags and jags.samples (), I have multiple parameters that are monitored and some parameters are in matrices. This means for example, with 2 chains and 5000 iterations, jags.samples() may return ...
3
votes
0
answers
476
views
How to specify a zero-inflated Dirichlet model in JAGS/BUGS
There was a recent publication discussing the advantages of the zero-inflated dirichlet for microbiome count data which is compositional (you are modeling a matrix of species relative abundance data ...
1
vote
0
answers
126
views
JAGS model to PyMC [closed]
I'm trying to translate a code that I have written in JAGS to PyMC but I'm getting stuck due to the recursion in the JAGS code that I can't figure out how to pass it to PyMC.
The model in JAGS is ...
1
vote
0
answers
57
views
Why is my 95% CI from a simulation being either 100% or 0%?
So what I intended doing with the code is to simulate dataset with the outcome being number of parasites that died (yi) out of every n=50 parasites on the host. There are 2 treatment groups (control ...
1
vote
0
answers
84
views
Hiearchical Beta-Binomial model via rjags: How to draw posterior sample/do inference on posterior exactly?
I have the following code for bugs model which I want to use with rjags:
...
21
votes
2
answers
9k
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 ...
2
votes
1
answer
240
views
Updating prior in MCMC with new estimates for parameters
I'm new to doing Bayesian analysis and I wanted to learn by using baseball data. I took a group of players and found their hits and at bats for various years and I want to be able to get estimates for ...
2
votes
1
answer
591
views
influence of bayesian priors: rjags and categorical variables
I am a bad statistician and new using Bayesian tools, and I am learning how to make regressions with rjags. While toying, I came across a situation I do not fully ...
0
votes
1
answer
433
views
Jags: Attempt to redefine node error, mixed effect regression [closed]
I want to perform a mixed effect regression in rjags, with a random slope and intercept. I define the following toy dataset:
...
4
votes
1
answer
3k
views
How to implement credible 95% interval for median odds ratio using JAGS?
As described in Merlo et al (J Epidem Comm Health 2006), the 95% credible interval for MOR is calculated using MCMC. MOR is defined as $\exp(\sqrt{2\sigma^2}\times 0.675)$, where $\sigma$ is the level-...
1
vote
2
answers
538
views
How posterior function is calculated in JAGS
I have a theoretical question. I understand the JAGS samples from the posterior function of a model. But I don't understand (nor I can find in the documentation) how it calculates the posterior in the ...
1
vote
0
answers
243
views
Zero trick in JAGS for GLMM [closed]
I'm trying to do zero trick but i got stuck. I tried the following model:
model
dGC.model <- function(){
C <- 10000
for(i in 1:(2*m)){
zeros[i] ~ dpois(zeros.mean[i])
zeros.mean[i] <...
0
votes
0
answers
25
views
Data-informed grouping of covariates in Bayesian Hierarchical Modeling?
Is there a way to place a prior on the first stage's betas that allows the second stage groups to be determined from the data? I am working with co-exposures where I am not super confident in how they ...
1
vote
1
answer
254
views
JAGS RUNTIME ERROR : Expected parameters with fixed values in function rep
I am trying to write jags code for the following scenario
Toss a coin with unknown probability of heads (p)
If heads, then draw a random integer from 1 to 12
If tails, then draw a random integer from ...
1
vote
1
answer
183
views
Change shape parameters in a beta distribution based in each datapoint [closed]
I am new to Bayesian statistics and I have been trying to implement a Beta Binomial model from a PhD thesis in rjags. The thesis describes prior distribution for the variables but I am stuck in how to ...
1
vote
0
answers
241
views
How to fit a scalable Bayesian VAR model in Stan/JAGS
I am trying to fit a Bayesian vector auto regressive model but I am struggling with the computation. I tried both JAGS and Stan to fit the model but I have never been able to fit it successfully. It ...
7
votes
2
answers
931
views
Appropriate GLM when response variable is proportion, but not binomial
The response variable I'm dealing with is the proportion of a total area that is suitable habitat for a species of interest. So although the response variable is bounded between 0 and 1, my intuition ...
1
vote
2
answers
68
views
Bayesian model predictions
I am using an exponential decay model for the prediction of chemical exposures. y[i] is measured exposure, and y_new[i] is a prediction for x_new. I expect that new predictions will have exponential ...
5
votes
0
answers
466
views
AR(1) model - which prior to use?
I want to use the following univariate model:
$y_t = \mu_t + \epsilon_t, \ \epsilon_t \sim N(0,1)$
$\mu_t = \phi \mu_{t-1} + \omega_t, \ \omega_t \sim N(0,\sigma_\omega^2)$
That is, $\mu_t$ follows ...
0
votes
0
answers
367
views
Does thinning in JAGS/Stan reduce computational time for simulating a chain of a given length?
Question
Let's say we have a complicated model whose posterior distribution we want to draw from using MCMC. To do this, we simulate a chain of total length $N=10,000$. For the sake of this question, ...
6
votes
1
answer
3k
views
Naive SE vs Time Series SE: which statistics should I report after Bayesian estimation?
I am new to Bayesian estimation.
When I do some estimations with JAGS, I find there are statistics called Naive SE and Time Series SE.
What exactly do they mean? Is it necessary that I report one or ...
0
votes
1
answer
96
views
JAGS error in the estimation of a simple INAR model
I am having a hard time try to figure out how to translate a simple INAR(1) model in JAGS.
\begin{equation}
Y_t = \alpha \circ Y_{t-1} + e_t
\end{equation}
where $\circ$ is the binomial thinning ...
1
vote
0
answers
668
views
How to model Beta distribution with Uniform prior in RJAGS? [closed]
I'm having trouble modeling a Bayesian problem in RJAGS.
I'm analyzing depth damage curves. In 1988, the US Army Corps of Engineers estimated that 1 foot of flooding would result in 32% mean damage ...
1
vote
1
answer
216
views
In JAGS, how can I fix a parameter to a distribution, as opposed to just a constant?
The first code chunk below (model1) is a JAGS script designed to estimate a two-group Gaussian mixture model with unequal variances. I am looking for a way to fix one of the parameters (say $\mu_2$) ...
2
votes
1
answer
3k
views
DIC, WAIC in JAGS
I have a Bayesian Hierarchical model using JAGS. In order to find the best model, I have compared the DIC of two models but It's not reliable. So, I decided to calculate WAIC from JAGS. However I have ...
0
votes
1
answer
519
views
Bayesian Statistics - How to weight a Poisson distributed response
I have a Bayesian GLM where the response that I'm interested in is count data. I want to weight the the response by the variance to account for uncertainty in the measurement. If the response was ...
6
votes
2
answers
2k
views
Example where the posterior from Jags and Stan are really different and have real impacts on decisions using the model
I have seen many people claiming Stan is "much better" than JAGS, meaning roughly this: "although Jags is much faster, the quality of the samples is worse. So it's worth waiting for the ...
4
votes
1
answer
1k
views
Truncating a posterior predictive distribution in JAGS
I have run into an error associated with truncating a distribution in JAGS.
In my minimum reproducible example, I have data for 9 observations and would like to find a posterior predictive ...
0
votes
1
answer
929
views
How to correctly include offset in Bayesian Zero-Inflated Poisson model in winbugs
I am trying to fit a Bayesian Zero-inflated model and I want to include an offset term.
When I compared the output of the pscl package; the result of the count model from the winbugs and pscl package ...
1
vote
2
answers
302
views
Framework for simulation study to validate bayesian models
I am looking for a framework that would allow to take JAGS/bugs model and on many sets of simulated data test if there is a bias (or not) in the parameter estimates (the real parameters would be known ...
0
votes
1
answer
127
views
Distributions with negative support in JAGS
I am creating a Bayesian regression model where I want to include a prior for a variable that can only have a negative coefficient. What distribution can I use that only has a negative support and is ...