get_network

0th

Percentile

Calculating Weighted Network

Calculate a network from a group by individual matrix. This function allows various levels of subsetting.

Usage
get_network(association_data, data_format = "GBI",
association_index = "SRI", identities = NULL,
which_identities = NULL, times = NULL, occurrences = NULL,
locations = NULL, which_locations = NULL, start_time = NULL,
end_time = NULL, classes = NULL, which_classes = NULL)
Arguments
association_data

a K x N matrix of K groups (observations, gathering events, etc.) and N individuals (all individuals that are present in at least one group) OR a K x N x N array of sampling periods.

data_format

"GBI" expect a group by individual matrix, "SP" Expect a sampling periods array

association_index

"SRI" Simple ratio index, "HWI" Half-weight index (more to come)

identities

N vector of identifiers for each individual (column) in the group by individual matrix

which_identities

vector of identities to include in the network (subset of identities)

times

K vector of times defining the middle of each group/event

occurrences

N x S matrix with the occurrence of each individual in each sampling period (see details) containing only 0s and 1s

locations

K vector of locations defining the location of each group/event

which_locations

vector of locations to include in the network (subset of locations)

start_time

element describing the starting time for inclusion in the network (useful for temporal analysis)

end_time

element describing the ending time for inclusion in the network (useful for temporal analysis)

classes

N vector of types or class of each individual (column) in the group by individual matrix (for subsetting)

which_classes

vector of class(es)/type(s) to include in the network (subset of classes)

Details

Provides the ability to generate networks from one group by individual matrix and subsetting within the function. This is particularly useful for generating several networks with different characteristics from the same group by individual matrix (for example networks from a given location or set of locations, or of a particular sex).

Including occurrence data is recommended when using sampling periods (not required for GBI data). If an individual is only observed alone in a sampling period, then it will not be included in the sampling period matrices (as these record only associations or interactions, not presence). Thus, a matrix containing N (for number of individuals) rows and S (for number of sampling periods) is required. See the get_sampling_periods function for help generating this matrix.

Value

N x N matrix of association weights for each dyad.

• get_network
Examples
# NOT RUN {
data("group_by_individual")
data("times")

# subset GBI (to reduce run time of the example)
gbi <- gbi[,1:80]

## define to 2 x N x N network to hold two association matrices
networks <- array(0, c(2, ncol(gbi), ncol(gbi)))

## calculate network for first half of the time
networks[1,,] <- get_network(gbi, data_format="GBI",
association_index="SRI", times=times, start_time=0,
end_time=max(times)/2)
networks[2,,] <- get_network(gbi, data_format="GBI",
association_index="SRI", times=times,
start_time=max(times)/2, end_time=max(times))

## test if one predicts the other via a mantel test (must be loaded externally)
library(ape)
mantel.test(networks[1,,],networks[2,,])

## convert to igraph network and calculate degree of the first network
# }
# NOT RUN {
library(igraph)
net <- graph.adjacency(networks[1,,], mode="undirected", diag=FALSE, weighted=TRUE)
deg_weighted <- graph.strength(net)
detach(package:igraph)

## alternatively package SNA can use matrix stacks directly
library(sna)
deg_weighted <- degree(networks,gmode="graph", g=c(1,2), ignore.eval=FALSE)
detach(package:sna)
# }

Documentation reproduced from package asnipe, version 1.1.11, License: GPL-2

Community examples

Looks like there are no examples yet.