Trace Plots from Multi Species Model

Skip to first unread message

Bethke, Bethany (DNR)

Oct 22, 2019, 10:13:39 AM10/22/19



I was wondering if there’s a way to get trace plots from the multiSpeciesTP model runs? When I try what works with the TPmodel function I get this error message:


adult_models <- multiSpeciesTP(adultList, model = "twoBaselinesFull",

                                 n.adapt = 20000, n.iter = 20000,

                                 burnin = 20000, n.chains = 5, print = FALSE)


posterior.samples <- posteriorTP(model = adult_models, n.iter = 20000,

                                 variable.names = c("TP", "alpha"))


Error in model$iter() : attempt to apply non-function


So then I’m not able to take the next step of:


summary(posterior.samples) #use median values from #1 for estimates


#Diagnostic of model fit, use to check if iterations are enough and model has converged

posterior.combined <- coda::mcmc(, posterior.samples))

getPosteriorMode(posterior.combined) #central tendency best described by mode, according to example



The multiSpeciesTP function is definitely working for me, and I’m getting output in the dataframe that seems good, but I would like to check some diagnostics if possible.


Thank you!

Bethany Bethke

Fisheries Research Scientist | Fish and Wildlife

Minnesota Department of Natural Resources

5351 N Shore Dr

Duluth MN,  55804




Claudio Quezada Romegialli

Oct 26, 2019, 2:45:02 PM10/26/19
to Bethke, Bethany (DNR),
Hi Bethany

When you use multiSpeciesTP() you have to change print = FALSE to TRUE, so that you can get trace plots for each consumer.

adult_models <- multiSpeciesTP(adultList, model = "twoBaselinesFull",

                                 n.adapt = 20000, n.iter = 20000,

                                 burnin = 20000, n.chains = 5, print = TRUE)

Although, once you have calculated TP through multiSpeciesTP, there is no need to calculate posteriorTP, this is only needed when calculating one consumer at a time.

If you want to get a numerical summary just use

sapply(adult_models$"TPs", quantile, probs = c(0.025, 0.5, 0.975)) %>% round(3)

and for the mode use

If you have any doubts, please let me know.



To download tRophicPosition package visit
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web, visit

Dr. Claudio Quezada-Romegialli
Profesor Asociado
Departamento de Biología
Facultad de Ciencias Naturales y Exactas
Universidad de Playa Ancha, Valparaíso, Chile
Móvil: +56 9 9038 0148
Teléfono: +56 32 250 0519
Reply all
Reply to author
0 new messages