Questions tagged [r2jags]

R2Jags is an R package that interfaces with the JAGS Gibbs sampler.

Information and Downloads:

depends on another package, .

95 questions
0
votes
1 answer

Having trouble with Bayesian Inference model - JAGS with R

I've been trying to reproduce the results of the following paper using R and JAGS with no success. I can get the model to run, but the results shown are consistently different. Link for the paper:…
0
votes
1 answer

R JAGS: Dimension mismatch

I am trying to run a model in JAGS but I got the following error: Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Cannot insert node into m[1]. Dimension mismatch The model I specified…
eleg23
  • 1
  • 1
0
votes
2 answers

Bayesian Rolling Poisson Regression in Jags (via R2jags)

The Problem I have a small dataset (N=100). I need to run a Poisson regression, but excluding one observation at a time (hence, a Rolling Poisson Regression). There are several predictors in the equation, but I care about one (call it b.x). My idea…
0
votes
1 answer

JAGS errors: "Resolving undeclared variables" and "Invalid vector argument to exp"

This is my first time using JAGS and I ran into some errors when modeling my data. Here is a brief description of my data: A total of n people (e.g., 2) each solved m problems (e.g., 6). All problems have 3 answers, each of a certain value V. Here…
ramund
  • 185
  • 11
0
votes
0 answers

RJAGS output Node inconsistent with parents

Hi everyone I'm new in JAGS and currently doing a bayesian inference using mcmc through RJAGS. I've been trying my best to debug my code until I'm stuck with this error "Error in node e1[3] Node inconsistent with parents".…
0
votes
1 answer

read data from a file rjags

My data file looks something like this: list(y=structure(.Data=c(26, 228, 31, ...)), .Dim=c(413,9)) Let's say this file is saved as "data.txt". If I'm working in 'R2OpenBUGS', it allows me to pass the data as a file with no problem: mcmc <-…
Babak
  • 497
  • 1
  • 7
  • 15
0
votes
1 answer

JAGS - apply function to all parameter nodes

I'm new to JAGS and I'm running a model in R via R2jags package. The model code is based on a code taken from Kéry & Schaub 2012 ('Bayesian Population Analysis using WinBUGS"), pg 399. Chi-square discrepancy measure is computed model { .... for(g…
Quechua
  • 124
  • 10
0
votes
2 answers

Winbugs to Rjags beta binomial model translation

I am working through the textbook "Bayesian Ideas and Data Analysis" by Christensen et al. There is a simple exercise in the book that involves cutting and pasting the following code to run in Winbugs: model{ y ~ dbin(theta, n) # Model the data…
potpie
  • 91
  • 1
  • 8
0
votes
1 answer

R - JAGS - Runtime Error

I'm trying to run his model code with JAGS: model{ ## priors b0 ~ dnorm(0, 5) b1 ~ dnorm(0, 5) b2 ~ dnorm(0, 5) b3 ~ dnorm(0, 5) b4 ~ dnorm(0, 5) b5 ~ dnorm(0, 5) b6 ~ dnorm(0, 5) sigmayear ~ dt(0, 1, 2) I(0, ) ## likelihood …
Nils L
  • 3
  • 1
0
votes
0 answers

Gamma distribution in JAGS - Error in node

I'm trying to parameterise a gamma distribution in JAGS - with a piecewise linear predictor but my model fails to run with the following error message: Error: Error in node (ashape/(aexp(mu[59]))) Invalid parent values The model works when…
Anand Roopsind
  • 581
  • 2
  • 8
  • 11
0
votes
0 answers

'nothing to compile' error running jags.model function in R (RJAGS)

I am building a hierarchical bayesian model for shots in a football/soccer match. my code is below. dat1 <- read.csv("1314prem.csv") home <- 0.2 # for simplicity fixing home (can be modelled separately) model2.string <-" model { for (i in 1:N){ #…
Ed.T
  • 1
  • 1
0
votes
1 answer

Rjags Invalid parent value error with use of hyper prior

I'm using rjags to calculate a species abundance using an N-mixture model and count data. To capture over dispersion of my data, I used hyperpriors. But I get an "Error in node S[1,1,2] Invalid parent values" My guess is that I have a problem in…
user3767071
  • 99
  • 1
  • 1
  • 9
0
votes
1 answer

How to get the time of sampling in rjags?

I have implemented the LDA model with rjags. And I successfully got the final samples with: jags <- jags.model('../lda_jags.bug', data = data, n.chains = 1, n.adapt = 100) update(jags, 2000) samples <-…
user5779223
  • 1,460
  • 3
  • 21
  • 42
0
votes
1 answer

R, JAGS, r2jags: access last element at the beginning of a `for` loop

I am working on an experiment design problem and trying to fit a JAGS model via R and r2jags. To measure carryover effect, I must access the i-1 element in the list for one of the variables. When i=1, this variable must return the last item in its…
user2205916
  • 3,196
  • 11
  • 54
  • 82
0
votes
2 answers

Can't import R dump() data into JAGS, "unexpected LIST"

I used R dump() to create a data.txt file as specified by the latest JAGS manual, but I keep running into this error: Reading data file data.txt syntax error, unexpected LIST, expecting DOUBLE or NA or ASINTEGER or 'c' The data.txt produced by…
oiiio
  • 179
  • 1
  • 1
  • 8