Activity for Martyn Plummerhttps://sourceforge.net/u/userid-1549763/activity/Recent activity for Martyn PlummerenThu, 16 Nov 2017 16:57:59 -0000Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/092185b8/?limit=25#4a41It x observed? If it is then you can just recode it so it goes from 1 to 5 instead of 0 to 4. You can even do this inside JAGS with a data block, e.g. (removing the for loops for simplicity) data { y <- x - 1 } model { y ~ dnorm(theta, 4) } If x is not observed then just create a deterministic node by adding 1 to the binomial node model { y ~ dnorm(theta, 4) x <- y + 1 }Martyn PlummerThu, 16 Nov 2017 16:57:59 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/092185b8/?limit=25#4a41Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/d1c54c48/?limit=25#e14bYou might ask the maintainer of the package, but my first impression is yes. This is how it works in the rjags package and it looks like the dclone package works in the same way with added parallelism. To save memory when you have high autocorrelation, you should increase the thinning interval. If you really want to remove memory in an R session then you should run gc() to force garbage collection.Martyn PlummerThu, 16 Nov 2017 16:48:39 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/d1c54c48/?limit=25#e14bMartyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31/9468/fe4fA reproducible example means: The model description in the BUGS language Sufficient data to compile the model A script that can be run to reproduce the output you give. From the limited information that you have shared, I can tell you this much. The vector pD contains an element for each observed stochastic node. So in your model x and y are vectors of observed stochastic nodes, i.e. you supplied x and y as data and, in the model description, you defined x[1] ... x[423] and y[1] ... y[423] as stochastic...Martyn PlummerThu, 16 Nov 2017 15:31:49 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31/9468/fe4fMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31/9468/fe4f/b011/017fI think you need to rethink your model. The evidence from pD suggests that it is over-fitting (1 effective parameter per observation).Martyn PlummerThu, 16 Nov 2017 15:03:28 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31/9468/fe4f/b011/017fMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31/9468/fe4fA reproducible example means: The model description in the BUGS language Sufficient data to compile the model * A script that can be run to reproduce the output you give. From the limited information that you have shared, I can tell you this much. The vector pD contains an element for each observed stochastic node. So in your model x and y are vectors of observed stochastic nodes, i.e. you supplied x and y as data and, in the model description, you defined x[1] ... x[423] and y[1] ... y[423] as stochastic...Martyn PlummerThu, 16 Nov 2017 14:33:51 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31/9468/fe4fMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/1ab6e7f1/?limit=25#114eYou don't need the leading dollar sign in your path. If I do export JAGS_HOME=$/home/martyn/temp then I get the same error, but with export JAGS_HOME=/home/martyn/temp it works.Martyn PlummerSat, 11 Nov 2017 08:30:43 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/1ab6e7f1/?limit=25#114eMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31I'm not sure what the problem is here. Can you give us a reproducible example?Martyn PlummerFri, 10 Nov 2017 16:30:03 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#3795/5b31Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#ad2f/7d89OK. My mistake. If you are using the R2jags::jags function and you have two chains then you need to double up your list of initial values, so you have one per chain, e..g myinits <- list(k = matrix(0.001, nrow=ns, ncol=2), temp = matrix(10, nrow=ns, ncol=2)) myinits <- list(myinits, myinits) The safest thing to do is to write a functon that returns the initial values myinits <- function() { list(k = matrix(0.001, nrow=ns, ncol=2), temp = matrix(10, nrow=ns, ncol=2)) } This will work for as many chains...Martyn PlummerTue, 07 Nov 2017 10:42:20 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#ad2f/7d89Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#1c39/afe0You need to show me your code. The error message is not enough for me to diagnose the problem.Martyn PlummerMon, 06 Nov 2017 16:27:38 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#1c39/afe0Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#681dYour initial values should look like this: myinits <- list(k = matrix(0.001, nrow=ns, ncol=2), temp = matrix(10, nrow=ns, ncol=2)) In your model, k is a matrix with ns rows and 2 columns so the initial values must match this. The same is true for temp. Your initial values look a bit strange to me: myinits <- list( list(k = (c(0.001,0.001))), list(temp = (c(10,10)))) This will set initial values for k but not temp in chain 1 and for temp but not k in chain 2. This might be what you want but I am pointing...Martyn PlummerMon, 06 Nov 2017 12:01:06 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#681dMartyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#31e1Hello Everyone, i wanna run a hierarchical model on data from a temporal discounting paradigm in R. Before the sampling starts i get the Error Message: "Error in setParameters(init.values[[i]], i) : RUNTIME ERROR: Dimension mismatch in values supplied for k" Thank you very much for help. This is my model file: model { #single subject params from group distribution for (s in 1:ns) { temp[s,1] ~ dnorm(temp_mu[1],temp_lambda[1])T(0,) temp[s,2] ~ dnorm(temp_mu[2],temp_lambda[2])T(0,) k[s,1] ~ dnorm(k_mu[1],k_lambda[1])T(0,)...Martyn PlummerMon, 06 Nov 2017 11:53:18 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a1d46d2b/?limit=25#31e1Martyn Plummer committed [a16335]https://sourceforge.net/p/mcmc-jags/code-0/ci/a1633555ccc8eb214804d85e160e73d02a8b975c/Manual updatesMartyn PlummerTue, 24 Oct 2017 13:22:51 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/a1633555ccc8eb214804d85e160e73d02a8b975c/Martyn Plummer committed [897185]https://sourceforge.net/p/mcmc-jags/code-0/ci/8971853430b4ac628a1c4c5dd25ba56c22e982a1/Clarify error messageMartyn PlummerTue, 24 Oct 2017 13:22:51 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/8971853430b4ac628a1c4c5dd25ba56c22e982a1/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/be5795c6/?limit=25#120cThere is a log density function associated with each distribution in JAGS. You can use logDensity.multi for the multinomial distribution. See section 6.3 of the user manual "Functions associated with distributions" The d-p-q functions that provide density, probability and quantile functions are only available for a limited set of univariate distributions in the the bugs module. These are listed in table 6.2 in the manual.Martyn PlummerMon, 23 Oct 2017 08:52:17 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/be5795c6/?limit=25#120cMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/f0d09eb8/?limit=25#8ba1You cannot set initial values for the array beta because all of its elements are deterministic nodes, i.e. defined by a left arrow <- . You can only set initial values for stochastic nodes defined by ~. You can set initial values for the non-fixed elements of beta.uF and beta.uM. You can do this by using NA for all the values in the first column, e.g. beta.init <- cbind(rep(NA, 20), matrix(0.5, 20, 2)) inits1 <- list('betauF'= beta.init, 'beta.uM'=beta.init)Martyn PlummerFri, 20 Oct 2017 08:39:22 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/f0d09eb8/?limit=25#8ba1Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/05932139/?limit=25#e370You need to truncate the prior distributions of beta[1,k,1] and beta[1,k,2] to be less than 0.95, e..g beta[1,k,1] ~ dbeta(pbetaF[1], pbetaF[2]) T(,0.95) or equivalently since pbetaF=c(1,1), beta[1,k,1] ~ dunif(0, 0.95)Martyn PlummerFri, 20 Oct 2017 08:30:32 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/05932139/?limit=25#e370Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/f5309081/?limit=25#7d94Load the glm module to get access to better samplers for generalized linear models. load.module("glm")Martyn PlummerThu, 19 Oct 2017 09:25:20 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/f5309081/?limit=25#7d94Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/251cd357/?limit=25#09f5I'm not sure that is a reliable solution. The key issue here is that in your BUGS model, true.abundance[i] is unobserved. But there is a logical constraint that trua.abundance[i] must be at least as big as observed.abundance[i] otherwise this line generates a density of zero. observed.abundance[i]~dbin(p[i],true.abundance[i]) If you don't supply initial values for true.abundance then it will be generated from the prior and is not guaranteed to satisfy the logical constraint. This is how I added valid...Martyn PlummerThu, 19 Oct 2017 09:06:26 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/251cd357/?limit=25#09f5Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/1a251e83/?limit=25#6523I can't say that directed cycles are always bad but they are mostly bad and here is why. A good model written in the BUGS language should describe a plausible mechanism for generating the data. This means that it should be able to generate new outcome variables (and hopefully ones that looks like your observed data). If you have a directed cycle in your model then it cannot generate a new data set. Your trick of duplicating Y technically removes the directed cycle, but if you generated a new Y from...Martyn PlummerThu, 19 Oct 2017 08:47:56 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/1a251e83/?limit=25#6523Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/ec134030/?limit=25#bb7aHowever, since the mixture specification is made on the mean mu, and not on y, the likelihood plays no direct role in the full conditional distribution of the allocations G[i]: No that's not true. You can transcribe the BUGS language description of the model into a DAG by joining any node on the right hand side of a relation to the node on the left hand side. This gives the DAG in the attached file dag1.png. The node mu[i] is a deterministic function of its parents, represented by double arrows and...Martyn PlummerThu, 19 Oct 2017 08:11:09 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/ec134030/?limit=25#bb7aMartyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/ec134030/?limit=25#b2d0No it is not a degenerate distribution. If y[i] < 10 then the likelihood of y[i]is higher for 0 <= mu[i] <= 10 than for 11 <= mu[i] <= 20, but the latter does not have zero likelihood. Your model allows values of sigmay up to 10 which is pretty big. Consider the log likelihood of your smallest y value, y[18] = 2.24907 for mu[18] = 11 and sigmay = 10: > dnorm(min(y), mean=11, sd=10, log=TRUE) [1] -3.604421 Likewise the log likelihood of the largest value y[22] = 16.11238 for mu[22] = 10 and sigmay...Martyn PlummerWed, 18 Oct 2017 15:26:48 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/ec134030/?limit=25#b2d0Martyn Plummer modified a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/1a251e83/?limit=25#0220Hi, As you can imagine when reading the title of this topic, I am not totally confident with maths and algorithms. I have found a solution to a problem, but would like some reviews on it. I would need to estimate a threshold, which allow the distinction between two groups of measures. I do not want to use classical cluster analyses, because, I would like to separate my populations only when it is relevant (i.e. when the data are better predicted by an intercept and a sub-population effect than by...Martyn PlummerWed, 18 Oct 2017 08:43:28 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/1a251e83/?limit=25#0220Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/264f81ca/?limit=25#d0f4You say there isn't a lib64 directory, so there should be one called "lib". A quick and dirty workaround is to set LIBnn variable: Sys.setenv("LIBnn"="lib") However, since you have pkg-config available your best bet is to use it. There should be a jags.pc file in the JAGS installation tree, e.g. for a default installation [martyn@linux ~]$ find /usr/local/ -name jags.pc /usr/local/lib/pkgconfig/jags.pc So you would then set the environment variable PKG_CONFIG_PATH to the directory containing that...Martyn PlummerTue, 17 Oct 2017 05:30:15 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/264f81ca/?limit=25#d0f4Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9db05875/?limit=25#1823/89a6If you are using jags.parallel from the R2jags package then you need to add any modules you want to load to the argumen jags.module. The parallel R processes that are launched by the jags.parallel function will not include any modules that you have loaded in your primary R session.Martyn PlummerThu, 12 Oct 2017 09:53:42 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9db05875/?limit=25#1823/89a6Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9db05875/?limit=25#572f/f516Works for me library(rjags) Loading required package: coda Linked to JAGS 4.3.0 Loaded modules: basemod,bugs > load.module("mix") module mix loaded > mod <- "model { y ~ dbetabin(0.5, 0.5, 3) }" > m <- jags.model(textConnection(mod)) Compiling model graph Resolving undeclared variables Allocating nodes Graph information: Observed stochastic nodes: 0 Unobserved stochastic nodes: 1 Total graph size: 3 Initializing model > coda.samples(m, "y", n.iter=10) [[1]] Markov Chain Monte Carlo (MCMC) output:...Martyn PlummerWed, 11 Oct 2017 17:07:05 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9db05875/?limit=25#572f/f516Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/8e8bb433/?limit=25#7332/ff2bI don't think that is the same problem. The "invalid parent values" error comes at initialization and is usually a sign that you need better initial values. It is possible that your initial values (or the ones automatically generated by JAGS) work for your data but do not work for your posterior predictive simulations, especially if you are extrapolating your predictions beyond the range of your data.Martyn PlummerTue, 26 Sep 2017 12:46:06 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/8e8bb433/?limit=25#7332/ff2bMartyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/8e8bb433/?limit=25#91f0Hello All, I'm having trouble running a model using package jagsUI today that seemingly had no problems running yesterday. Everything seems to load correctly and I get the message "Beginning parallel processing using 2 cores. Console output will be suppressed." After about 30 second though I get the error: "Error in checkForRemoteErrors(val) : 2 nodes produced errors; first error: Error in node Beta_time Current value is inconsistent with data" After messing around for a couple of hours I'm still...Martyn PlummerTue, 26 Sep 2017 09:20:23 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/8e8bb433/?limit=25#91f0Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9db05875/?limit=25#aea3You need to load the "mix" module to access this distributionMartyn PlummerWed, 20 Sep 2017 05:03:52 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9db05875/?limit=25#aea3Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/e791f3b9/?limit=25#4f95I have a couple of comments about your code. Firstly ,this model does not compile. It should give you error messages that various elements of cov.mat are undefined. To compile the model you need this: omega[i,k,1:fups[i], 1:fups[i]] <- inverse(cov.mat[i,k,1:fups[i],1:fups[i]]) Secondly, you have to be careful with the constant correlation model. If the variance matrix is M by M then you cannot have the correlation less than -1/M (because the matrix would not be positive definite). Given the variable...Martyn PlummerThu, 14 Sep 2017 12:29:50 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/e791f3b9/?limit=25#4f95Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9e1df7f5/?limit=25#ef29I think I see the problem here. eta[j,t] <- a1 + a2*ROO[t] + a3*NEC[t] + a4*TEM[t] + a5*ATEM[t] + a6*FOR[j,t] + a7*RES[j] The variables a1, a2, ... a7 are all initialized to 0 so that eta[j,t] is also 0. Then when you transform it via the inverse link function: mu[j,t] <- pow(eta[j,t], -1) You get an infinite value for mu[j,t]. Initializing a1 to a suitable positive value should get work. When using the inverse link function you should ensure that the linear predictor ( eta[j,t]) is positive. You...Martyn PlummerThu, 14 Sep 2017 08:19:17 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/9e1df7f5/?limit=25#ef29Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/5c9e9026/?limit=25#f375/c0aaJAGS 4.3.0 has substantially improved heuristics for finding a joint linear model. But they are still just heuristics so they might not work for you. Try it and see. The key thing is to check that you are you are getting block updating by using the list.samplers() function in R.Martyn PlummerMon, 11 Sep 2017 12:48:38 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/5c9e9026/?limit=25#f375/c0aaMartyn Plummer modified a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#d455/eb8dOK that makes sense. If all values of z_temp_1[s,1:3] are initialized to the same value then all values of z[s,1:3] are equal to zero and hence p[s,i] is zero. A value of DV[s, i] equal to 1 then generates a likelihood of zero. JAGS 5.0.0 will draw initial values from the prior so this will not happen.Martyn PlummerMon, 11 Sep 2017 11:19:40 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#d455/eb8dMartyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#6872I have rewritten your model using nested indexing, which is the best way to handle this. The model choice indicator z[s] is a scalar and then pDV[z[s]] picks the right probability parameter. model { for (s in 1:subjects) { for (i in 1:stimuli) { DV[s, i] ~ dbern(pDV[z[s]]) } z[s] ~ dcat(pz) } pz <-c(1/3,1/3,1/3) pDV <- c(0.2, 0.5, 0.8) } I took out the Dirichlet layer which is redundant.Martyn PlummerMon, 11 Sep 2017 10:31:53 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#6872Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#d455/eb8dOK that makes sense. If all values of z_temp_1[s,1:3] are initialized to the same value then all values of z[s,1:3] are equal to zero and hence p[s,i] is zero. A value of DV[s, i] then generates a likelihood of zero. JAGS 5.0.0 will draw initial values from the prior so this will not happen.Martyn PlummerMon, 11 Sep 2017 10:27:50 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#d455/eb8dMartyn Plummer modified a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#be2cHi everybody, I am just beginning with jags (and bayesian modeling) and I hope finding some help with the following problem: Suppose I have 3 (cognitive) models predicting probabilities of a binary outcome variable DV (0,1). The DV comes from an experiment, where human subjects made binary choices to several stimuli. Now I want to 'classify' each subject into one of the three cognitive models, that indicate which of these processes is most likely. Let's call the Models: M1, M2, and M3. For simplicity,...Martyn PlummerFri, 08 Sep 2017 16:48:18 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/dbaae6f8/?limit=25#be2cMartyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/640a2968/?limit=25#00b7According to your model, the 3 dimensions of z correspond to dimensions 1, 2, 3 of y y[s,i,f,j] ~ dbern(z[s,i,f]*p) # Observation model whereas when you create your initial value array, you are leaving dimensions 1,2, 4 zst <- apply(y, c(1,2, 4), max) # Avoid data/model/inits #conflict Admittedly the error message could be more clear. In version. 5.0.0 I am trying to modify the error messages so that they give what was observed and what was expected.Martyn PlummerTue, 05 Sep 2017 16:14:27 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/640a2968/?limit=25#00b7Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ba83a135/?limit=25#2ae4The issue here is that your covariate x[i] takes values up to 400. When this is multiplied by the starting value of beta_p=0.1 in the linear predictor: logit(p[i,t]) <- mu_p + beta_p*x[t] + eps_p[i] this gives a value of 40. When transformed by the inverse link function this gives p[i,t]=1 numerically. It is then impossible to observe y[i,t]=0 which is why JAGS complains. I got your example to work with starting value beta_p = 0. This is a case where centering and scaling the covariate x might help...Martyn PlummerFri, 01 Sep 2017 16:44:08 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ba83a135/?limit=25#2ae4Martyn Plummer committed [cdc73a]https://sourceforge.net/p/mcmc-jags/code-0/ci/cdc73a106323b3d470cc20492acb3221e5df92be/Fix logic_error arising from out-of-range index in a mixture node.Martyn PlummerThu, 31 Aug 2017 15:35:15 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/cdc73a106323b3d470cc20492acb3221e5df92be/Martyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b7cd1e27/?limit=25#b4daERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?This is also posted on cross validated [here](https://stats.stackexchange.com/questions/300214/fitting-a-zero-inflated-weibull-model-in-jags). I am trying to fit a zero-inflated weibull model in JAGS. I am modeling the number of new trees that appear in a forest plot over some recensus period that varies from 5-10 years. The data are counts, with lots of zero observations. I would like...Martyn PlummerTue, 29 Aug 2017 11:55:46 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b7cd1e27/?limit=25#b4daMartyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b7cd1e27/?limit=25#b4daERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?This is also posted on cross validated [here](https://stats.stackexchange.com/questions/300214/fitting-a-zero-inflated-weibull-model-in-jags). I am trying to fit a zero-inflated weibull model in JAGS. I am modeling the number of new trees that appear in a forest plot over some recensus period that varies from 5-10 years. The data are counts, with lots of zero observations. I would like...Martyn PlummerTue, 29 Aug 2017 11:54:22 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b7cd1e27/?limit=25#b4daMartyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b7cd1e27/?limit=25#b4daERROR! The markdown supplied could not be parsed correctly. Did you forget to surround a code snippet with "~~~~"?This is also posted on cross validated [here](https://stats.stackexchange.com/questions/300214/fitting-a-zero-inflated-weibull-model-in-jags). I am trying to fit a zero-inflated weibull model in JAGS. I am modeling the number of new trees that appear in a forest plot over some recensus period that varies from 5-10 years. The data are counts, with lots of zero observations. I would like...Martyn PlummerTue, 29 Aug 2017 11:52:35 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b7cd1e27/?limit=25#b4daMartyn Plummer committed [1e5514]https://sourceforge.net/p/mcmc-jags/code-0/ci/1e55149af095d54bf1924214e68bde32d3454d42/Remove unused exception class ParentErrorMartyn PlummerFri, 25 Aug 2017 14:53:20 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/1e55149af095d54bf1924214e68bde32d3454d42/Martyn Plummer committed [95ff71]https://sourceforge.net/p/mcmc-jags/code-0/ci/95ff71bef099eda8bbba4c8a9d190086593fef98/Documentation fixesMartyn PlummerFri, 25 Aug 2017 14:34:46 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/95ff71bef099eda8bbba4c8a9d190086593fef98/Martyn Plummer committed [76cd17]https://sourceforge.net/p/mcmc-jags/code-0/ci/76cd1748dbdf90ca3206f8460ee35ee2b38fe798/Simplify initialization of LogicalNodes with new initializeFixed() member function.Martyn PlummerFri, 25 Aug 2017 14:34:46 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/76cd1748dbdf90ca3206f8460ee35ee2b38fe798/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/55a80036/?limit=25#262bI can reassure everyone that the dordered.probit and dordered.logit distributions do work and you can find worked examples of the latter in the classic BUGS examples (see vol1/inhaler and vol1/bones). Nobody else can run your example since we do not have the file votes.csv that you are using. So we have to guess what the problem is. The error message you are getting can mean one of two things: 1) Bad starting values, so that the observed data has zero prior probability. This seems unlikely 2) The...Martyn PlummerThu, 24 Aug 2017 09:56:37 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/55a80036/?limit=25#262bMartyn Plummer committed [665c8b]https://sourceforge.net/p/mcmc-jags/rjags/ci/665c8b39a21e3836060d249b756730ecc10bfcc5/Fixes to configure scriptMartyn PlummerWed, 23 Aug 2017 16:08:18 -0000https://sourceforge.net/p/mcmc-jags/rjags/ci/665c8b39a21e3836060d249b756730ecc10bfcc5/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/64dc916b/?limit=25#1e02The bug here is that JAGS does not recognize that 2^n - 1 is an integer value. It should do in this case because n is a fixed positive integer. I have fixed this in the development version (future JAGS 5.0.0). In the meantime, you can work around the bug by defining M <- as.integer(2^n - 1) in your R script, supplying M with the data, and modifying the line for( i in 1:(2^n-1) ){ in your model description to for( i in 1:M ){Martyn PlummerWed, 23 Aug 2017 16:07:22 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/64dc916b/?limit=25#1e02Martyn Plummer committed [995484]https://sourceforge.net/p/mcmc-jags/rjags/ci/995484d61ca376ec706e08c64832d5937da84f41/Branch merge from release-4_patched (vectorisation of monitors)Martyn PlummerWed, 23 Aug 2017 15:33:47 -0000https://sourceforge.net/p/mcmc-jags/rjags/ci/995484d61ca376ec706e08c64832d5937da84f41/Martyn Plummer committed [d34f1a]https://sourceforge.net/p/mcmc-jags/code-0/ci/d34f1a1b436330e6334aa7278231ceac740a2417/Tidy codeMartyn PlummerWed, 23 Aug 2017 13:07:48 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/d34f1a1b436330e6334aa7278231ceac740a2417/Martyn Plummer committed [2a97a1]https://sourceforge.net/p/mcmc-jags/code-0/ci/2a97a13a414fd71adc93f4a5852f930655bb14f7/Bug fix for LogicalNode::isDiscreteValued().Martyn PlummerWed, 23 Aug 2017 13:07:48 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/2a97a13a414fd71adc93f4a5852f930655bb14f7/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/55a80036/?limit=25#cc3cIt was just a typo. You need to load the glm module to access the dordered.probit distribution.Martyn PlummerWed, 23 Aug 2017 07:56:14 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/55a80036/?limit=25#cc3cMartyn Plummer committed [748fd3]https://sourceforge.net/p/mcmc-jags/code-0/ci/748fd31f01b438a58dce0d6d8b29545ad8055ff9/Fix last branch merge (removing accidentally added deterministicSample method)Martyn PlummerThu, 17 Aug 2017 14:32:54 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/748fd31f01b438a58dce0d6d8b29545ad8055ff9/Martyn Plummer committed [def504]https://sourceforge.net/p/mcmc-jags/code-0/ci/def504343a4c07ad800dd72b0bb2c09bb08639c0/Branch merge from 4.3.0Martyn PlummerThu, 17 Aug 2017 14:13:11 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/def504343a4c07ad800dd72b0bb2c09bb08639c0/Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/8211df61/?limit=25#ea5cI have added a WAIC monitor to the dic module in JAGS 4.3.0. It is stilly experimental. If you guys could validate it against your own calculations that would be extremely useful. Here is an application to the blocker example from the classic bugs examples: module glm loaded > data <- read.jagsdata("blocker-data.R") > inits <- read.jagsdata("blocker-init.R") > load.module("dic") module dic loaded > m <- jags.model("blocker.bug", data, inits, n.chains = 2) Compiling model graph Resolving undeclared...Martyn PlummerThu, 17 Aug 2017 09:03:26 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/8211df61/?limit=25#ea5cMartyn Plummer committed [1b7b00]https://sourceforge.net/p/mcmc-jags/code-0/ci/1b7b00aa0426655739661499f27eeb9234fbd92d/Bug fixes for SumMethodMartyn PlummerWed, 16 Aug 2017 16:09:26 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/1b7b00aa0426655739661499f27eeb9234fbd92d/Martyn Plummer committed [fbe2fc]https://sourceforge.net/p/mcmc-jags/code-0/ci/fbe2fc5aad4b964629275d4d58fc12880678078f/Clarify classic bugs check instructions for Windows.Martyn PlummerWed, 16 Aug 2017 16:09:26 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/fbe2fc5aad4b964629275d4d58fc12880678078f/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/f371d9a0/?limit=25#50c5I've rewritten your model below to use dcat instead of dsample. This is possible because you are only sampling one observation at a time. model{ for (i in 1:newIDn){ #likelihood of newdat given chosen_index and olddat newdat[i,1:2] ~ dmnorm(olddat[chosen_index[i],1:2], tau) #sample from old IDs for each newID, according to some prior probs chosen_index[i] ~ dcat(rep(1, oldIDn)) } #Constrain chosen_index to avoid repeated indices for (j in 1:oldIDn) { #dinterval with cutpoint 1 will return 0 for is_chosen_sum[j]<=1...Martyn PlummerMon, 14 Aug 2017 15:23:48 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/f371d9a0/?limit=25#50c5Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/55a80036/?limit=25#1e00You have to provide starting values for cutpoints_unsorted. If you do not do this then all elements get initialized to the same value, which then causes vote_prob[vote_ix, 2:4] to be zero and hence any value of vote[vote_ix] that takes values 2, 3, 4, has likelihood zero. This is obviously a mis-feature and is fixed in JAGS 5.0.0 (under development). If you upgrade to JAGS 4.3.0 then you can use the new dordered.probit distribution directly. vote[vote_ix] ~ dordered.gamma(mu[vote_ix], cutpoints[1:4])...Martyn PlummerMon, 14 Aug 2017 13:51:39 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/55a80036/?limit=25#1e00Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/26fd192b/?limit=25#309bCan you show the error message?Martyn PlummerFri, 11 Aug 2017 09:56:49 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/26fd192b/?limit=25#309bMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/aa20da59/?limit=25#091cIn your code for setting the initial values you have a couple of lines that will cause problems. Here: Z[i,j,1] <- NA; Z[i,j,2] <- smalldata[i,j+3] and here: Z[i,j,1] <- smalldata[i,j]; Z[i,j,2] <- NA In your model, Z[i,j,1:2] is a single node: Z[i,j,1:2] ~ dmnorm(mu[i,j,1:2],Omega[1:2,1:2]) just as a node cannot be partially observed, it cannot be partially initialized. If you supply initial values for Z[i,j,1:2] then you must supply values for both components. You may not supply a starting value...Martyn PlummerFri, 11 Aug 2017 09:25:09 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/aa20da59/?limit=25#091cMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/8b90bc83/?limit=25#1adcWell, tau_e and tau_a are precision matrices, so to monitor the variance-covariance matrix you need to invert them. Add the following lines to your model: sigma_a <- inverse(tau_a) sigma_e <- inverse(tau_e) Then monitor the variance-covariance matrices as follows. out2 <- jags.samples(jags, c("sigma_a", "sigma_e"), 10000) plot(out2$sigma_a[1,1,1:10000,1], type = "l") plot(out2$sigma_a[1,2,1:10000,1], type = "l") plot(out2$sigma_e[1,1,1:10000,1], type = "l") plot(out2$sigma_e[1,2,1:10000,1], type...Martyn PlummerFri, 11 Aug 2017 09:07:31 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/8b90bc83/?limit=25#1adcMartyn Plummer committed [69c759]https://sourceforge.net/p/mcmc-jags/examples/ci/69c759c95e7579fc65c90920014408a7a12eb7f0/Add missing benchmarks for inhaler exampleMartyn PlummerThu, 10 Aug 2017 09:51:08 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/69c759c95e7579fc65c90920014408a7a12eb7f0/Martyn Plummer committed [55920d]https://sourceforge.net/p/mcmc-jags/examples/ci/55920d17590c9f04e285539f854e66a039bc7ebb/Updating ice exampleMartyn PlummerThu, 10 Aug 2017 09:51:08 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/55920d17590c9f04e285539f854e66a039bc7ebb/Martyn Plummer committed [13a773]https://sourceforge.net/p/mcmc-jags/examples/ci/13a77310cd6d3c647de3c1c1ccc3d6d68788fdc9/Add time checks to testsMartyn PlummerThu, 10 Aug 2017 09:51:08 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/13a77310cd6d3c647de3c1c1ccc3d6d68788fdc9/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/1cb7eccc/?limit=25#04ca/aa14This works in JAGS 4.3.0. The error message was a false alarm which I have now silenced. There are some sampling methods that do not work if you try to simultaneously update two nodes when one is a parent of the other. JAGS will throw this error message by default when you try to create such a multi-level sampler. This is a precaution against creating invalid samplers. After reviewing the Sum sampling method, I have concluded that multi-level samplers are perfectly safe so have allowed them.Martyn PlummerWed, 09 Aug 2017 13:49:45 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/1cb7eccc/?limit=25#04ca/aa14Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/aa20da59/?limit=25#5e1d/ee3dIn this model Z[i,1:2] is a latent variable and both elements Z[i,1] and Z[i,2] are unobserved for all values of i. When either smk[i] or eth[i] is observed then there is an a posteriori constraint on the values of Z[i,]. You must supply initial values that satisfy these constraints. Furthermore, in this case you must supply initial values for both Z[i,1] and Z[i,2] even if only one of smk[i] or eth[i] is observed. When neither smk[i] nor eth[i] is observed then you may omit initial values for Z[i,]...Martyn PlummerWed, 09 Aug 2017 13:30:27 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/aa20da59/?limit=25#5e1d/ee3dMartyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/640a2968/?limit=25#8f86In your model, z is a matrix (i.e. it has two dimensions) z[i,f] ~ dbern(psi) # State model In R, the object zst you supply as initial values for z has three dimensions zst <- apply(y, c(1,2,3), max) # Avoid data/model/inits conflict Here the call to apply() with the second argument MARGIN=c(1,2,3) preserves the first three dimensions.Martyn PlummerTue, 18 Jul 2017 20:26:45 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/640a2968/?limit=25#8f86Martyn Plummer committed [2c1987]https://sourceforge.net/p/mcmc-jags/code-0/ci/2c198735f6afa0efcd71b13d5ba7ccc62d3b84c6/Added tag release-4_3_0 for changeset 16ac33e7d936Martyn PlummerTue, 18 Jul 2017 15:33:31 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/2c198735f6afa0efcd71b13d5ba7ccc62d3b84c6/Martyn Plummer committed [16ac33]https://sourceforge.net/p/mcmc-jags/code-0/ci/16ac33e7d936f9c24c6a1d6269c541cc25147b4c/Fixes for SolarisMartyn PlummerTue, 18 Jul 2017 12:54:12 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/16ac33e7d936f9c24c6a1d6269c541cc25147b4c/Martyn Plummer committed [bf7eed]https://sourceforge.net/p/mcmc-jags/code-0/ci/bf7eedb4409123cd8b471d14eaf40858059f49ce/Fix broken test for base moduleMartyn PlummerTue, 18 Jul 2017 08:18:57 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/bf7eedb4409123cd8b471d14eaf40858059f49ce/Martyn Plummer committed [418cff]https://sourceforge.net/p/mcmc-jags/code-0/ci/418cffe37a99f60f2154286f49fa5933885c76bc/Fix order of sampler factoriesMartyn PlummerMon, 17 Jul 2017 15:17:11 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/418cffe37a99f60f2154286f49fa5933885c76bc/Martyn Plummer committed [409700]https://sourceforge.net/p/mcmc-jags/code-0/ci/4097001f6d03f95194c53b3a4268bf69b2889c02/Fix memory bugMartyn PlummerMon, 17 Jul 2017 15:17:11 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/4097001f6d03f95194c53b3a4268bf69b2889c02/Martyn Plummer committed [2fc7fb]https://sourceforge.net/p/mcmc-jags/code-0/ci/2fc7fbb1a79891093c9c087080629567be3d3833/Fixes for clangMartyn PlummerMon, 17 Jul 2017 15:17:11 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/2fc7fbb1a79891093c9c087080629567be3d3833/Martyn Plummer committed [f9b3ae]https://sourceforge.net/p/mcmc-jags/code-0/ci/f9b3ae0e797a7bb94c55094e81dfcc10e4836dbf/Remove obsolete sampler ConjugateFMartyn PlummerMon, 17 Jul 2017 15:17:11 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/f9b3ae0e797a7bb94c55094e81dfcc10e4836dbf/Martyn Plummer committed [46e5c0]https://sourceforge.net/p/mcmc-jags/examples/ci/46e5c0e61e8723791066d0a41d64345694fe9fb1/Schools example with scaled wishart priorMartyn PlummerMon, 17 Jul 2017 14:02:39 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/46e5c0e61e8723791066d0a41d64345694fe9fb1/Martyn Plummer committed [a87e48]https://sourceforge.net/p/mcmc-jags/code-0/ci/a87e481dd08db802cc7d7c901576e8d7de0fc00d/Fix serious memory bug in REScaledWishart2Martyn PlummerMon, 17 Jul 2017 12:49:14 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/a87e481dd08db802cc7d7c901576e8d7de0fc00d/Martyn Plummer committed [a30e33]https://sourceforge.net/p/mcmc-jags/examples/ci/a30e338704bb226e1b2c0864506588eefbe4f95f/Further fixes to inhaler exampleMartyn PlummerMon, 17 Jul 2017 10:34:32 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/a30e338704bb226e1b2c0864506588eefbe4f95f/Martyn Plummer committed [b302c2]https://sourceforge.net/p/mcmc-jags/examples/ci/b302c2daa64f5197eb14685c83cc375f402c0eda/Fixes for inhaler exampleMartyn PlummerMon, 17 Jul 2017 10:14:02 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/b302c2daa64f5197eb14685c83cc375f402c0eda/Martyn Plummer committed [56badc]https://sourceforge.net/p/mcmc-jags/code-0/ci/56badc8e27f4bb96c4218820e303b498e64abf9c/Changes to random effects samplers (no longer rescale random effects).Martyn PlummerThu, 13 Jul 2017 17:53:16 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/56badc8e27f4bb96c4218820e303b498e64abf9c/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#af12/e956/28c2There is no true way, really. I wrote a paper on this topic around 10 years ago https://doi.org/10.1093/biostatistics/kxm049 The main message of the paper is that these penalized deviance statistics are approximations that require certain asymptotic conditions. Specifically all contributions to pD must be much smaller than 1. For the linear model, I was able to show that 2*sum(pD/(1 - pD)) is the optimism of the expected deviance. I speculated that this might also be a good approximation for GLMs,...Martyn PlummerThu, 13 Jul 2017 14:11:15 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#af12/e956/28c2Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/7945bd0a/?limit=25#0e21/24dbHi Clark, Thanks for the reproducible example. You have triggered a bug in the likelihood calculations for the multinomial distribution. This is now fixed in the sources and the fix will be in the next release. Incidentally, your initial values for y should be y <- ifelse(h >= 1, 1, 0) i.e. with >= instead of >. After fixing that, I found the bug.Martyn PlummerThu, 13 Jul 2017 13:49:35 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/7945bd0a/?limit=25#0e21/24dbMartyn Plummer committed [afde19]https://sourceforge.net/p/mcmc-jags/code-0/ci/afde1963f699ea097a3f0577331e8cbc90d0c450/Fix likelihood calculations for size zero.Martyn PlummerThu, 13 Jul 2017 13:43:35 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/afde1963f699ea097a3f0577331e8cbc90d0c450/Martyn Plummer committed [742435]https://sourceforge.net/p/mcmc-jags/code-0/ci/74243568b6e23865695cac8d70331e5a86e92e86/Fix likelihood calculationsMartyn PlummerThu, 13 Jul 2017 13:43:35 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/74243568b6e23865695cac8d70331e5a86e92e86/Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/d792712c/?limit=25#bee5OK I understand the problem now. You need to change some things in your data preparation and in your model. In my simple example, I set the censored values to missing (NA). You need to the same with your data. Currently you have given the censored values the numeric code -1 but JAGS will interpret this as real data and will therefore consider all these values to be observed at -1. You need to change the following R code when you set up the data: ## For both X and Y, all values <= -1 are censored...Martyn PlummerThu, 13 Jul 2017 11:44:10 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/d792712c/?limit=25#bee5Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a7a0c6c1/?limit=25#111d/356eHi Inga This is a recurring problem. The underlying issue is that the operator * is overloaded. It can be used both for multiplying a matrix by a scalar and for element-wise multiplication of two conforming matrices. The first is scale preserving (hence we have a conjugate Wishart posterior); the second is not. Currently JAGS is unable to distinguish these two cases. This can be fixed, but only in the next major release. For your problem, I think there may be a solution if you write this part for...Martyn PlummerThu, 13 Jul 2017 10:14:26 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a7a0c6c1/?limit=25#111d/356eMartyn Plummer modified ticket #41https://sourceforge.net/p/mcmc-jags/bugs/41/'linker' input unusedMartyn PlummerThu, 13 Jul 2017 07:42:44 -0000https://sourceforge.net/p/mcmc-jags/bugs/41/Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a3a1a4a6/?limit=25#210aJAGS normally does not allow the observations to be deterministic functions of the parameters. There are some important exceptions, but what you have here is a non-linear function and it is not covered by any of the available "observable functions".Martyn PlummerWed, 12 Jul 2017 16:52:14 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/a3a1a4a6/?limit=25#210aMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#af12You can do this by hand with the results of dic.samples > dic.out <- dic.samples(mymodel, type="pD", n.iter=10000) > pD <- dic.out$penalty > dev <- dic.out$deviance > sum(dev + pD/(1 - pD)) The dic.samples function with type="popt" is supposed to give a better approximation to the optimism of the expected deviance, but it is based on importance weighting and is not very stable.Martyn PlummerWed, 12 Jul 2017 16:50:16 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/ea46dc43/?limit=25&page=1#af12Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b49c1c7c/?limit=25#0ce1Well is should work. If the only difference between your models is Poisson/log link vs binary/logit link then both should work equally well with the glm module (Actually the binary model will be much faster). In order to understand why this is not working I need a reproducible example, i.e., model, data, initial values and script to run the model.Martyn PlummerWed, 12 Jul 2017 16:28:49 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/b49c1c7c/?limit=25#0ce1Martyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/4dd85e64/?limit=25#cbcdI have looked into this a little more to see where the problem lies. I have tried your model with both link="cloglog" and link="logit". The BUGS code generated by mtc.model is different. You can see the code with cat(model$code) For your model with complementary log log link, the prior distribution on the baseline risk is generated by # Study baseline priors for (i in studies.a) { mu[i] <- cloglog(p.base[i]) p.base[i] ~ dunif(0, 1) } This is a uniform prior on the baseline risk p.base[i] for study...Martyn PlummerWed, 12 Jul 2017 16:17:15 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/4dd85e64/?limit=25#cbcdMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/4dd85e64/?limit=25#cbcdI have looked into this a little more to see where the problem lies. I have tried your model with both link="cloglog" and link="logit". The BUGS code generated by mtc.model is different. You can see the code with cat(model$code) For your model with complementary log log link, the prior distribution on the baseline risk is generated by # Study baseline priors for (i in studies.a) { mu[i] <- cloglog(p.base[i]) p.base[i] ~ dunif(0, 1) } This is a uniform prior on the baseline risk p.base[i] for study...Martyn PlummerWed, 12 Jul 2017 16:05:47 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/4dd85e64/?limit=25#cbcdMartyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/044acfef/?limit=25#8d59Logic errors come from deep within the program where it is not possible to return an informative error message from the users. Usually the problem can be caught earlier. I need your data in order to run this model and debug JAGS to see where the error comes from. Incidentally, the sum distribution is similar to dsum but has a simpler syntax, e.g. you can write: n[j,k] ~ sum(yu[1:100,j,k])Martyn PlummerWed, 12 Jul 2017 13:17:49 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/044acfef/?limit=25#8d59Martyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/044acfef/?limit=25#60e0Dear all, I'm trying to implement a spatial mark-resight model with a unknown number of marks to estimate animal density. I am using jags.model function and I get the following error: LOGIC ERROR: Unable to find sampled node I really have no idea on what I’m doing wrong. Many thanks in advance for any reply! Here’s the code: # Initial values for latent y yin <- array(0, c(M,J,K.max)) for(j in 1:J){ for(k in 1:K.max){ yin[1:M,j,k] <- rmultinom(1, n[j,k], rep(1/M, M)) }} data <- list(y=y, n=n, mmax=mmax,...Martyn PlummerWed, 12 Jul 2017 13:15:18 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/044acfef/?limit=25#60e0Martyn Plummer modified a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/044acfef/?limit=25#60e0Dear all, I'm trying to implement a spatial mark-resight model with a unknown number of marks to estimate animal density. I am using jags.model function and I get the following error: LOGIC ERROR: Unable to find sampled node I really have no idea on what I’m doing wrong. Many thanks in advance for any reply! Here’s the code: ~~~~ # Initial values for latent y yin <- array(0, c(M,J,K.max)) for(j in 1:J){ for(k in 1:K.max){ yin[1:M,j,k] <- rmultinom(1, n[j,k], rep(1/M, M)) }} data <- list(y=y, n=n,...Martyn PlummerWed, 12 Jul 2017 13:14:55 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/044acfef/?limit=25#60e0Martyn Plummer committed [54942c]https://sourceforge.net/p/mcmc-jags/examples/ci/54942c43fe9919deb260d5ec0a189244d3a79170/More tests for inhaler exampleMartyn PlummerMon, 10 Jul 2017 16:42:44 -0000https://sourceforge.net/p/mcmc-jags/examples/ci/54942c43fe9919deb260d5ec0a189244d3a79170/Martyn Plummer posted a comment on discussion Open Discussionhttps://sourceforge.net/p/mcmc-jags/discussion/610036/thread/d792712c/?limit=25#42e7Thanks Jim for your kind message. It means a lot to me. It is probably easier to discuss a concrete example. Here is some simulated data where values below -1 are censored. Check your code against this. Simulate some data in R: x <- rnorm(100) Observed <- ifelse(x < -1, 0, 1) x[x < -1] <- NA Model "left_censored.txt" model { for (i in 1:N) { Observed[i] ~ dinterval(x[i], -1) x[i] ~ dnorm(mu, tau) } tau ~ dgamma(1E-3, 1E-3) mu ~ dnorm(0, 1E-4) } Run the model in R library(rjags) m <- jags.model("left_censored.txt",...Martyn PlummerFri, 07 Jul 2017 06:19:13 -0000https://sourceforge.net/p/mcmc-jags/discussion/610036/thread/d792712c/?limit=25#42e7Martyn Plummer posted a comment on discussion Helphttps://sourceforge.net/p/mcmc-jags/discussion/610037/thread/4dd85e64/?limit=25#5368I'm not familiar with the gemtc package, but I see you are using the complementary log log link: link="cloglog", With binomial outcomes, only the logit link will give you the symmetric results that you are expecting.Martyn PlummerThu, 06 Jul 2017 09:13:54 -0000https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/4dd85e64/?limit=25#5368Martyn Plummer committed [a6ed62]https://sourceforge.net/p/mcmc-jags/code-0/ci/a6ed6227bd82f13a25a4828133c618aa2524538d/Fixes for WAIC monitorMartyn PlummerFri, 30 Jun 2017 16:07:56 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/a6ed6227bd82f13a25a4828133c618aa2524538d/Martyn Plummer committed [2f0ff9]https://sourceforge.net/p/mcmc-jags/code-0/ci/2f0ff9deed865e8131b6befe0703102f6d3c81a7/Added WAIC monitorMartyn PlummerFri, 30 Jun 2017 15:29:25 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/2f0ff9deed865e8131b6befe0703102f6d3c81a7/Martyn Plummer committed [ea3f03]https://sourceforge.net/p/mcmc-jags/code-0/ci/ea3f0369437509aece33c1dc1928bffaa2a168cb/Fixes for SolarisMartyn PlummerFri, 30 Jun 2017 09:13:37 -0000https://sourceforge.net/p/mcmc-jags/code-0/ci/ea3f0369437509aece33c1dc1928bffaa2a168cb/