Questions tagged [rjags]
149 questions
3
votes
0 answers
Constraining Bayesian multinomial logistic in R via JAGS
I am learning how to fit Bayesian multinomial logistic models in R. This is my first attempt at using JAGS via rjags. The code illustrates with a MWE what I am trying to do:
## simulate data
set.seed(123)
n=2000
rr<-rmultinom(n, 3,…

Ashley Naimi
- 232
- 1
- 9
2
votes
1 answer
JAGS: Use cell matrix as data input for excluding NA
Below is my model and example data I would use. There are some NA in the data that I needed to set priors to generate numbers but this way may cause some errors. I was wondering if I could just let JAGS skip the NA so like have a matrix with…

Kenny
- 361
- 1
- 8
2
votes
1 answer
Error: Attempt to redefine node in linear regression
I have fitted following simple linear regression Bayesian model using rjags.
I was able to run the model by specifying all the predictors separately(like for a lm object). Now I want to learn how to specify the predictors by introducing them as a…

student_R123
- 962
- 11
- 30
2
votes
1 answer
JAGS/BUGS error - Possible directed cycle involving some or all of the following nodes
My dataset is about penalty kicks and contains 106 rows and the features are :
The kick direction
The player's strong foot
HomeAway that tells us if the player is playing in his town or away
I would like to perform a multinomial logistic…

ShilZoyer
- 21
- 5
2
votes
1 answer
What is the algorithm of jags with discrete likelihood and continuous prior
I am trying to understanding the following rjags code.
library(rjags)
set.seed(1)
N <- 10
p <- rep(10,N)
cat("
model {
for (i in 1:N) {
p[i] ~ dpois(lambda)
}
lambda <- 2*exp(-2*alpha*3)/(2*pow(4,2))
alpha ~…

Ke Qin
- 25
- 1
- 5
2
votes
0 answers
RJAGS unable to find appropriate sampler when constraining covariance matrix
I am using RJAGS to make inference on mean and covariance matrix from some data and I noticed that whenever I put a constraint in the precision matrix I receive the following error message
Error in jags.model(file = "model.tmp", data = data) :…

arsenio
- 21
- 2
2
votes
1 answer
Suppress JAGS "value out of range" warnings in R
I'm running a large number of JAGS models in R using the jags function of the R2jags package (which uses the rjags package to run JAGS).
I get a lot of warnings printed in the console:
value out of range in 'lgamma'
Printing these warnings seems…

Scransom
- 3,175
- 3
- 31
- 51
2
votes
1 answer
rjags error Error in mat[, "deviance"] : subscript out of bounds
I'm running a model in R using the package 'jagsUI' and the model begins to run for a little bit, but then I get the message
"Error in mat[, "deviance"] : subscript out of bounds
In addition: Warning message:
In order.params(samples,…

Curtis
- 449
- 1
- 4
- 17
2
votes
1 answer
predicting with zoib models (MCMC / RJags)
I am using the zoib package in R to build zero-inflated beta regression models. I am looking for a simple way to use the models that zoib produces to calculate a predicted response for a new dataset. By "new dataset" I mean data not used to build…

bear
- 21
- 3
2
votes
1 answer
Define conditional linear Gaussian network using rjags
I am struggling to define a conditional linear Gaussian Bayesian network using rjags.
(A clg BN is defined by a continuous child node (outcome) having both a continuous normal and a discrete parent (predictors))
For the net below, A is discrete, D…

user2957945
- 2,353
- 2
- 21
- 40
2
votes
1 answer
Translating glmer (binomial) into jags to include a correlated random effect (time)
Context:
I have a 12 item risk assessment where individuals are given a rating from 0-4 (4 being the highest risk). The risk assessment can be done multiple times for each individual (max = 19, but most only have less than 5 measurements).
The…

Helen
- 23
- 4
1
vote
0 answers
updated Rstudio and R, now unable to install rjags
I just updated Rstudio (2023.03.0 Build 386) and R (R version 4.2.3 (2023-03-15 ucrt) -- "Shortstop Beagle"). I am trying to install rjags, R2jags, and simmR. Everything else is dependent on rjags.
When intstalling rjags I get the error:
Error:…

vermicellion
- 338
- 2
- 14
1
vote
1 answer
How do I correct the error: RUNTIME ERROR: Compilation error on line 4. Index out of range taking subset of y
I've built a linear regression model using rjags but I am getting a runtime error saying the index is out of range. I've looked for advice online but can't find anything that I understand or addresses this exact problem.
Here is my…

Louisa Wareing
- 19
- 3
1
vote
1 answer
"Failed to set trace monitor for deviance There are no observed stochastic nodes" error when running JAGS model in R
I'm trying to get an N-mixture model to run in JAGS for a stats class that I'm currently in. However, I keep getting the error "Failed to set trace monitor for deviance
There are no observed stochastic nodes" whenever I try to run the model. At the…

Josh
- 49
- 5
1
vote
1 answer
Jags: Attempt to redefine node error, mixed effect regression
I want to perform a mixed effect regression in rjags, with a random slope and intercept. I define the following toy dataset:
library(ggplot2)
library(data.table)
global_slope <- 1
global_int <- 1
Npoints_per_group <- 50
N_groups <- 10
pentes <-…

denis
- 5,580
- 1
- 13
- 40