To.From.ID: Convenience function to make to-from object needed for...

View source: R/to_from.R

To.From.IDR Documentation

Convenience function to make to-from object needed for specifying MLPE random effects

Description

Convenience function to make to-from object needed for specifying MLPE random effects

Usage

To.From.ID(sampled_pops,
                  pop_n = NULL,
                  spLoc = NULL,
                  nb = NULL,
                  ...)

Arguments

sampled_pops

Provide an integer value representing the number of individuals or populations that were sampled

pop_n

Provide a vector of length equal to 'sampled_pops', indicating the number of individuals sampled at each population. Only needed if going from a population- to an individual-based analysis

spLoc

SpatialPoints object of sample locations

nb

Distance between points that should be considered as part of the same group or neighborhood. If spLoc is specified, nb must also be specified. See Details.

...

Additional arguments. Currently only 'dist' argument is accepted.

Details

This function creates an object indicating the population pairs that distance values were calculated between. Note: Distance values must be taken from the lower half of a distance matrix. You can use lower to obtain these values. When specifying a MLPE model using mlpe_rga, pop1 from To.From.ID must be added to the data frame containing model data, and must be specified as the random effect.

By providing spLoc, you can add an additional random effect to account for spatial proximity of sample locations. You must also specify nb, which indicates the maximum distance (in units of your spLoc object) that locations are considered to be part of the same neighborhood.

Value

A data frame with two columns

Author(s)

Bill Peterman <Peterman.73@osu.edu>

Examples

## Standard use
To.From.ID(sampled_pops = 4)

## If going from population to individual-level 
To.From.ID(sampled_pops = 4,
           pop_n = c(1,2,3,1))
         
## A vector of pairwise distances can also be expanded            
To.From.ID(sampled_pops = 4,
           pop_n = c(1,2,3,1),
           dist = runif(6)) 
           
## Spatial location incorporated
spLoc <- SpatialPoints(cbind(c(1,2,9,10), 
                             c(1,2,9,10)))
          
To.From.ID(sampled_pops = 4,
           spLoc = spLoc,
           nb = 3)              

wpeterman/ResistanceGA documentation built on Nov. 20, 2023, 11:50 p.m.