![]() Vector llik //log likelihood for each capture history at the last time period Vector p //capture probability (real scale) Vector z_lp //temporal RE on capture probability Vector z_ls // temporal RE on survival (logit) Int sumf //first capture occasion for each capture history Int sumFR //number of individuals with particular capture history Int sumCH //capture history matrix (1= captured, 2= unobserved) Int NsumCH //number of unique capture histories example 1- matrix multiplication using loops “A need for speed in Bayesian population models: a practical guide to marginalizing and recovering discrete latent states.” Ecological Applications 30.5 (2020): e02112. csv file (first 10 columns = sumCH, 11th column = sumFR, 12th column = sumf), NsumCH=dim(sumCH), Nocc=10. Thank you so much! I’ve attached the simulated data I used for this example as a. (2020) - and my example code follows this framework. In Stan, we use a marginalized likelihood framework described in Yackulic et al. When an animal is captured, it is given an individually-identifiable mark so that it can be monitored through time. Animals in the study area are vulnerable to capture during multiple, discrete capture occasions. ![]() The simple model code I have provided is a Cormack-Jolly-Seber (CJS) model to estimate survival and capture probability for animals. Also - would using sparse matrices be helpful for this type of model? Is there something I am doing inefficiently? The dataset I am actually fitting is much larger than this toy example (my actual code has 25 states - 42 occasions - and additional state uncertainty -I always run it using multiplication loops as the matrix math is too slow), so any speed-up tips would be really useful. There seems to be a lot of discussion on how it is more efficient to use matrices and vectorization, however, I find matrix multiplication to be much slower in Stan than just running loops (see simple example below). Specifically, since lots of my code involves matrix math, I wanted to know the most efficient way to do this. As I’ve started to build larger and more complex models, model run times are getting excessive (e.g., weeks) and I’m wondering if there’s somewhere in my code where I am unknowingly being inefficient. Hello! I’ve been working in Stan for a few years now (mainly building mark-recapture models), and while I love this program there are many things I do not fully understand, particularly about speed and optimization.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |