Error in plot_continuous_var
MixSIAR Version 3.1.12 R version 4.4.1 RStudio 2024.04.1 Build 748
When there are two factors and one continuous effect, plot_continuous_var when output_options$return_obj == TRUE returns "Error in plot_continuous_var(jags.1, mix, source, output_options) : object 'g' not found".
I've looked into the function code, and it is because there are if statements in the function for mix$n.effects == 1 and mix$n.effects == 0, but no statement for mix$n.effects == 2.
When running this model, I also got a warning when running the model, "In FUN(X[[i]], ...) : Failed to set trace monitor for ilr.global: Monitor already exists and cannot be duplicated".
I've made a reprex by modifying the alligator example within the package (mixsiar_script_alligator_length_ind.R). I just added sex in as a fixed effect into the mix file. The only modified code was:
mix <- load_mix_data(filename=mix.filename,
iso_names=c("d13C","d15N"),
factors=c("ID", "sex"),
fac_random=c(TRUE, FALSE),
fac_nested=c(FALSE, FALSE),
cont_effects="Length")
Then once the model is run, this creates the error:
output_options <- list(summary_save = TRUE, summary_name = "summary_statistics", sup_post = TRUE, plot_post_save_pdf = FALSE,
plot_post_name = "posterior_density", sup_pairs = TRUE, plot_pairs_save_pdf = TRUE, plot_pairs_name = "pairs_plot",
sup_xy = TRUE, plot_xy_save_pdf = TRUE, plot_xy_name = "xy_plot", gelman = TRUE, heidel = FALSE,
geweke = TRUE, diag_save = TRUE, diag_name = "diagnostics", indiv_effect = FALSE, plot_post_save_png = FALSE,
plot_pairs_save_png = FALSE, plot_xy_save_png = FALSE, diag_save_ggmcmc = FALSE, return_obj = TRUE)
diag <- output_diagnostics(jags.1, mix, source, output_options)
df.stats <- output_stats(jags.1, mix, source, output_options)
### this creates the error
g.post <- output_posteriors(jags.1, mix, source, output_options)