Trace Plots from Multi Species Model

20 views
Skip to first unread message

Bethke, Bethany (DNR)

unread,
Oct 22, 2019, 10:13:39 AM10/22/19
to trophicposi...@googlegroups.com

Hello,

 

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(do.call(rbind, posterior.samples))

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

plot(posterior.samples)

 

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

218-302-3271

bethany...@state.mn.us

https://www.dnr.state.mn.us/fisheries/management/research.html

 

 

Claudio Quezada Romegialli

unread,
Oct 26, 2019, 2:45:02 PM10/26/19
to Bethke, Bethany (DNR), trophicposi...@googlegroups.com
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

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

and for the mode use
getPosteriorMode(adult_models$"TPs")

If you have any doubts, please let me know.

Cheers

Claudio


--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
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 trophicposition-s...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/trophicposition-support/BN8PR09MB34606819C2DA682677927540DE680%40BN8PR09MB3460.namprd09.prod.outlook.com.


--
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
Forward
0 new messages