Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot invert matrix: not positive definite, re: issue #54 #85

Open
rjbest opened this issue Sep 21, 2016 · 10 comments
Open

Cannot invert matrix: not positive definite, re: issue #54 #85

rjbest opened this issue Sep 21, 2016 · 10 comments

Comments

@rjbest
Copy link

rjbest commented Sep 21, 2016

I'm having the same issue as a previous user in Issue #54

I get (Error: RUNTIME ERROR:Cannot invert matrix: not positive definite) from jags when using any more than 2 tracers and raw source data.

My values for the discrimination means and SDs are all 0s, but my source SDs are not 0s. When I calculate the source means and SDs and use that instead, it works fine. It does not matter if I use the GUI or script method. I'm assuming using the raw data (with >40 samples per source) would free me from problems of non-normality in the sources, so would really like to figure out what is wrong.

Were there any obvious formatting errors uncovered in issue #54 ?

Thanks very much!

@rjbest
Copy link
Author

rjbest commented Sep 21, 2016

Second related question. Looking at the model.txt file, it looks like even with raw source data that is just used to calculate means and standard deviations anyway, and the normality assumption still applies to the distribution of source tracers values?

Thanks again.

@MaartenWynants
Copy link

Hi,

What helped me was using mean source data instead of raw data because like you said the model calculates the means and SD values anyway.
I think that your discriminant matrix has to have the same form as your source matrix otherwise they won't convert. So if you build your source with raw data, I think you have to make sure your discriminant is defined for every data point.
However, I am no specialist, I am just speaking out of my own experience of trial and error.

Maarten

@rjbest
Copy link
Author

rjbest commented Sep 27, 2016

Thanks very much Maarten. I'm still curious about the difference between raw vs. mean data because as far as I can tell they do not produce the same results (for just two tracers, where both options are possible to run and compare). But maybe it's as simple as the kind of sample size adjustment made in the SD calculation - that sample size number has to be used for something....

@alex-koiter
Copy link

I too ran into the same issue using raw data with more than two tracers and I was unable to resolve it. Worked no problem when using the summarized data.

@igoreulaers
Copy link

Hi,

I am running in this issue running a triple-isotope model, at the stage where I ask to run the JAGS model ("write_JAGS_model(model_filename, resid_err, process_err, mix, source)"):

Error in update.jags(object, n.iter, ...) : RUNTIME ERROR:
Cannot invert matrix: not positive definite

I wonder whether someone has already pinpointed to a specific issue?

Any help is deeply appreciated !

@amroco
Copy link

amroco commented Jun 5, 2023

I've also run into this issue using a triple isotope model. I am going to use summarized source data as suggested, but perhaps there multiple isotope vignettes could be updated to say "use summarised source data instead of raw" to help avoid this situation? Also not clear on the difference between using raw and summarised values in the model. Does the model summarise them?

@brianstock
Copy link
Owner

brianstock commented Jun 5, 2023 via email

@jasmineisela
Copy link

I have ran into a similar issues and have attempted to use residual error only, and still received the error. Are 3 tracers not able to be used with raw data?

@roxanasierra
Copy link

I am having the same problem with raw data. I tried 5 sources, 4 sources (all with at least 3 different samples), an with two sources. All gave me the same error:
Initializing model

| | 0%
Error in update.jags(object, n.iter, ...) : RUNTIME ERROR:
Cannot invert matrix: not positive definite

Any suggestions would be appreciated

Thanks!

@cls03
Copy link

cls03 commented Mar 18, 2024

Hi everyone,

I'm also having the same issue with two isotopes, with raw data, and using size as a continuous covariate. It worked when I did the trial run, but then doesn't work when I change it from trial to anything else. @brianstock, for my system, I should use residual and process error both as true. I played with these when trying to run the model as 'normal', and it only works when resid_err = F and process_err = T. When resid_err = T and process_corr = F, I get "Error in update.jags(object, n.iter,....). Error in node x_iso[47m1:2] Failure to calculate log density." When I put both resid_err and process_err as T (what I want), I get "Error in update.jags(object, n.iter, ....): RUNTIME ERROR: Cannot invert matrix" not positive definitive." There's a paper that did the analysis I need to do on the same species, etc, and they used both as true. I'm not sure where this could be going wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants