Activity for JAGS: Just Another Gibbs Sampler

  • H. Brian Underwood H. Brian Underwood posted a comment on discussion Open Discussion

    I have a small simulation where I generate some data with known quantities in R, and submit the data to JAGS in an attempt to recover the generating numbers. I'm only tracking two parameters and the priors seem simple (?). I can run this script a hundred times on a single core and never receive a node error, but when I attempt to run it on multiple cores, it throws node errors more often than not. I've tried a variety of priors with some improvement, but I can't eliminate node errors altogether....

  • Martyn Plummer Martyn Plummer committed [cda5a4] on rjags

    Alow compilation without remapping R API calls

  • Martyn Plummer Martyn Plummer committed [b0490b] on rjags

    Use explicit names of R API calls using Rf_ prefix instead of relying on remapping.

  • Nils Müller-Scheeßel Nils Müller-Scheeßel posted a comment on discussion Help

    Many thanks for your time and effort! I can confirm that the revised model runs without error message. Concerning the Wishart distribution, I was under the impression from the literature that its use is generally disencouraged in favour of the scaled Wishart (e. g. here, p. 925). So, you do not agree with this advice? Thank you also for the heads-up concerning the need of the variance to be fixed to 1. I was not aware of this issue.

  • Basem Motwaly Basem Motwaly posted a comment on discussion Help

    It functions when transitioning directly from juvenile to male or female, but it fails when I include the new transition from less than one year to juvenile.

  • Basem Motwaly Basem Motwaly posted a comment on discussion Help

    It consistently produces the same error, and I've tried everything possible to resolve it without finding a solution.

  • Basem Motwaly Basem Motwaly posted a comment on discussion Help

    he is a sample for my data, Site Year Location Number Sex AgeSex ReproSex LessRepro 1 2002 gurgfa 1 F F F F 1 2002 gurgfa 2 F F F F 1 2002 gurgfa 3 F F F F 1 2002 gurgfa 4 F F F F 1 2002 gurgfa 5 M M M M 1 2002 gurgfa 6 F F F F 1 2002 gurgfa 7 F JF J J 1 2002 gurgfa 8 M M M M 1 2002 gurgfa 9 F F F F 1 2002 gurgfa 11 F F F F 1 2002 gurgfa 12 F JF J J 1 2002 gurgfa 13 M M M M 1 2002 gurgfa 14 F JF J J 1 2002 gurgfa 15 F F F F 1 2002 gurgfa 16 F F F F 1 2003 gurgfa 1 F F F F 1 2003 gurgfa 3 F F F F...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    You don't have a variable called "inf" in your model, so this message means that there is a variable with a fixed value that is being used as an index in your model, but its value is infinite. Check your database to see if there are any infinite values in any of the variables.

  • Basem Motwaly Basem Motwaly modified a comment on discussion Help

    here is my Jags model { #----------------------------------------- ### Indexing: # j = site # t = year ### Parameters: # phi.l: less than one year apparent survival probability # phi.j: juvenile apparent survival probability # phi.f: female apparent survival probability # phi.m: male apparent survival probability # tau.lj: transition probability from less than one year to juvenile # tau.ja: transition probability from juvenile to adult # pFemale: probability that a transitioning adult is female #...

  • Basem Motwaly Basem Motwaly posted a comment on discussion Help

    here is my Jags model { #----------------------------------------- ### Indexing: # j = site # t = year ### Parameters: # phi.l: less than one year apparent survival probability # phi.j: juvenile apparent survival probability # phi.f: female apparent survival probability # phi.m: male apparent survival probability # tau.lj: transition probability from less than one year to juvenile # tau.ja: transition probability from juvenile to adult # pFemale: probability that a transitioning adult is female #...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    I see some problems with your model. There is no advantage here to using the scaled Wishart distribution as the extra flexibility it gives you over the Wishart is already included in the model by the fact that the threshold parameters are free. This means your model is weakly identifiable and it is quite plausible that in a long run it will drift off to infinity causing a numerical error. The second problem is that the variance of the latent quantity ystar should be fixed to 1 in each dimension in...

  • Nils Müller-Scheeßel Nils Müller-Scheeßel posted a comment on discussion Help

    My model includes a set of correlated ordinal response variables that I predict with one numeric variable. For the ordinal variables, I use the dordered.probit distribution. The latent numeric variables are generated by a dmnorm distribution with a dscaled.wishart prior for the precision matrix. A simplified version of my model with a simulated toy data-set can be found below. The model runs fine in general and generate sensible estimates. However, after a long run, JAGS crashes with the message...

  • Ixshel Cox Ixshel Cox modified a comment on discussion Help

    Thank you for your suggestion.

  • Basem Motwaly Basem Motwaly posted a comment on discussion Help

    I am reaching out to seek your expertise with a JAGS model I have developed to estimate the parameters φ (phi) and p for an endangered species. While the initial model works as intended, I am encountering difficulties when attempting to incorporate an additional stage for individuals less than one year old, transitioning to juveniles. Each attempt to modify the model results in errors. Could you kindly assist me in integrating this new stage into my R code? I am willing to share the relevant data,...

  • Basem Motwaly Basem Motwaly posted a comment on discussion Open Discussion

    I am reaching out to seek your expertise with a JAGS model I have developed to estimate the parameters φ (phi) and p for an endangered species. While the initial model works as intended, I am encountering difficulties when attempting to incorporate an additional stage for individuals less than one year old, transitioning to juveniles. Each attempt to modify the model results in errors. Could you kindly assist me in integrating this new stage into my R code? I am willing to share the relevant data,...

  • Basem Motwaly Basem Motwaly posted a comment on discussion Open Discussion

    I am reaching out to seek your expertise with a JAGS model I have developed to estimate the parameters φ (phi) and p for an endangered species. While the initial model works as intended, I am encountering difficulties when attempting to incorporate an additional stage for individuals less than one year old, transitioning to juveniles. Each attempt to modify the model results in errors. Could you kindly assist me in integrating this new stage into my R code? I am willing to share the relevant data,...

  • Beilei He Beilei He posted a comment on discussion Help

    Thank you Martyn, in your jags.model2: jags.model2 <- "model { for (i in 1:length(t)) { is.censored[i] ~ dinterval(t[i], tcens[i]) t[i] ~ dweib(shape, lambda[i]) log(lambda[i]) <- alpha + beta[group[i]] } alpha ~ dnorm(0, 1.0E-6) beta[1] <- 0 beta[2] ~ dnorm(0, 1.0E-6) beta[3] ~ dnorm(0, 1.0E-6) shape ~ dexp(0.01) Intercept <- alpha groupMedium <- beta[2] groupPoor <- beta[3] }" how can we get scale like in jags. Model : scale <- exp(-alpha)? thank you

  • Beilei He Beilei He modified a comment on discussion Help

    Hi I have run rjags and SAS, looks like i have the same results for all parameters except scale in Weibull model. Did i do something wrong in the parameterization? in jags i have scale 22.6919 sas gives the MLE scale 0.2122 df <- HEADACHE n <- length(df[,1]) t <- df$Minutes is.na(t) <- df$Censor==1 is.censored <- df$Censor t.cen <- df$Minutes + 1 - df$Censor df_rjags <- list(n=n, t=t, is.censored=is.censored, t.cen=t.cen, x=df$Group) # treatment 1 or 2 to be usable for beta index tinits1 <- df$Minutes...

  • Beilei He Beilei He posted a comment on discussion Help

    Hi I have run rjags and SAS, looks like i have the same results for all parameters except scale in Weibull model. Did i do something wrong in the parameterization? df <- HEADACHE n <- length(df[,1]) t <- df$Minutes is.na(t) <- df$Censor==1 is.censored <- df$Censor t.cen <- df$Minutes + 1 - df$Censor df_rjags <- list(n=n, t=t, is.censored=is.censored, t.cen=t.cen, x=df$Group) # treatment 1 or 2 to be usable for beta index tinits1 <- df$Minutes + 5 is.na(tinits1) <- df$Censor==0 tinits2 <- tinits1...

  • Sebastian Murray Sebastian Murray modified a comment on discussion Help

    Hello, I built a complex hierarchical model with JAGS (using the R2jags R package) in the context of modelling species occupancy. All my parameters are converging (Rhat < 1.1), but the 'deviance' that is automatically monitored in JAGS is not (Rhat > 5, sometimes up to 29), getting very different values between the 3 chains laucnhed. I don't understand why, and why does it imply. In other less complex models that I fitted before, I never had this problem. Does anyone already had this issue ? Best...

  • Sebastian Murray Sebastian Murray modified a comment on discussion Help

    Hello, I built a complex hierarchical model with JAGS (using the R2jags R package) in the context of modelling species occupancy. All my parameters are converging (Rhat < 1.1), but the 'deviance' that is automatically monitored in JAGS is not (Rhat > 5, sometimes up to 29), getting very different values between the 3 chains laucnhed. I don't understand why, and why does it imply. In other less complex models that I fitted before, I never had this problem. Does anyone already had this issue ? Best...

  • Sebastian Murray Sebastian Murray posted a comment on discussion Help

    Hello, I built a complex hierarchical model with JAGS (using the R2jags R package) in the context of modelling species occupancy. All my parameters are converging (Rhat < 1.1), but the 'deviance' that is automatically monitored in JAGS is not (Rhat > 5, sometimes up to 29). I don't understand why, and why does it imply. In other less complex models that I fitted before, I never had this problem. Does anyone already had this issue ? Best regards, Seb

  • martyn_plummer@sourceforge.net committed [711fd0] on Code

    Allow missing arguments. Add checks for missing arguments.

  • martyn_plummer@sourceforge.net committed [d637ea] on rjags

    Fold in changes to mcarray from rjags-4 plus other bug fixes.

  • martyn_plummer@sourceforge.net committed [d2501e] on rjags

    Fix error messages.

  • Joseph Hediger Joseph Hediger posted a comment on discussion Help

    UPDATE: we solved the issue. We removed our initial values with the exception of the missing weights and decreased our precision on priors.

  • Gianluca Baio Gianluca Baio posted a comment on discussion Help

    Yes, I figured that too! I think I've fixed the R2jags function --- I'll send them a PR on their Github.

  • Ixshel Cox Ixshel Cox modified a comment on discussion Help

    Thank you for your suggestion. However, when I compile the fitting model, there is an error in the dimension of the W vector. > set.seed(123) > fit.caputo<-jags(data=caputo.data, inits = caputo.inits1, parameters.to.save= caputo.params, + n.chains =2, n.iter = 10000, n.burnin=1000,model.file="caputo.jags") Compiling model graph Resolving undeclared variables Deleting model Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    Thanks for looking into this. This is due to a bug in R2jags which means that the burn-in phase is completely skipped. It does not matter what you specify for n.burnin, the samples will be collected from the first iteration. This means that there is an extremely large transient at the beginning of the samples which inflates the apparent variance of the deviance.

  • Gianluca Baio Gianluca Baio posted a comment on discussion Help

    OK, just in case this is interesting for people, I've done a bit more exploration on this... So, the model is something like no_pooling=function(){ for(i in 1:S) { # Sampling distributions r1[i] ~ dbin(pi1[i], n1[i]) r2[i] ~ dbin(pi2[i], n2[i]) logit(pi1[i]) <- alpha[i] logit(pi2[i]) <- alpha[i] + delta[i] # Baselines (NB: sd=4 => precision = 0.0625) alpha[i] ~ dnorm(0,0.0625) # Study-specific treatment effects (sd=2 => precision = 0.25) delta[i] ~ dnorm(0,0.25) } } and the data are from Spiegelhalter...

  • Ixshel Cox Ixshel Cox modified a comment on discussion Help

  • Ixshel Cox Ixshel Cox posted a comment on discussion Help

    Thank you for your suggestion. However, when I compile the fitting model, there is an error in the dimension of the W vector. > set.seed(123) > fit.caputo<-jags(data=caputo.data, inits = caputo.inits1, parameters.to.save= caputo.params, + n.chains =2, n.iter = 10000, n.burnin=1000,model.file="caputo.jags") Compiling model graph Resolving undeclared variables Deleting model Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on...

  • Ixshel Cox Ixshel Cox modified a comment on discussion Help

  • Ixshel Cox Ixshel Cox posted a comment on discussion Help

    Thank you for your suggestion. However, when I compile the fitting model, there is an error in the dimension of the W vector. > set.seed(123) > fit.caputo<-jags(data=caputo.data, inits = caputo.inits1, parameters.to.save= caputo.params, + n.chains =2, n.iter = 10000, n.burnin=1000,model.file="caputo.jags") Compiling model graph Resolving undeclared variables Deleting model Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on...

  • Gianluca Baio Gianluca Baio posted a comment on discussion Help

    Thank you, Martyn --- I had read your 2008 paper and have gone back to it already, so I was aware of the slight but fundamental differences in the way in which the two versions of pD (and hence DIC) are computed. I was curious about the issue with the few very extreme simulations for the deviance --- I can give more details, but ultimately, there's a handful of simulations where some of the main parameters get estimates that are way off the chart, wrt their full posterior. The underlying model is...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    This requires a little background to answer. JAGS and BUGS do slightly different things here. BUGS implements the original definition of pD = Dbar - Dhat, as described by Spiegelhalter et al in the original DIC paper. I did not think this was quite right. In the discussion of that paper I proposed an alternative definition of pD that solved some problems with the original formula. Later I wrote a paper rigorously justifying it. However - and this is the important part - I did not claim I was inventing...

  • Joseph Hediger Joseph Hediger posted a comment on discussion Help

    Hello, I am trying to fit a CJS capture mark recapture model evaluating the interaction between weight and birth site on survival probabilities. The model converges without the interaction but fails to converge with the interaction. Any advice or guidance would be greatly appreciated. I have provided a subset of the data and code below. library(jagsUI) library(tidyverse) ch <- as.matrix(read.csv('./cleaned/caphist.csv', header = T)) weight <- as.matrix(read.csv('./cleaned/weight.csv', header = T))...

  • Gianluca Baio Gianluca Baio posted a comment on discussion Help

    Can I please follow up on this very old thread? I have seen the same behaviour pointed out by Jack, which however doesn't happen when running the model with R2OpenBUGS --- is there an obvious reason why these outliers (massive values in a very small number of simulations for the parameters, which result in massive values for the deviance and thus pV) aren't picked up by BUGS too?

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    You have two nested for loops - one in t and one in k. JAGS will attempt to define the nodes V[t+1] and W[t+1] every time it enters the inner k loop. If the quantities V and W are functions of both t and k then they need to be two-dimensional arrays, e.g. for (t in 1:N1) { for (k in 1:t) { V[t+1, k] <- ... W[t+1, k] <- ... } }

  • Ixshel Cox Ixshel Cox posted a comment on discussion Help

    Hi everyone, I am working on Bayesian estimation with the aim of finding the posterior distribution of a fractional model using the Caputo derivative. However, when I compile the fitting model I get the following error and I have not been able to identify it. ajuste del modelo en JAGS.Caputo (Derivada global) set.seed(123) fit.caputo<-jags(data=caputo.data, inits = caputo.inits1, parameters.to.save= caputo.params, + n.chains =2, n.iter = 10000, n.burnin=1000,model.file="caputo.jags") Compiling model...

  • Katrina D Keith Katrina D Keith modified a comment on discussion Help

    I'm using JAGS 4.3.1. Here are my parameters, and I load the glm module #Model Run Parameters na = 25000 # adaptation nb = 3e+05 # burnin ni = 2500 # samples nc = 2 # chains library(MCMCpack) library(runjags) Sys.setenv(JAGS_HOME = "C:/Program Files/JAGS/JAGS-4.3.1") library(rjags) load.module("glm")

  • Katrina D Keith Katrina D Keith posted a comment on discussion Help

    Answered on StackOverflow, apologies for spamming

  • Katrina D Keith Katrina D Keith posted a comment on discussion Help

    crossposted to stackexchange because I'm desperate for help. https://stackoverflow.com/questions/78524675/jags-just-another-gibbs-sampler-possible-directed-cycle-error-cant-find

  • Katrina D Keith Katrina D Keith posted a comment on discussion Help

    I'm using JAGS 4.3.1. Here are my parameters, and I load the glm module #Model Run Parameters na = 25000 # adaptation nb = 3e+05 # burnin ni = 25000 # samples nc = 2 # chains library(MCMCpack) library(runjags) Sys.setenv(JAGS_HOME = "C:/Program Files/JAGS/JAGS-4.3.1") library(rjags) load.module("glm")

  • Katrina D Keith Katrina D Keith posted a comment on discussion Help

    Yes, thank you! And here is the rest of the code that I use for this model: param<-c("reg","alpha", "beta_elevation","beta_ndwi","beta_ndvi", "beta_high_canopy","beta_male", "beta_migratory","beta_min_rain", "beta_max_rain","beta_min_temp", "beta_adult","beta_max_temp", "beta_bodymass","Ind_elevation", "Ind_adult","Ind_high_canopy", "Ind_male","Ind_migratory","Ind_min_rain", "Ind_bodymass","Ind_max_rain", "Ind_min_temp","Ind_max_temp", "Ind_ndwi","Ind_ndvi","phy", "sigma_reg","sigma_alpha","sigma_phy",...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    Can you supply a data set that would allow someone else to run this model?

  • Katrina D Keith Katrina D Keith posted a comment on discussion Help

    I'm adapting some open source code to look at how environmental and organismal variables effect infection probability. I have been getting an error that states that there is a possible directed cycle involving resid_pred on line 10. Sorry for the long code but I wanted to include everything as perhaps the error is happening somewhere else in the model? ANY help is greatly appreciated. cat(" model { #Sensitivity and specificity spec <- sum(ifelse(equals(pred, infected) && infected == 0, 1, 0)) / sum(equals(infected,...

  • Florent Bled Florent Bled posted a comment on discussion Help

    I know this is an old question, but just in case somebody ends up with the same issue, try to load the DIC module. It appears that when recompiling the model, this is not done "automatically". To redo the example above, you could try the following: recompile(jagsfit) load.module("dic") jagsfit.upd<-update(jagsfit) The loading of the module is normally done when calling jags() or jags.parallel(). It could be a nice addition to ensure that the module is loaded by update() if DIC=T(or more logically...

  • Haley Vermicellion Haley Vermicellion modified a comment on discussion Help

    I have a model that I am trying to add covariates into. The model runs when I don't add "gamma". When I add "gamma", I get the following error: Error in checkForRemoteErrors(val) : 3 nodes produced errors; first error: Error in node -1.8306 Index expression evaluates to non-integer value I have tried to make all of the parts of the data list into numeric, I still have the same error. I am not sure how else to resolve this and I don't understand how a node could be negative. The augtemp data are normally...

  • Haley Vermicellion Haley Vermicellion posted a comment on discussion Help

    I have a model that I am trying to add covariates into. The model runs when I don't add "gamma". When I add "gamma", I get the following error: Error in checkForRemoteErrors(val) : 3 nodes produced errors; first error: Error in node -1.8306 Index expression evaluates to non-integer value I have tried to make all of the parts of the data list into numeric, I still have the same error. I am not sure how else to resolve this and I don't understand how a node could be negative. The augtemp data are normally...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    I don't think you do have the latest version of R. If R is installing into C:/Users/valer/OneDrive/Documents/R/win-library/4.1 then this suggests that you have R version 4.1.x. The latest release of R is 4.4.0. CRAN keeps binary packages for older releases, but does not update them. Checking on CRAN, I see that the latest available binary package for R 4.1 on Windows is 4-13, whereas R 4.2 and later does have the latest rjags release. The solution here is to update your R installation.

  • Valeria Perez Valeria Perez posted a comment on discussion Help

    Hello, I have downloaded the latest version of JAGS and have the latest version of R, but when trying to install rjags and R2jags it gives me the following error: install.packages("rjags") Installing package into ‘C:/Users/valer/OneDrive/Documents/R/win-library/4.1’ (as ‘lib’ is unspecified) There is a binary version available but the source version is later: binary source needs_compilation rjags 4-13 4-15 TRUE installing the source package ‘rjags’ trying URL 'https://cran.rstudio.com/src/contrib/rjags_4-15.tar.gz'...

  • J. Aaron Hogan J. Aaron Hogan modified a comment on discussion Help

    Just to update this post with the solution that I have worked out: In order to get a random effect a level not specified in the model, the trick is to 1) give the model a separate intercept by at the matrix level -- the finest level of specification -- for the likelihood. In this case it is as matrix of n species by j individuals. And then 2) elsewhere in the model specification link those intercepts to normally-distributed priors at the level of interest (in this case plots). here is modified code...

  • J. Aaron Hogan J. Aaron Hogan modified a comment on discussion Help

    Just to update this post with the solution that I have worked out: In order to get a random effect a level not specified in the model, the trick is to 1) give the model a separate intercept by at the matrix level -- the finest level of specification -- for the likelihood. In this case it is as matrix of n species by j individuals. And then 2) elsewhere in the model specification link those intercepts to normally-distributed priors at the level of interest (in this case plots). here is modified code...

  • J. Aaron Hogan J. Aaron Hogan posted a comment on discussion Help

    Just to update this post with the solution that I have worked out: In order to get a random effect a level not specified in the model, the trick is to 1) give the model a separate intercept by at the matrix level -- the finest level of specification -- for the likelihood. In this case it is as matrix of n species by j individuals. And then 2) elsewhere in the model specification link those intercepts to normally-distributed priors at the level of interest (in this case plots). here is modified code...

  • J. Aaron Hogan J. Aaron Hogan posted a comment on discussion Help

    Dear JAGS community, I am interested in adding a random group-level effect (for plot) to the following model. The model is a model of tree growth with a gamma likelihood, where shape and rate are re-parameterized to a mean and sd. The mean growth (mu) is modeled using a log-linear model with 11 predictors. I would like to add normally distributed random error terms for plot groups. Currently the data are fed to JAGS are in matrix form -- a ragged right edge matrix of species (in rows, s) by individuals...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    The issue seems to be that you need to set the initial values for some of the parameters explicitly. In my modified version of your example below, I have explicitly set the parameters shape, scale, and treat and this seems to work. library(rjags) seedNum <- 160424 tlast <- 1 # Censoring time ## Data-generating parameter values shape0 <- 0.5 scale0 <- 4 treat0 <- 0.5 numObs <- 125 # per arm dat <- data.frame((matrix(NA, nrow = numObs*2, ncol = 3))) colnames(dat) <- c("time", "delta", "trt") ## Generate...

  • martyn_plummer@sourceforge.net committed [51636e] on Code

    Fix for Fedora 40.

  • Anonymous created ticket #17

    4.3.2 for Windows?

  • Arlene Jiang Arlene Jiang modified a comment on discussion Help

    Hi Martyn, Your code and explanations above has been incredibly helpful for building Weibull AFT models in JAGS. I'm hoping to run simulations based on this model. I've attached my model of interest below (it's a simpler case - I'm interested in whether people are treated or not - 'treat'). After hundreds of repeated runs, I've been running into "Error in node alpha - Current value is inconsistent with data". What am I missing here? Thanks! model { for (i in 1:length(t)) { is.censored[i] ~ dinterval(t[i],...

  • Arlene Jiang Arlene Jiang modified a comment on discussion Help

    Hi Martyn, Your code and explanations above has been incredibly helpful for building Weibull AFT models in JAGS. I'm hoping to run simulations based on this model. I've attached my model of interest below (it's a simpler case - I'm interested in whether people are treated or not - 'treat'). After hundreds of repeated runs, I've been running into "Error in node alpha - Current value is inconsistent with data". What am I missing here? Thanks! model { for (i in 1:length(t)) { is.censored[i] ~ dinterval(t[i],...

  • Arlene Jiang Arlene Jiang posted a comment on discussion Help

    Hi Martyn, Your code and explanations above has been incredibly helpful for building Weibull AFT models in JAGS. I'm hoping to run simulations based on this model. I've attached my model of interest below (it's a simpler case - I'm interested in whether people are treated or not - 'treat'). After hundreds of repeated runs, I've been running into "Error in node alpha - Current value is inconsistent with data". What am I missing here? Thanks! model { for (i in 1:length(t)) { is.censored[i] ~ dinterval(t[i],...

  • Yu-Sung Su Yu-Sung Su posted a comment on discussion Help

    Thank you for bringing this to our attention, and a special thanks to Martyn for facilitating the coordination. A new version with a patch addressing this issue is now available. However, during my learning process with the BUGS language, I was advised against having missing categories in the aggregate-level variables. While the issue is indeed frustrating, I proceeded with the patch regardless. If there are any similar cases where this patch doesn't resolve the issue, please report them here or...

  • Christopher Jennelle Christopher Jennelle modified a comment on discussion Help

    Hello all, I am running a Poisson GLMM in JAGS, which works well. I am modeling the counts of birds in 40 sites (panel design with about 10 sites visited per year) over 15 years, and the sites are distributed among 5 zones with biological relevance (8 sites per zone). My objective is to estimate the site-specific trend in relative abundance as % change/year at the site level, and at the zone level. The model below works well to estimate site-level trends, however, I would like to estimate zone-level...

  • Christopher Jennelle Christopher Jennelle posted a comment on discussion Help

    Hello all, I am running a Poisson GLMM in JAGS, which works well. I am modeling the counts of birds in 40 sites (panel design with about 10 sites visited per year) over 15 years, and the sites are distributed among 5 zones with biological relevance (8 sites per zone). My objective is to estimate the site-specific trend in relative abundance as % change/year at the site level, and at the zone level. The model below works well to estimate site-level trends, however, I would like to estimate zone-level...

  • martyn_plummer@sourceforge.net committed [60ecb9] on rjags

    Skip linkage tests when cross compiling (devel version). Thanks to Jeroen Ooms

  • martyn_plummer@sourceforge.net committed [da2b2b] on rjags

    Skip linkage tests when cross compiling. Thanks to Jeroen Ooms.

  • martyn_plummer@sourceforge.net committed [c83914] on rjags

    Fix bug in detection of all-missing data entries

  • martyn_plummer@sourceforge.net committed [0fa6a2] on Code

    Update parsing of R dump data.

  • martyn_plummer@sourceforge.net committed [0ef2cc] on Code

    Node::initialize defunct.

  • martyn_plummer@sourceforge.net committed [d53f83] on Code

    Catch non-integer initial values before they cause trouble in glm::LGMix.

  • martyn_plummer@sourceforge.net committed [e109e2] on Code

    Allow jags to read dumped R output with compact reverse integer sequences.

  • Stacey Cherny Stacey Cherny posted a comment on discussion Help

    Thanks for the fix! That is very bizarre! The problem has been happening on the last few datasets I've worked with, but I have data where I don't see the problem. Very mysterious, but your solution was a great motivation to switch to rjags, which I also got to work thanks to your advice.

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    It appears that JAGS is not reading in the data correctly from the file post_params.R. By switching on some diagnostic messages, I can see what JAGS does when it reads in the data: Reading data file post_params.R Reading AGE.p[500] Reading ECW.p[2000] Reading GDF15_LnLn.p[2000] Reading LA_ratio_Ln.p[1000] Reading LYMPabs.p[500] Reading SIRI.p[500] Reading D2TM.p[2000] Reading HLD.p[2000] Reading HTM.p[2000] Reading CVD.p[3000] Reading prec.AGE.p[500] Reading prec.ECW.p[500] Reading prec.GDF15_LnLn.p[500]...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    This looks like a bug in the R2jags package. Here are the equivalent steps using rjags. > m <- jags.model("model.bug", data=d, n.chain=3) Compiling model graph Resolving undeclared variables Allocating nodes Graph information: Fully observed stochastic nodes: 72 Unobserved stochastic nodes: 11 Total graph size: 454 Initializing model |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% > update(m, 1000) |**************************************************| 100% > s <- jags.samples(m, variable.names=c("b",...

  • Liting Zheng Liting Zheng posted a comment on discussion Help

    I have the same confusion. Did you resolve your problem?

  • Stacey Cherny Stacey Cherny posted a comment on discussion Help

    It seems no matter what model I'm trying to build I get the following error on the last line: model <- jags.model(textConnection(AllLines), data = list(), n.chains = num_cores) Compiling model graph Resolving undeclared variables Allocating nodes Deleting model Error in jags.model(textConnection(AllLines), data = list(), n.chains = num_cores) : RUNTIME ERROR: Compilation error on line 143. Unknown variable CVD.p Either supply values for this variable with the data or define it on the left hand side...

  • Martyn Plummer Martyn Plummer modified ticket #57

    Invalid shape in LGMix::updateShape

  • Martyn Plummer Martyn Plummer posted a comment on ticket #57

    I have discovered through an independent bug report that this error is caused by using non-integer values as initial values for a node with a Poisson distribution, which is then used as an outcome variable in a Poisson GLM. I have added additional checks to ensure that the user gets an informative message when initializing discrete-valued variables with non-integer values. Closing this now.

  • Alejandro De La Fuente Alejandro De La Fuente posted a comment on discussion Help

    Hi, I need some help calculating the 90th percentile of a 3D vector within a JAGS model. This needs to be done to integrate 2 models, so that the output of the first model is used as a predictor in the second model. I am providing an example below of how could it be done using the mean, but I am interested in calculating the 90th percetile across one of the vector's dimension instead. Has anyone run into a similar situation before or know how to do this? I have been searching through the manual,...

  • Allen Allen modified a comment on discussion Open Discussion

    Hi everyone, First off thank you to Martyn for the rjags package and for creating this forum. I have the following code library(rjags) customer_level_data <- read.table("Data1.txt", header=TRUE) visit_level_data <- read.table("Data2.txt", header=TRUE) R <- diag(c(0.1,0.1,0.1,0.1,0.1)) jags_data <- list(I=nrow(customer_level_data), NoVisits=customer_level_data$NoVisits.., Start=customer_level_data$Start.., HDay=visit_level_data$HDay.., MKT=visit_level_data$MKT.., LMKT=visit_level_data$LMKT.., IntTimeBeforeMKT=visit_level_data$IntTimeBeforeMKT..,...

  • Allen Allen posted a comment on discussion Open Discussion

    Here is the bugscode

  • Allen Allen posted a comment on discussion Open Discussion

    Hi everyone, First off thank you to Martyn for the rjags package and for creating this forum. I have the following code library(rjags) customer_level_data <- read.table("Data1.txt", header=TRUE) visit_level_data <- read.table("Data2.txt", header=TRUE) R <- diag(c(0.1,0.1,0.1,0.1,0.1)) jags_data <- list(I=nrow(customer_level_data), NoVisits=customer_level_data$NoVisits.., Start=customer_level_data$Start.., HDay=visit_level_data$HDay.., MKT=visit_level_data$MKT.., LMKT=visit_level_data$LMKT.., IntTimeBeforeMKT=visit_level_data$IntTimeBeforeMKT..,...

  • Larry Dong Larry Dong posted a comment on discussion Open Discussion

    Hi Martyn, Sorry to the long delays in reply, the holidays came around, fell a little sick and forgot about this. Just wanted to say thanks for the prompt reply, it was helpful. I had a quick look into that a while ago. Happy belated new year! Larry

  • Pål Kristian Berntzen Bjartan Pål Kristian Berntzen Bjartan posted a comment on discussion Help

    I am trying to fit a BUGS model in rjags. However I get the following warning and error message: Error in model$jags <- rjags::jags.model(path$bugs, data, inits, n.chains = chains, : cannot add bindings to a locked environment I am trying to understand what may be causing the error. Full output Compiling model graph Resolving undeclared variables Allocating nodes Graph information: Observed stochastic nodes: 10898 Unobserved stochastic nodes: 1953 Total graph size: 34848 Initializing model Warning...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    Yes, the dinterval distribution is flexible enough to include these different constraints. For example, if you have a 2-dimensional multivariate normal that is unobserved: Z[1:2] ~ dmnorm(mu[1:2], Tau[1:2,1:2]) and both mu and Tau are fixed quantities. Then you can censor Z[1] as positive and Z[2] as negative with: ~~~ for (i in 1:2) { S[i] ~ dinterval(Z[i], 0) } ~~~ where S is supplied as data: ~~~ S <- c(1, 0) ~~~ You will also need to supply starting values for Z such that Z[1] starts with a positive...

  • mauricio mauricio posted a comment on discussion Help

    Two question regarding this solution. 1) Would this work if I want to encode the information that every element of the array is negative? 2) Would this work if I want to encode the information that some elements of the array are positive and some are negative?

  • J. Aaron Hogan J. Aaron Hogan modified a comment on discussion Help

    Dear Jags community & Martyn, Thanks for previous help and thanks again in advance for any additional help you can provide here. I am encountering a new error in relation to this model. It turns out that because the likelihood is Bernoulli, the previous attempt at calculating the Bayesian p-value was incorrect. I have tried to implement a new method for that calcuation ad have run into a new error: RUNTIME ERROR: Compilation error on line 44. Possible directed cycle involving y.hat.dev like 44 is...

  • J. Aaron Hogan J. Aaron Hogan posted a comment on discussion Help

    Dear Jags community & Martyn, Thanks for previous help and thanks again in advance for any additional help you can provide here. I am encountering a new error in relation to this model. It turns out that because the likelihood is Bernoulli, the previous attempt at calculating the Bayesian p-value was incorrect. I have tried to implement a new method for that calcuation ad have run into a new error: RUNTIME ERROR: Compilation error on line 44. Possible directed cycle involving y.hat.dev like 44 is...

  • J. Aaron Hogan J. Aaron Hogan posted a comment on discussion Help

    This turned out to be a memory issue. The workers were running out of momory. The 'negative vector' error seems to be a generic R error when computations reach memory limits. https://stackoverflow.com/questions/77641108/jags-error-negative-length-vectors-are-not-allowed

  • Zhenke Wu Zhenke Wu modified a comment on discussion Help

    @mdenwood Thanks so much for the blog - I missed it. My model code is generated by wrapper functions automatically, and indeed there are a lot of deterministic relations. However, I stick to the order as described in the post, though perhaps with some exceptions (but I think it is rare). Perhaps this is easier to reproduce: devtools::install_github("zhenkewu/baker") example(baker::nplcm) If you run this code under 4.3.2 vs 4.2.0, the speed difference is noticeable. I agree I was vague - sorry about...

  • Zhenke Wu Zhenke Wu posted a comment on discussion Help

    @mdenwood Thanks so much for the blog - I missed it. My model code is generated by wrapper functions automatically, and indeed there are a lot of deterministic relations. However, I stick to the order as described in the post, though perhaps with some exceptions (but I think it is rare). Perhaps this is easier to reproduce: devtools::install_github("zhenkewu/baker") example(baker::nplcm) If you run this code under 4.3.2 vs 4.2.0, the speed difference is noticeable. I agree I was vague - sorry about...

  • Martyn Plummer Martyn Plummer posted a comment on discussion Help

    Sorry I thought you were talking about 4.3.1 vs 4.3.2. There were much bigger changes between 4.2.x and 4.3.x. Among these, I did accidentally introduce some memory management issues which would affect models with a large number of mixture nodes, i.e. nodes defined by a random subset of a node array such as Y[i] in the code snippet below. Y[i] ~ X[Z[i]] Z[i] ~ dcat(p[]) I have addressed these issues in the development version.

  • J. Aaron Hogan J. Aaron Hogan posted a comment on discussion Help

    Indeed, that was the case. Thanks for your keen eye, Martyn. Take care & happy holidays here is a complete solution to the issue for reference: ###### ---------------------------- ###### ## Posterior predictive simulations --- Bayesian p.vals ## predicted y-hat values y.pred[s,j,t] ~ dbern(phi[s,j,t]) bp.data[s,j,t] = ifelse(y.pred[s,j,t] < y[s,j,t], 1, 0) ## if y is less than y.pred return 1, else zero ###### ---------------------------- ###### } # end j loop ## Bayesian p.val matrix by species...

  • Matt Denwood Matt Denwood posted a comment on discussion Help

    A small change in compilation speed between JAGS 4.2.0 and 4.3.2 could be expected due to the changes to the way in which JAGS reads the model definition, as described at https://martynplummer.wordpress.com/2016/09/14/you-can-always-make-it-faster/#more-822 However, you say "much faster", which implies a more dramatic difference. Can you provide a minimal reproducible example of a model that compiles much more quickly using JAGS 4.2.0 (preferably also including details of the timings under both versions,...

  • Michael Jacky Michael Jacky posted a comment on discussion Help

    Thank you for the prompt response!

  • Michael Jacky Michael Jacky posted a comment on discussion Help

    Thank you for the prompt response!

1 >