brianstock / MixSIAR

A framework for Bayesian mixing models in R:
http://brianstock.github.io/MixSIAR/
90 stars 75 forks source link

Error in JAGS model #105

Open Lushani84 opened 7 years ago

Lushani84 commented 7 years ago

Hi, I've been using MixSIAR for a bit now and thought I've gotten comfortable with the code. The model was running fine for a few data sets but I keep getting this error with my current set. There were no error messages up until hit run_model() I tried looking for an answer on StackOverflow but to no avail, please help!

module glm loaded Compiling model graph Resolving undeclared variables Allocating nodes Deleting model

Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on line 123. Index out of range taking subset of src_tau

brianstock commented 7 years ago

Hmm, that is strange. The model is probably misspecified and my error checks missed the problem. If you want to email me your csv files and R script, I can take a look.

-Brian

Lushani84 commented 7 years ago

Thank you! I'm sending them to you now.

NaDinG commented 6 years ago

Hi, how was the problem solved? I was wondering, because I think I have a comparable one with the jags model: Compiling model graph Declaring variables Resolving undeclared variables Allocating nodes Deleting model

Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on line 165. Index out of range taking subset of src_cov

But I also have an error when calculating the convex hull area: Error: dims [product 14] do not match the length of object [0]

Thank you in advance Nadin

nauplius97 commented 6 years ago

Hello!

Same here... Any hint about what the problem might have been?

I got this message:

Compiling model graph Resolving undeclared variables Allocating nodes Deleting model

Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on line 113. Index out of range taking subset of src_tau

Thanks! David.

KelseyKingsbury commented 6 years ago

Hi everyone,

I have the same error when trying to run the JAGS model:

(Compiling model graph Resolving undeclared variables Allocating nodes Deleting model

Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains, : RUNTIME ERROR: Compilation error on line 93. Index out of range taking subset of src_tau)

Has anyone figured out a fix yet?

Thanks, Kelsey

werderz commented 5 years ago

Hi everyone,

I have the same problem/error: Error in jags.model(jags_model, quiet = "TRUE", inits = inits, data = list(mrg.y = mrg.y, : RUNTIME ERROR: Compilation error on line 12. Index out of range taking subset of phi

Was someone able find a solution for the problem already?

Thanks, Sandy

MaartenWynants commented 5 years ago

After some trial and error I think I have fixed this issue. This error only occurs if you only use 1 error class (either residual or process error only). For example in my case :

model_filename <- "MixSIAR_model.txt" process_err <- FALSE resid_err <- TRUE write_JAGS_model(model_filename, process_err, resid_err, mix, source)

jags.1 <- run_model(run="test",mix,source,discr,model_filename, alpha.prior = alpha, process_err,resid_err) < Make sure in your code these are in the same order: 1. process and 2. residual

Hope that helps. Maarten

eronraines commented 4 years ago

Hi all,

I had the same error showing up and I fixed it. What worked for me was making sure that the initial parameters I called in were the appropriate dimension. What you might play with is the initial parameter. It might need to be a matrix of initial values.

Hope this helps people, Eron

mhannappel commented 1 year ago

I was able to fix my error: I got the error and found a typo in my dataset where one of the factors in my Consumers data had one more level than in my sources (e.g., I had 5 locations in my consumer's data and only 4 in the sources). Once I fixed the typo, the error was resolved. Try checking that you have the same number of levels for a factor in both the consumers and sources. Hope that helps.