pafi: Pair-wise affinity index

View source: R/pafi.R

pafiR Documentation

Pair-wise affinity index

Description

Pair-wise affinity index

Usage

pafi(
  assodata,
  presence = NULL,
  daterange = NULL,
  flips = 500,
  rand = 10,
  removesolitary = FALSE,
  addIDs = FALSE,
  exclcols = NULL,
  progbar = TRUE
)

Arguments

assodata

data frame with association data. Can include a date column (ignored if no daterange is specified), and a focal column (if not found, column names (excluding date if found) are assumed to be "focals", i.e. individuals that are considered for calculating the index).

presence

optional data.frame in the form of date by ID, with 0 and 1 indicating whether an ID was present on a given day or not; first column must be a date (YYYY-MM-DD); see createnullpresence

daterange

character or date of length 2 (format YYYY-MM-DD). Ignored, if no date column is found. For multiasso() it can also be a list with pairs of dates or one of the following single characters: "months", "bimonth" or "trimonth", (details below)

flips

the number of iterations WITHIN each randomization, i.e. how many dyads are swapped

rand

numeric. Number of times, a null association data set is created while keeping distribution of association (party) sizes constant and the number of times each individual appears. Used to assess an expected association index (which can be used to test null hypothesis that observed associations are random).

removesolitary

logical, by default FALSE. should parties/associations that consist of only one individual (the focal if focal column is found) be excluded.

addIDs

logical, by default FALSE. should individuals that are not focals (if there is a focal column in assodata), but represented by columns be included in dyads to be calculated. E.g. if there is a focal column, and addIDs=TRUE than all focal-nonfocal dyads will be considered (in addition to focal-focal dyads), while nonfocal-nofocal dyads will be ignored. Remove the focal column if you whish to use all dyads that are represented by columns (or add the name of the focal column in the exclcols= argument).

exclcols

character string with column names (or numerical index of these) to be excluded. Normally used to exclude columns that neither represent IDs, date or focal.

progbar

logical, should a progress bar be displayed? by default TRUE

Details

Note that the algorithm for the randomization is not very efficient, i.e. it is slow. So use a small rand to verify that the function indeed works as expected before using a “proper” value (>=1000)...

Future versions should include the possibility to differentiate between focals and other IDs, as well as a function to create artificial association data sets for testing purposes... Another thing to do is to allow the possibility to integrate neighbor data, which is essentially the same idea but could contain "parallel" data sets according to different distance categories.

Also, as of now, possible problems include cases in which a single association/party includes all individuals, i.e. this might cause a problem for the randomization test, at least in HWI().

To be done as well is to make sure that if there is a focal column, that the entry for the respective focal individual is set to 1, ie. to indicate presence in its own party (done in v0.34). More generally, make sure to consider the difference between party data and neighbor data!

Value

a data.frame

References

Pepper et al 1999

Examples

## Not run: 
data(dolphins)
dpr <-  createnullpresence(colnames(dolphins)[2:19], from="2000-01-01", "2000-02-09")
# pairwise affinity index
pafi(dolphins, flips=100, rand=100)
pafi(dolphins, flips=100, rand=100, presence = dpr)

## End(Not run)

gobbios/socialindices documentation built on Feb. 14, 2023, 3:56 p.m.