Learn R Programming

tsna (version 0.1.3)

tSnaStats: Apply the sna package's static graph- and vertex-level network descriptive statistics at multiple time points

Description

Samples collapsed static networks at regular intervals along a network dynamic object, applies the named static sna descriptive statistic function to each network, and returns the result as a time series. Additional arguments to the function can be included via ... . Set the sna function's directedness and self-loops flags appropriately by default.

Usage

tSnaStats(nd, snafun, start, end, time.interval = 1, ...)

Arguments

nd
a networkDynamic object to be evaluated
snafun
character string giving the name of the sna package function to be applied. i.e 'mutuality'
start
optional numeric time value at which evaluation should start (default is first observed time)
end
optional numeric time value at which evaluation should end (default is last observed time)
time.interval
optional numeric value giving time interval between evaluations (default is 1)
...
additional arguments to be passed on to the sna function. See docs for each function for possible arguments.

Value

  • a ts (time series) object. A matrix in which rows correspond to the time points evaluated and columns correspond to values of statistics produced. In the case of vertex-level indices, there will be one column per vertex. For the census measures, each column will correspond to a census element.

Details

This wrapper directly calls functions in the sna package, so it will only work if that package is installed. Below is a list of supported functions:

Graph-Level statistics:

Vertex-level statistics:

  • closenessVertex Closeness Centrality Scores
  • betweennessVertex Betweenness Centrality Scores
  • bonpowVertex Bonacich Power Centrality Scores
  • degreeVertex Degree Centrality Scores
  • evcentVertex Eigenvector Centrality Scores
  • flowbetVertex Flow Betweenness Scores
  • graphcentVertex (Harary) Graph Centrality Scores
  • infocentVertex Information Centrality Scores
  • loadcentVertex Load Centrality Scores
  • prestigeVertex Prestige Scores

Most of the sna functions involve converting the network to a matrix and can be quite expensive to calculate for a single time point, so use care when applying to large or long-duration networks.

Some of the sna functions are undefined or produce numerical errors when applied to networks with certain configurations (such as zero edges).

The sna functions generally cannot handle networks with no vertices, so stats will be replaced with NA when they are encountered.

There may be some overlap with ergm terms available through tErgmStats and the ergm version will generally be faster

References

Carter T. Butts (2014). sna: Tools for Social Network Analysis. R package version 2.3-2. http://CRAN.R-project.org/package=sna

See Also

See also tErgmStats,

Examples

Run this code
library(networkDynamicData)
data(harry_potter_support)

# compute triad census scores for each time point
tSnaStats(harry_potter_support,snafun='triad.census')

# compute graph transitivities
tSnaStats(harry_potter_support,snafun='gtrans')
data(concurrencyComparisonNets)
# since thes are big nets, with lots of timepoints, 
# set time.interval to avoid evaluating every step
tSnaStats(base,'prestige',time.interval=25,rescale=TRUE)

# since it is time series, easy to plot
plot(tSnaStats(base,'components',time.interval=10))

Run the code above in your browser using DataLab