Questions tagged [rjags]
149 questions
0
votes
1 answer
Error in update.jags(model, n.iter, ...) : Error in node sd[1] Invalid parent values
I am having error in node sd[1], it says invalid parent values in the compiler. I am working with a gaussian model for "Galaxies" data from "MASS"p package of R.
library(rjags)
library(MASS)
library(mcsm)
data("galaxies")
summary(galaxies)
y =…

Tahmeed
- 48
- 1
- 9
0
votes
1 answer
Hierarchical model using JAGS for R shows wrong number of means
I have 2 columns of data, y and grp and I am trying to create a JAGS model which is shown above. grp is group and I have 5 groups. The following code is from here. I am using this code because the description there under the heading Model and Data…

Mohan Radhakrishnan
- 3,002
- 5
- 28
- 42
0
votes
1 answer
jags priors in for loop
I'm trying to minimize my jags code by work with for loop. my original code is
data<- list(r1=c(16, 62, 14, 23, 570, 63, 63, 116),
r2=c(10, 66, 20, 27, 522, 31, 31, 95),
n1=c(53, 106, 56, 82, 1012, 201, 201, 2049),
…

Me28
- 107
- 7
0
votes
1 answer
rjags model negative binomial likelihood and gamma prior
I read in my data. I make the model string. I hand it JAGS. I get "Error in node y[1] - Node inconsistent with parents".
Y=read.table("data.txt",header=T)
Y=Y$Y
model_string <- "model{
# Likelihood:
for( i in 1 : N ) {
y[i] ~ dnegbin( l , r…

lazer-guided-lazerbeam
- 234
- 2
- 10
0
votes
1 answer
Hierarchical Mixture Model in Rjags
This is my first time using rjags, and I'm trying to fit some count data Y. I'm using a hierarchical mixture model as follows:
Y ~ p*Poisson(N*lambda1) + (1-p)*Poisson(N*lambda2)
lambda1 ~ Gamma(a,b)
lambda2 ~ Lognormal(c,d)
a ~ Gamma(1,1)
b ~…

ing
- 21
- 3
0
votes
0 answers
Model does sometime compile, sometimes it does not although nothing changes
So I have a rjags model given below. My problem is that when I want to run jags.model(), it sometimes compiles sometimes it does not. So I could literally run the jags.model() function and no error occurs when I immediately rerun the same…

Janosch
- 356
- 2
- 13
0
votes
0 answers
Jags RUNTIME ERROR: Compilation error on line 17. Attempt to redefine node delta[15,1,1]
I am having a problem to compile a Jags model using the following code. It seems that the parameter delta is being tried to be redefined (line 17 : delta[i, si[i, k], hh] ~ dnorm(md[i, si[i, k], hh], taud[i, si[i, k], hh])) at the beginning of the…

liso
- 23
- 5
0
votes
0 answers
Dirichlet Multinomial model in JAGS with categorical X
Can someone help with JAGS code for a Bayesian multinomial logistic model with one categorical X variable (Dirichlet prior)? My representative sample is the matrix "z" in the code below that represents the 3 outcomes and "site", in the bottom line…

user40950
- 1
- 3
0
votes
0 answers
Estimating DIC for a zoib beta regression model
I have the data and code below and would appreciate your help to estimate DIC (or AIC) for a beta regression model with zoib:
library(zoib)
data("GasolineYield", package = "zoib")
re.md <- zoib(yield ~ temp | 1 | 1, data=GasolineYield,
joint =…

Krantz
- 1,424
- 1
- 12
- 31
0
votes
1 answer
Outcome prediction using JAGS from R
[Code is updated and does not correspond to error messages anymore]
I am trying to understand how JAGS predicts outcome values (for a mixed markov model). I've trained the model on a dataset which includes outcome m and covariates x1, x2 and…

Rnout
- 29
- 7
0
votes
0 answers
R JAGS: invalid parent value in node (combining dcat and dnorm)
I am a newbie when it comes to using Jags and Rjags.
modelString = "
model {
for (i in 1:N){
y[i] ~ dt(mu,tau,nu)
}
tau <- nuless2/(sig^2)
nuless2 <- nu / nuless
nuless <- (nu-2)
sig ~ dnorm(0.02045457,10000000)
mu ~…

Laxus Phung
- 1
- 3
0
votes
1 answer
JAGS: prior's distribution inside a distribution
This is our first model:
# Data:
x1 = as.factor(c(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1))
x2 = as.factor(c(0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1))
x3 = as.factor(c(0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1))
x4 =…

Bram
- 342
- 1
- 12
0
votes
1 answer
Generate predictions using JAGS
I have a parametrised linear Gaussian Bayesian network and I am trying to make predictions on the model using rjags. I can do this for one observation but do not know how to pass multiple observations. Here is an…

user2957945
- 2,353
- 2
- 21
- 40
0
votes
1 answer
Reconstructing variables from mcmc objects
I am using rjags as a sampler. The model has 3 matrices defined. The coda.samples function returns a list of samples. If I take the first sample list the column names look something like this:
> colnames(output[[1]])
"A[1,1]" "A[2,1]" "A[1,2]" …

Davor Josipovic
- 5,296
- 1
- 39
- 57