View source: R/Utility_functions.R
make_mig | R Documentation |
Function to create a migration matrix from x,y coordinates or pairwise distance matrix.
make_mig(site.arrange, max.dist, tot)
site.arrange |
Matrix or Distance object. Either a two column matrix with x-values \(i.e. longitude\) in the first column and y-values (i.e. latitude) in the second column or a pairwise distance object between each site. |
max.dist |
Numeric, the maximum distance the species can migrate. |
tot |
Numeric, a value between 0 and 1 detailing the probability of migration. |
This function creates a matrix of migration probabilities where cell ij is the probability for a species to migrate from community j to community i. Migration probablities are calculated by dividing the total probability of migrating into proportions between all the communities that the species can reach according to the max.dist parameter. Proportions are set up so that they are inversely related to the distance travelled, i.e. the further the distance between sites the lower the probability of migrating between sites. If x,y coordinates are given, pairwise euclidean distances are calcuted and used.
Returns a mumeric matrix where cell ij is the probability of the species migrating from community j to community i.
xy <- matrix(sample(50, 10), ncol = 2)
make_mig(xy, 20, .1)
pairdist <- dist(xy)
make_mig(pairdist, 20, .1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.