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

Alligator example #149

Closed
Daniel-Gorman opened this issue Aug 28, 2018 · 8 comments
Closed

Alligator example #149

Daniel-Gorman opened this issue Aug 28, 2018 · 8 comments

Comments

@Daniel-Gorman
Copy link

Hi Brian, fairly new user of MixSIAR. I am trying to run the script for the recently included Alligator example through R Studio, but I don’t seem to be able to get past line 173. This then appears to mean that I cannot subsequently ‘compare_models’ (screenshot below). Apologies if it’s a naively simple issue, but any advice would be greatly appreciated.

image

Attached also is Sessioninfo():

image

@brianstock
Copy link
Owner

Hi Daniel,

I just re-ran mixsiar_script_alligator.R on my machine to confirm it is working.

My guess is you're getting an error in the for loop with the call to plot_data (since it's graphics-related) and then not actually running the models. If you look at each element of the jags.mod list, you should see rjags objects. I.e. if you run class(jags.mod[[1]]), the output should be [1] "rjags".

Assuming this is the case, set mod=1 and then go through the for loop line-by-line to see what is causing the error. My guess is that it is related to graphics. Sometimes R Studio causes issues here, so first thing I'd try would be using the R console instead.

@Daniel-Gorman
Copy link
Author

Hi Brian, Ive checked the objects - and get [1] = NULL (rather than "rjags").. ?
Also, I'm not quite sure what you mean by "go through the for loop line-by-line"..
Thanks for any additional help.

image

@brianstock
Copy link
Owner

Yeah, that's what I expected - you're getting an error before running the model (there is no model object saved as jags.mod[[1]]). After setting mod=1, run the lines inside the for loop (i.e. 109-166) one command at a time so you can see where the error occurs.

@Daniel-Gorman
Copy link
Author

Hi Brian, slowly getting through the examples. Managed to fix the previous issue by changing the for loop section:

plot_data(filename=paste0("isospace_plot_", mod),
plot_save_pdf=FALSE,

I'm now using my own data (with 4 competing models), but getting the following error when moving back up to the root directory:
image

@brianstock
Copy link
Owner

Good to hear! Saving PDFs is likely an OS-specific issue. Did you try using the R console instead of R Studio?

The new error is happening reading in the source CSV file, not when moving back to the root directory. It's probably worth a bit of your time to do an R tutorial and understand what a for loop is. Cyclismo is pretty good: https://www.cyclismo.org/tutorial/R/scripting.html#for-statements.

@Daniel-Gorman
Copy link
Author

Hi again Brian, making steady progress now :) Thanks for the very responsive help..
Ive made it all the way through running my 4 models (Null, factor, covariate, factor+covariate) and used LOO to compare the weights!
Now trying to plot the covariate (similar to the Alligator plot) but bumped into some more issues. Any advice on the following error?
image

@brianstock
Copy link
Owner

Sorry, this error is sloppy coding/testing on my part. The calc_eps function should be moved above where it is called. I've fixed this on the develop branch, which you can install via

devtools::install_github("brianstock/MixSIAR", ref="develop")

Alternatively, you can just copy+paste the calc_eps function (lines 274-280), then re-run that code.

@Daniel-Gorman
Copy link
Author

Hi Brian - this worked - thanks greatly.
So, now I’m almost where I want to be, but I fear that the "hard part" is yet to come. My covariate (‘distance’) model includes 6 dietary sources (which makes interpretation very difficult). What I would like to do is combine the 6 sources – into 3 groups (a posteriori)..
Something like this (taken from the Mantis e.g.):

combined <- combine_sources(jags.model, mix, source, alpha.spec,
groups=list(group1=c("source1","source2"), group2=c("source3","source4"), group3=c("source5","source6")))

..and then Plot [group] proportions vs. ‘distance’ from covariate model.
I'm currently trying to merge the code from Mantis (combine) + Alligator (plot proportions vs. length) > but not getting very far :0
Any advice on how to move forward, greatly appreciated.

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

2 participants