Description Usage Arguments Details Value Author(s) References Examples
Calculate a network from a group by individual matrix. This function allows various levels of subsetting.
1 2 3 4 5 6 | 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,
enter_time = NULL, exit_time = NULL)
|
association_data |
a |
data_format |
|
association_index |
|
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) |
enter_time |
N vector of times when each individual entered the population |
exit_time |
N vector of times when each individual departed the population |
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.
In some situations it is useful to calculate the network based only on the period in which each dyad overlapped within the population. In such cases, the entry_time and/or the exit_time variables can be given. These must given in the same format as the times variable, and all need to be in a format capable of doing time or date comparisons using > and < operators. The easiest is YYYYMMDD, whereas MMDDYYYY or DDMMYYYY will not work properly.
N x N
matrix of association weights for each dyad.
Damien R. Farine
Whitehead (2008) Analyzing Animal Societies
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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)
## End(Not run)
|
Generating 80 x 80 matrix
Generating 80 x 80 matrix
$z.stat
[1] 18.35219
$p
[1] 0.001
$alternative
[1] "two.sided"
Attaching package: 'igraph'
The following objects are masked from 'package:ape':
edges, mst, ring
The following objects are masked from 'package:stats':
decompose, spectrum
The following object is masked from 'package:base':
union
Loading required package: statnet.common
Attaching package: 'statnet.common'
The following object is masked from 'package:base':
order
Loading required package: network
network: Classes for Relational Data
Version 1.13.0 created on 2015-08-31.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
Mark S. Handcock, University of California -- Los Angeles
David R. Hunter, Penn State University
Martina Morris, University of Washington
Skye Bender-deMoll, University of Washington
For citation information, type citation("network").
Type help("network-package") to get started.
sna: Tools for Social Network Analysis
Version 2.4 created on 2016-07-23.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
For citation information, type citation("sna").
Type help(package="sna") to get started.
Attaching package: 'sna'
The following object is masked from 'package:ape':
consensus
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.