MixSIAR
MixSIAR copied to clipboard
Error in output_posteriors, not producing values
I have run through the wolf data and have no problem. I am unable to get the alligator data to work as I continually get an error Error in if (n.chains == 1) return(coda::mcmc(sims[, 1, ], thin = n.thin)) : argument is of length zero
So I can't test it there.
Ive no idea why when I use the exact same script as the wolf example to run my 1 model, I am missing information. no posterior draws are produced or saved.
jags.mod$BUGSoutput$sims.list$p.fac1[,1,1]
produces NAs or ZERO
g.post <- output_posteriors(jags.mod, mix, source, output_options)
names(g.post)
[1] "both" "epsilon"
There is nothing to plot. Even though I have 2 fixed effects Age and Treatment, nothing is registering. What have I done wrong? what am I missing? Ive been working on this issue for 10 days almost and its really disheartening so any assistance would be extremely appreciated.
mix<- load_mix_data(filename=mix.filename,
iso_names=c("d13C","d15N"),
factors=c("age_class","treatment"),
fac_random=c(FALSE, FALSE),
fac_nested=c(FALSE,FALSE),
cont_effects=NULL)
mainDir <- "~/StableIsotope/5 MixSIAR/BestModelRun"
subDir <- paste0("model_", mod)
dir.create(file.path(getwd(), subDir), showWarnings = FALSE)
setwd(file.path(getwd(), subDir))
source[[mod]] <- load_source_data(filename=source.filename,
source_factors=NULL,
conc_dep=FALSE,
data_type="means",
mix[[mod]])
discr[[mod]] <- load_discr_data(filename=discr.filename, mix[[mod]])
plot_data(filename=paste0("isospace_plot_", mod),
plot_save_pdf=FALSE,
plot_save_png=TRUE,
mix[[mod]], source[[mod]], discr[[mod]],
return_obj = TRUE)
model_filename <- paste0("MixSIAR_model_", mod, ".txt")
resid_err <- TRUE
process_err <- TRUE
write_JAGS_model(model_filename, resid_err, process_err, mix[[mod]], source[[mod]])
jags.mod[[mod]] <- run_model(run="long", mix[[mod]], source[[mod]], discr[[mod]], model_filename, alpha.prior=1)
# Process diagnostics, summary stats, and posterior plots
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)
output_JAGS(jags.mod, mix[[mod]], source[[mod]], output_options)
..$ BUGSoutput :List of 24
.. ..$ n.chains : int 3
.. ..$ n.iter : num 3e+05
.. ..$ n.burnin : num 2e+05
.. ..$ n.thin : num 100
.. ..$ n.keep : int 1000
.. ..$ n.sims : int 3000
.. ..$ sims.array : num [1:1000, 1:3, 1:108] 271 269 268 264 261 ...
.. .. ..- attr(*, "dimnames")=List of 3
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. .. .. ..$ : chr [1:108] "deviance" "ilr.fac1[1,1]" "ilr.fac1[2,1]" "ilr.fac1[3,1]" ...
.. ..$ sims.list :List of 7
.. .. ..$ deviance : num [1:3000, 1] 269 264 272 268 273 ...
.. .. ..$ ilr.fac1 : num [1:3000, 1:3, 1:3] 0 0 0 0 0 0 0 0 0 0 ...
.. .. ..$ ilr.fac2 : num [1:3000, 1:2, 1:3] 0 0 0 0 0 0 0 0 0 0 ...
.. .. ..$ ilr.global: num [1:3000, 1:3] -1.168 -0.708 -0.754 0.556 0.521 ...
.. .. ..$ loglik : num [1:3000, 1:83] -0.532 -0.408 -1.064 -0.885 -0.854 ...
.. .. ..$ p.global : num [1:3000, 1:4] 0.02041 0.00424 0.0069 0.03996 0.08206 ...
.. .. ..$ resid.prop: num [1:3000, 1:2] 0.969 0.266 0.543 0.626 0.807 ...
.. ..$ sims.matrix : num [1:3000, 1:108] 269 264 272 268 273 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : NULL
.. .. .. ..$ : chr [1:108] "deviance" "ilr.fac1[1,1]" "ilr.fac1[2,1]" "ilr.fac1[3,1]" ...
.. ..$ summary : num [1:108, 1:9] 267.06 0 -0.219 0.263 0 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:108] "deviance" "ilr.fac1[1,1]" "ilr.fac1[2,1]" "ilr.fac1[3,1]" ...
.. .. .. ..$ : chr [1:9] "mean" "sd" "2.5%" "25%" ...