Creates randomised social networks for each network window using datastream permutations with user-defined restrictions (to constrain swaps according to temporal or spatial windows)

DatastreamPermSoc(
  data,
  intwindow,
  mindate,
  maxdate,
  netwindow,
  overlap,
  spacewindow,
  same.time,
  time.restrict,
  same.spat,
  spat.restrict,
  n.swaps,
  n.rand,
  burnin,
  n.burnin,
  iter,
  buffer = 0
)

Arguments

data

A 5 column dataframe with columns for the ID of the captured individual, the location of its capture (a name or number), the x coordinate of its capture location, the y coordinate of the capture location, and the date of capture

intwindow

The maximum period of time (in days) between two co-captures (i.e. if intwindow = 10 then two individuals captured 10 days apart could be considered co-captured but two individuals captured 11 days apart would not be)

mindate

The start date (format = "YYYY-MM-DD") of the study (i.e. when you want to build networks from)

maxdate

The end date (format = "YYYY-MM-DD") of the study (i.e. when you want to build networks until). Please provide as the day after the last day of the study.

netwindow

The period of time (in months) over which each network is built(i.e. netwindow=12 would correspond to yearly networks)

overlap

The amount of overlap between networks in months (i.e. overlap=2 would result in a second network window starting 2 months before the end of the first). When overlap=0, there is no overlap between successive network windows

spacewindow

The maximum distance between locations that can be classed as a co-capture (calculated using the coordinate system provided in the input data). Best used when multiple capture locations occur very close together

same.time

(TRUE/FALSE) Whether swaps should be restricted to only occur betwen individuals trapped on the same date or not

time.restrict

Provided as a number of months. Imposes time restrictions on when swaps can take place so that individuals can only be swapped with those a fixed time before or after being captured

same.spat

(TRUE/FALSE) Whether swaps should be restricted to only occur between individuals trapped at the same location

spat.restrict

Provided on the same scale as the coordinates in the input dataset. Imposes space restrictions on when swaps can take place so that individuals can only be swapped with those captued within a fixed distance

n.swaps

The number of swaps between each random network being extracted (e.g. n.swaps = 10 would equate to 10 swaps taking place between each random network being saved)

n.rand

The number of randomised networks to be generated

burnin

(TRUE/FALSE) Whether burnin is required

n.burnin

The number of swaps to discard as burn-in before the first random network is created. The total number of swaps conducted is thus n.burnin+n.swaps*n.rand

iter

(TRUE/FALSE) Whether iterative randomisations are being used. If TRUE then D.rand is also returned

buffer

The number of days around a capture event that an individual can't be swapped into. Defaults to zero. This exists for when trapping schedules would prevent an individual trapped on one day being trapped on adjacent days

Value

If iter=TRUE then a list of length 3 with elements corresponding to:

  1. The randomised dataset (for feeding back into the next permutation)

  2. Randomised adjacency matrix list: a list of with the same number of elements at the number of network windows, with each element containing an array of the randomised adjacency matrices

  3. A matrix identifying whether an individual was present in each network window.

If iter=FALSE then a list of length 2 with elements corresponding to:

  1. Randomised adjacency matrix list: a list of with the same number of elements at the number of network windows, with each element containing an array of the randomised adjacency matrices

  2. A matrix identifying whether an individual was present in each network window. The edge list is not provided due to to the memory that providing this and the list of matrix arrays would require.

Examples

if (FALSE) { # load in data data(cmrData) # set parameters mindate<-"2010-01-01" maxdate<-"2015-01-01" intwindow<-60 netwindow<-12 overlap<-0 spacewindow<-0 # create network netdat<-DynamicNetCreate(data=cmrData, intwindow=intwindow, mindate=mindate, maxdate=maxdate, netwindow=netwindow, overlap=overlap, spacewindow=spacewindow) same.time=FALSE time.restrict=6 same.spat=FALSE spat.restrict="n" n.swaps=10 n.rand=100 n.burnin=100 Rs <- DatastreamPermSoc(data=cmrData, intwindow, mindate, maxdate, netwindow, overlap, spacewindow, same.time, time.restrict, same.spat, spat.restrict, n.swaps, n.rand, burnin=TRUE, n.burnin, iter=FALSE, buffer=0) }