Time-stratified distance matrices

12 views
Skip to first unread message

Sophie Newmarch

unread,
Jul 28, 2025, 9:46:59 PMJul 28
to revbayes-users
Hey everyone,

I am wanting to use revbayes for a time-stratified biogeographic analysis and have been following the advanced tutorial from the website (https://revbayes.github.io/tutorials/biogeo/biogeo_epoch). I note that to keep the example analysis simple, a single distance matrix is used, which assumes distances remain constant over time. What varies is the connectivity matrix for each time slice or epoch. 

I would like to have different distance matrices for each time epoch and was wondering how I would go about coding this in revbayes?

To start, the different connectivity matrices are generated by coding:

"for (i in 1:n_epochs) { epoch_fn[i] = geo_fn + ".connectivity." + i + ".txt" connectivity[i] <- readDataDelimitedFile(file=epoch_fn[i], delimiter=" ") }"

so would I be able to sub out connectivity to distance to read in stratified distance files?

Best,
Sophie


Sophie Newmarch

unread,
Aug 17, 2025, 6:39:46 PMAug 17
to revbayes-users
Hi all,

Just an update on this topic in case someone else (likely beginners like me!) would find it helpful in future. Thanks to guidance from other users, the change I was asking to make is what is needed i.e. subbing in 'distance' instead of 'connectivity'. As another user pointed out, you have to make sure that you refer to the stratified distance matrices (i.e. remember the '[i]')when setting up the dispersal rate matrix (see below).

for (i in 1:n_epochs) { for (j in 1:n_areas) { for (k in 1:n_areas) { dr[i][j][k] <- 0.0 if (connectivity[i][j][k] > 0) { dr[i][j][k] := dispersal_rate * exp(-distance_scale * distances[i][j][k]) } } } }

Hope that is helpful!
Sophie
Reply all
Reply to author
Forward
0 new messages