Title: | Statistical Network Analysis of Animal Social Networks |
---|---|
Description: | Obtain network structures from animal GPS telemetry observations and statistically analyse them to assess their adequacy for social network analysis. Methods include pre-network data permutations, bootstrapping techniques to obtain confidence intervals for global and node-level network metrics, and correlation and regression analysis of the local network metrics. |
Authors: | Prabhleen Kaur [aut, cre], Michael Salter-Townshend [ctb] |
Maintainer: | Prabhleen Kaur <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.1 |
Built: | 2025-02-08 06:08:54 UTC |
Source: | https://github.com/prabhleenkaur19/anisna |
Obtain network structures from animal GPS telemetry observations and statistically analyse them to assess their adequacy for social network analysis. Methods include pre-network data permutations, bootstrapping techniques to obtain confidence intervals for global network metrics, and correlation and regression analysis of the local network metrics.
Prabhleen Kaur
To obtain two non-overlapping bootstrapped versions and obtain p-values for the significance of difference between them
bootstrapped_difference_pvalues( network, n_versions = 1000, seed = 12345, n.iter = 10, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)) )
bootstrapped_difference_pvalues( network, n_versions = 1000, seed = 12345, n.iter = 10, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)) )
network |
An igraph object |
n_versions |
Number of bootstrapped versions to be used (default = 1000) |
seed |
seed number |
n.iter |
Number of iterations at each level |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
A matrix of p-values whose rows correspond to the sub-sample size and columns correspond to the chosen network metric. The sub-sample size values (corresponding to rows) occur in multiples of 5 and range from 5 to a maximum of half the number of nodes in the network
data(elk_network_2010) mean_pvalue_matrix <- bootstrapped_difference_pvalues(elk_network_2010, n_versions = 100) plot(mean_pvalue_matrix)
data(elk_network_2010) mean_pvalue_matrix <- bootstrapped_difference_pvalues(elk_network_2010, n_versions = 100) plot(mean_pvalue_matrix)
To perform correlation analysis for node-level network metrics
correlation_analyze( network, n_simulations = 10, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(degree = function(net, sub_net) igraph::degree(net, v = igraph::V(sub_net)$name), strength = function(net, sub_net) igraph::strength(net, v = igraph::V(sub_net)$name), betweenness = function(net, sub_net) igraph::betweenness(net, v = igraph::V(sub_net)$name), clustering_coefficient = function(net, sub_net) igraph::transitivity(net, type = "local", vids = igraph::V(sub_net)$name), eigenvector_centrality = function(net, sub_net) igraph::eigen_centrality(net)$vector[igraph::V(sub_net)$name]) )
correlation_analyze( network, n_simulations = 10, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(degree = function(net, sub_net) igraph::degree(net, v = igraph::V(sub_net)$name), strength = function(net, sub_net) igraph::strength(net, v = igraph::V(sub_net)$name), betweenness = function(net, sub_net) igraph::betweenness(net, v = igraph::V(sub_net)$name), clustering_coefficient = function(net, sub_net) igraph::transitivity(net, type = "local", vids = igraph::V(sub_net)$name), eigenvector_centrality = function(net, sub_net) igraph::eigen_centrality(net)$vector[igraph::V(sub_net)$name]) )
network |
An igraph graph object consisting of observed network |
n_simulations |
Number of sub-samples to be obtained at each level |
subsampling_proportion |
A vector depicting proportions of sub-sampled nodes |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Each function definition should include two parameters, one for the main network and another one for the subnetwork. See default example. Default = c("degree" = function(net, sub_net) igraph::degree(net, v = igraph::V(sub_net)$name), "strength" = function(net, sub_net) igraph::strength(net, v = igraph::V(sub_net)$name), "betweenness" = function(net, sub_net) igraph::betweenness(net, v = igraph::V(sub_net)$name), "clustering_coefficient" = function(net, sub_net) igraph::transitivity(net, type = "local", vids = igraph::V(sub_net)$name), "eigenvector_centrality" = function(net, sub_net) igraph::eigen_centrality(net)$vector[igraph::V(sub_net)$name]) |
A list of network metrics of class list_correlation_matrices. Each element of list is a matrix whose columns correspond to subsampling_proportion and rows correspond to n_simulations. The entries of the matrix provide value of correlation between the nodes in full network and the sub-sampled network for the corresponding metric.
data(elk_network_2010) elk_correlation_analysis <- correlation_analyze(elk_network_2010) plot(elk_correlation_analysis)
data(elk_network_2010) elk_correlation_analysis <- correlation_analyze(elk_network_2010) plot(elk_correlation_analysis)
Calculate distance between two pairs of radian coordinates
distance_radian_coordinates(latf, lonf, latt, lont)
distance_radian_coordinates(latf, lonf, latt, lont)
latf |
latitude from |
lonf |
longitude from |
latt |
latitude to |
lont |
longitude to |
distance value in meters
A list of 100 igraph objects obtained by permuting the raw elk_data_2010 and obtaining network from those
elk_2010_permutations
elk_2010_permutations
A list of 100 igraph objects
data(elk_2010_permutations)
data(elk_2010_permutations)
Dataset of all possible interactions from elk_data_2010
elk_all_interactions_2010
elk_all_interactions_2010
A dataframe with 7615 rows and 5 variables
First animal ID
Second animal ID
Observation timestamp of first animal
Observation timestamp of second animal
Distance in metres between the two animals
data(elk_all_interactions_2010)
data(elk_all_interactions_2010)
Contains GPS telemetry observations of the species elk in year 2010
elk_data_2010
elk_data_2010
A dataframe with 123568 rows and 4 variables:
Unique ID of individuals in the observed sample
Date and timestamp of the observation
Latitude of individual observation in radians
Longitude of individual observation in radians
data(elk_data_2010)
data(elk_data_2010)
Dataset of interactions from elk_data_2010 using first mode as the spatial threshold
elk_interactions_2010
elk_interactions_2010
A dataframe with 2393 rows and 5 variables
First animal ID
Second animal ID
Observation timestamp of first animal
Observation timestamp of second animal
Distance in metres between the two animals
data(elk_interactions_2010)
data(elk_interactions_2010)
An igraph object depicting the network obtained from elk_interactions_2010
elk_network_2010
elk_network_2010
An igraph object with 57 nodes and 114 edges
igraph::E(elk_network_2010)
igraph::E(elk_network_2010)
To convert latitude and longitude values from degrees to radians
get_coordinates_in_radian(species_raw)
get_coordinates_in_radian(species_raw)
species_raw |
A DataFrame consisting of GPS observations. The DataFrame must have a "latitude" column and a "longitude" column whose values are specified in degrees. |
The same DataFrame that has been passed as the argument with two additional columns namely "latitude_rad" and "longitude_rad"
To obtain interactions from raw GPS observations
get_interactions(species_raw, temporal_thresh = 7, spatial_thresh, n_cores = 1)
get_interactions(species_raw, temporal_thresh = 7, spatial_thresh, n_cores = 1)
species_raw |
A DataFrame consisting of GPS observations. It should have at least four columns namely "animal_id", "datetime", "latitude|_rad", and "longitude_rad". "latitude|_rad", and "longitude_rad" are latitude and longitude values in radians respectively. See function "get_coordinates_in_radian" to get these values. |
temporal_thresh |
Temporal threshold in minutes with default 7 minutes |
spatial_thresh |
The maximum distance in meters within which two animals are considered interacting |
n_cores |
Number of cores for parallel processing with default 1 |
A dataframe consisting of five columns. The first two columns contain animal ids, third and fourth column contain timestamp of their observations and the final column contains the distance between the two individuals.
data(elk_data_2010) get_interactions(elk_data_2010, temporal_thresh = 7, spatial_thresh = 15)
data(elk_data_2010) get_interactions(elk_data_2010, temporal_thresh = 7, spatial_thresh = 15)
Calculates and prints network summary statistics
get_network_summary(network)
get_network_summary(network)
network |
An undirected network with nodes representing animal IDs and edges representing associations between them. |
No return value, called for side effects. The function prints values of network metrics to the console.
data(elk_network_2010) get_network_summary(elk_network_2010)
data(elk_network_2010) get_network_summary(elk_network_2010)
To obtain spatial threshold for calculating interactions from raw GPS observations. The threshold is obtained as the distance interval that captures maximum number of inter-individual interactions.
get_spatial_threshold(species_interactions, interval_size)
get_spatial_threshold(species_interactions, interval_size)
species_interactions |
A dataframe consisting of individual interactions within maximum possible distance |
interval_size |
Minimum interval size within which the number of interactions should be calculated |
Spatial threshold in meters
data(elk_all_interactions_2010) get_spatial_threshold(elk_all_interactions_2010, interval_size = 2)
data(elk_all_interactions_2010) get_spatial_threshold(elk_all_interactions_2010, interval_size = 2)
To obtain confidence intervals around the observed global network statistics
global_CI( network, n_versions = 100, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), CI_size = 0.95 )
global_CI( network, n_versions = 100, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), CI_size = 0.95 )
network |
An igraph object consisting of observed network. |
n_versions |
Number of bootstrapped versions to be used. (default = 100) |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
CI_size |
Size of confidence interval. Default is 0.95 that generates a 95% confidence interval. |
A DataFrame consisting of three columns. The first column contains the value of observed network metric, the second and third column represent the lower and upper limit of 95
data(elk_network_2010) global_CI(elk_network_2010, n_versions = 100, network_metrics_functions_list = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)))
data(elk_network_2010) global_CI(elk_network_2010, n_versions = 100, network_metrics_functions_list = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)))
To obtain width of confidence intervals for global network metrics using bootstrapped versions at each level of sub-sampling
global_width_CI( network, n_versions = 100, seed = 12345, n.iter = 10, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), scaled_metrics = NULL, CI_size = 0.95 )
global_width_CI( network, n_versions = 100, seed = 12345, n.iter = 10, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), scaled_metrics = NULL, CI_size = 0.95 )
network |
An igraph object consisting of observed network. |
n_versions |
Number of bootstrapped versions to be used. (default = 100) |
seed |
seed number |
n.iter |
Number of iterations at each level. (default = 10) |
network_metrics_functions_list |
A list consisting of function definitions of the global network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
scaled_metrics |
Optional. A vector subset of the names of functions in network_metrics_functions_list with the metrics that should be scaled. For example scaled_metrics = c("diameter") |
CI_size |
Size of confidence interval. Default is 0.95 that generates a 95% confidence interval. |
A matrix of class Width_CI_matrix containing width of Confidence Intervals where each row corresponds to the sub-sample size and columns correspond to the chosen network metric. Sub-sample size values occur in multiples of 10 and range from 10 to maximum multiple of 10 less than or equal to the number of nodes in the network.
data(elk_network_2010) width_CI_elk <- global_width_CI(elk_network_2010, n_versions = 100) plot(width_CI_elk)
data(elk_network_2010) width_CI_elk <- global_width_CI(elk_network_2010, n_versions = 100) plot(width_CI_elk)
Function to obtain pairs of interacting animals
interacting_pairs( i, datetime, latitude, longitude, temporal_thresh, spatial_thresh )
interacting_pairs( i, datetime, latitude, longitude, temporal_thresh, spatial_thresh )
i |
Index of the animal |
datetime |
DateTime vector |
latitude |
latitude vector |
longitude |
longitude vector |
temporal_thresh |
time threshold in minutes |
spatial_thresh |
spatial threshold in meters |
A matrix consisting of two row. The first row corresponds to the interacting indices and the second row to the respective distances.
Function to obtain a network structure from interactions dataframe
network_from_interactions(species_raw, interactions, n_cores = 1)
network_from_interactions(species_raw, interactions, n_cores = 1)
species_raw |
A dataframe consisting of raw GPS observations. It should have at least four columns namely "animal_id", "datetime", "latitude|_rad", and "longitude_rad". "latitude|_rad", and "longitude_rad" are latitude and longitude values in radians respectively. See function "get_coordinates_in_radian" to get these values. |
interactions |
A dataframe of interactions obtained from raw GPS observations using the function "get_interactions" |
n_cores |
Number of cores for parallel processing, default is 1 |
An object of class igraph
data(elk_data_2010, elk_interactions_2010) network_from_interactions(elk_data_2010, elk_interactions_2010)
data(elk_data_2010, elk_interactions_2010) network_from_interactions(elk_data_2010, elk_interactions_2010)
To obtain confidence intervals for node-level network metrics
node_level_CI( network, n_versions = 100, network_metrics_functions_list = c(degree = igraph::degree, strength = igraph::strength, betweenness = igraph::betweenness, clustering_coefficient = function(x) { trans <- igraph::transitivity(x, type = "local", vids = igraph::V(x), isolates = "zero") names(trans) <- igraph::V(x)$name return(trans) }, eigenvector_centrality = function(x) igraph::eigen_centrality(x)$vector), n_cores = 1, CI_size = 0.95 )
node_level_CI( network, n_versions = 100, network_metrics_functions_list = c(degree = igraph::degree, strength = igraph::strength, betweenness = igraph::betweenness, clustering_coefficient = function(x) { trans <- igraph::transitivity(x, type = "local", vids = igraph::V(x), isolates = "zero") names(trans) <- igraph::V(x)$name return(trans) }, eigenvector_centrality = function(x) igraph::eigen_centrality(x)$vector), n_cores = 1, CI_size = 0.95 )
network |
An igraph graph object consisting of observed network. |
n_versions |
Number of bootstrapped versions to be used. (default = 100) |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Each function definition should include two parameters, one for the main network and another one for the subnetwork. See default example. network_metrics_functions_list = c("degree" = igraph::degree, "strength" = igraph::strength , "betweenness" = igraph::betweenness, "clustering_coefficient" = function(x) { trans <- igraph::transitivity(x, type = "local", isolates = "zero") names(trans) <- igraph::V(x)$name;return(trans) }, "eigenvector_centrality" = function(x) igraph::eigen_centrality(x)$vector ) |
n_cores |
Number of cores for parallel processing with default 1. |
CI_size |
Size of confidence interval. Default is 0.95 that generates a 95% confidence interval. |
A list of dataframes of class list_node_level_CI. Each element of list is a dataframe having five columns and having number of rows equal to number of nodes in the network. The five columns correspond to node_number, node_name, metric_value, lower_CI, upper_CI. correspond to subsampling_proportion and rows correspond to n_simulations. The entries of the matrix provide value of correlation between the nodes in full network and the sub-sampled network for the corresponding metric.
data(elk_network_2010) elk_node_level_CI <- node_level_CI(elk_network_2010) plot(elk_node_level_CI)
data(elk_network_2010) elk_node_level_CI <- node_level_CI(elk_network_2010) plot(elk_node_level_CI)
To obtain bootstrapped versions of a network's adjacency matrix
obtain_bootstrapped_samples( network, n_nodes = igraph::gorder(network), n_versions = 1000, seed = 12345 )
obtain_bootstrapped_samples( network, n_nodes = igraph::gorder(network), n_versions = 1000, seed = 12345 )
network |
An igraph object |
n_nodes |
Number of nodes to be selected in bootstrapped versions (default : All nodes) |
n_versions |
Number of bootstrapped versions required |
seed |
seed number |
A list of class bootstrapped_pvalue_matrix consisting of two elements. The first element contains the adjacency matrix of the original network and the second element contains bootstrapped versions of the adjacency matrices.
data(elk_network_2010) obtain_bootstrapped_samples(elk_network_2010, n_versions = 100)
data(elk_network_2010) obtain_bootstrapped_samples(elk_network_2010, n_versions = 100)
To obtain sub-networks of the observed network
obtain_network_subsamples( network, n_subsamples = 1, subsampling_proportion = 0.5 )
obtain_network_subsamples( network, n_subsamples = 1, subsampling_proportion = 0.5 )
network |
An igraph object |
n_subsamples |
Number of sub-networks to be obtained. (default = 1) |
subsampling_proportion |
A value depicting the level (in proportion) at which sub-samples to be taken. (default = 0.5). This value should lie between 0 and 1 depicting the proportion of observed nodes to be included in the sub-network. |
A list of size n_subsamples, where each element of the list is an igraph object representing a sub-network of the observed network.
data(elk_network_2010) obtain_network_subsamples(elk_network_2010, 1, 0.5)
data(elk_network_2010) obtain_network_subsamples(elk_network_2010, 1, 0.5)
Function to obtain permuted networks from raw datastream
obtain_permuted_network_versions( species_raw, temporal_thresh, spatial_thresh, n_permutations, n_cores = 1 )
obtain_permuted_network_versions( species_raw, temporal_thresh, spatial_thresh, n_permutations, n_cores = 1 )
species_raw |
A dataframe consisting of raw GPS observations |
temporal_thresh |
Temporal threshold in minutes |
spatial_thresh |
Spatial threshold |
n_permutations |
Number of permuted versions to obtain |
n_cores |
Number of cores for parallel processing with default 1 |
An object of class "list_permuted_networks" of size n_permutations where each element is a network of class igraph obtained by permuting raw datastream
data(elk_data_2010) permuted_versions <- obtain_permuted_network_versions(elk_data_2010, temporal_thresh = 7, spatial_thresh = 15, n_permutations = 10, n_cores = 2)
data(elk_data_2010) permuted_versions <- obtain_permuted_network_versions(elk_data_2010, temporal_thresh = 7, spatial_thresh = 15, n_permutations = 10, n_cores = 2)
Visualize Animal Network
plot_network(species_network, seed = 1)
plot_network(species_network, seed = 1)
species_network |
An igraph graph object consisting of observed network. |
seed |
Seed to be set for layout. |
No return value, called for side effects. The plots depict a visualisation of network structure.
data(elk_network_2010) plot_network(elk_network_2010)
data(elk_network_2010) plot_network(elk_network_2010)
To plot the results obtained from bootstrapped_difference_pvalues function
## S3 method for class 'bootstrapped_pvalue_matrix' plot(x, ...)
## S3 method for class 'bootstrapped_pvalue_matrix' plot(x, ...)
x |
A matrix of p-values obtained from bootstrapped_difference_pvalues function |
... |
Further arguments are ignored. |
No return value, called for side effects. The plot shows p-values between 0 and 1 corresponding to each sample size.
data(elk_network_2010) mean_pvalue_matrix <- bootstrapped_difference_pvalues(elk_network_2010, n_versions = 100) plot(mean_pvalue_matrix)
data(elk_network_2010) mean_pvalue_matrix <- bootstrapped_difference_pvalues(elk_network_2010, n_versions = 100) plot(mean_pvalue_matrix)
To plot correlation analysis results
## S3 method for class 'list_correlation_matrices' plot(x, ...)
## S3 method for class 'list_correlation_matrices' plot(x, ...)
x |
A list of matrices obtained from correlation_analyze function. |
... |
Further arguments are ignored. |
No return value, called for side effects. The plots show mean and standard deviation of correlation coefficients obtained over multiple iterations.
data(elk_network_2010) elk_correlation_analysis <- correlation_analyze(elk_network_2010) plot(elk_correlation_analysis)
data(elk_network_2010) elk_correlation_analysis <- correlation_analyze(elk_network_2010) plot(elk_correlation_analysis)
To plot the results for node-level confidence intervals
## S3 method for class 'list_node_level_CI' plot(x, ...)
## S3 method for class 'list_node_level_CI' plot(x, ...)
x |
A list of dataframes obtained from node_level_CI function. |
... |
Further arguments are ignored. |
No return value, called for side effects. The plots show confidence intervals along with the observed metric value for each of the nodes in the network.
data(elk_network_2010) elk_node_level_CI <- node_level_CI(elk_network_2010) plot(elk_node_level_CI)
data(elk_network_2010) elk_node_level_CI <- node_level_CI(elk_network_2010) plot(elk_node_level_CI)
Function to plot the network metrics distribution of permuted networks
## S3 method for class 'list_permuted_networks' plot( x, species_original_network, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), ... )
## S3 method for class 'list_permuted_networks' plot( x, species_original_network, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), ... )
x |
A list of igraph objects obtained obtained using the function obtain_permuted_network_versions |
species_original_network |
An igraph object which is the original network |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
... |
Further arguments are ignored. |
No return value, called for side effects.
data(elk_data_2010, elk_network_2010) permuted_versions <- obtain_permuted_network_versions(elk_data_2010, temporal_thresh = 7, spatial_thresh = 15, n_permutations = 10, n_cores = 2) plot(permuted_versions, elk_network_2010)
data(elk_data_2010, elk_network_2010) permuted_versions <- obtain_permuted_network_versions(elk_data_2010, temporal_thresh = 7, spatial_thresh = 15, n_permutations = 10, n_cores = 2) plot(permuted_versions, elk_network_2010)
To plot regression analysis results
## S3 method for class 'list_regression_matrices' plot(x, ...)
## S3 method for class 'list_regression_matrices' plot(x, ...)
x |
A list of matrices obtained from regression_slope_analyze function |
... |
Further arguments are ignored |
No return value, called for side effects. The plots show regression slope values corresponding to proportion of individuals in the sample.
data(elk_network_2010) elk_regression_analysis <- regression_slope_analyze(elk_network_2010) plot(elk_regression_analysis)
data(elk_network_2010) elk_regression_analysis <- regression_slope_analyze(elk_network_2010) plot(elk_regression_analysis)
To plot sub-sampling results
## S3 method for class 'Subsampled_Network_Metrics' plot( x, network, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), ... )
## S3 method for class 'Subsampled_Network_Metrics' plot( x, network, network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), ... )
x |
A list of matrices belonging to class "Subsampled_Network_Metrics" and is obtained from subsampled_network_metrics function |
network |
An igraph graph object consisting of the observed network |
network_metrics_functions_list |
This is the same argument that is passed for obtaining the results from the function subsampled_network_metrics. A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
... |
Further arguments are ignored |
No return value, called for side effects. The boxplots depict range of values, network metrics take when multiple subsamples are chosen from the observed sample.
data(elk_network_2010) elk_subsamples <- subsampled_network_metrics(elk_network_2010) plot(elk_subsamples, elk_network_2010, network_metrics_functions_list = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)))
data(elk_network_2010) elk_subsamples <- subsampled_network_metrics(elk_network_2010) plot(elk_subsamples, elk_network_2010, network_metrics_functions_list = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)))
To plot sub-sampling results of the original network and permuted networks
## S3 method for class 'Subsampled_Permuted_Network_Metrics' plot( x, network, n_simulations = 100, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), ... )
## S3 method for class 'Subsampled_Permuted_Network_Metrics' plot( x, network, n_simulations = 100, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)), ... )
x |
A list of matrices obtained from subsampled_permuted_network_metrics function of class "Subsampled_Permuted_Network_Metrics" |
network |
An igraph graph object consisting of observed network |
n_simulations |
For subsampling results of original network, this determines the number of sub-samples to be obtained at each level |
subsampling_proportion |
A vector depicting the levels (in proportion) at which subsamples to be taken. This parameter should be the same as the subsampling_proportion parameter passed for the function subsampled_permuted_network_metrics to obtain x. |
network_metrics_functions_list |
This is the same argument that is passed for obtaining the results from the function subsampled_permuted_network_metrics. A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
... |
Further arguments are ignored |
No return value, called for side effects. The boxplots show side-by-side comparison of network metrics distribution from subsamples of observed network and subsamples from permuted networks.
data(elk_2010_permutations, elk_network_2010) elk_subsamples_permuted_networks <- subsampled_permuted_network_metrics(elk_2010_permutations) plot(elk_subsamples_permuted_networks, elk_network_2010)
data(elk_2010_permutations, elk_network_2010) elk_subsamples_permuted_networks <- subsampled_permuted_network_metrics(elk_2010_permutations) plot(elk_subsamples_permuted_networks, elk_network_2010)
To plot the results obtained from width_CI function
## S3 method for class 'Width_CI_matrix' plot(x, ...)
## S3 method for class 'Width_CI_matrix' plot(x, ...)
x |
A matrix of width of Confidence Intervals obtained from global_width_CI function |
... |
Further arguments are ignored. |
No return value, called for side effects. Plots show width of confidence intervals corresponding to number of individuals in the sub-sample.
data(elk_network_2010) width_CI_elk <- global_width_CI(elk_network_2010, n_versions = 100) plot(width_CI_elk)
data(elk_network_2010) width_CI_elk <- global_width_CI(elk_network_2010, n_versions = 100) plot(width_CI_elk)
To perform regression analysis for local network metrics
regression_slope_analyze( network, n_simulations = 10, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(degree = function(net, sub_net) igraph::degree(net, v = igraph::V(sub_net)$name), strength = function(net, sub_net) igraph::strength(net, v = igraph::V(sub_net)$name), betweenness = function(net, sub_net) igraph::betweenness(net, v = igraph::V(sub_net)$name), clustering_coefficient = function(net, sub_net) igraph::transitivity(net, type = "local", vids = igraph::V(sub_net)$name), eigenvector_centrality = function(net, sub_net) igraph::eigen_centrality(net)$vector[igraph::V(sub_net)$name]) )
regression_slope_analyze( network, n_simulations = 10, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(degree = function(net, sub_net) igraph::degree(net, v = igraph::V(sub_net)$name), strength = function(net, sub_net) igraph::strength(net, v = igraph::V(sub_net)$name), betweenness = function(net, sub_net) igraph::betweenness(net, v = igraph::V(sub_net)$name), clustering_coefficient = function(net, sub_net) igraph::transitivity(net, type = "local", vids = igraph::V(sub_net)$name), eigenvector_centrality = function(net, sub_net) igraph::eigen_centrality(net)$vector[igraph::V(sub_net)$name]) )
network |
An igraph graph object consisting of observed network |
n_simulations |
Number of sub-samples to be obtained at each level |
subsampling_proportion |
A vector depicting proportions of sub-sampled nodes |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Each function definition should include two parameters, one for the main network and another one for the subnetwork. See default example. Default = c("degree" = function(net, sub_net) igraph::degree(net, v = igraph::V(sub_net)$name), "strength" = function(net, sub_net) igraph::strength(net, v = igraph::V(sub_net)$name), "betweenness" = function(net, sub_net) igraph::betweenness(net, v = igraph::V(sub_net)$name), "clustering_coefficient" = function(net, sub_net) igraph::transitivity(net, type = "local", vids = igraph::V(sub_net)$name), "eigenvector_centrality" = function(net, sub_net) igraph::eigen_centrality(net)$vector[igraph::V(sub_net)$name]) |
A list of network metrics of class list_regression_matrices. Each element of list is a matrix whose columns correspond to subsampling_proportion and rows correspond to n_simulations. The entries of the matrix provide value of the slope of regression when the nodal values in sub-sampled network are regressed upon the values of the same nodes in the full network for the corresponding metric.
data(elk_network_2010) elk_regression_analysis <- regression_slope_analyze(elk_network_2010) plot(elk_regression_analysis)
data(elk_network_2010) elk_regression_analysis <- regression_slope_analyze(elk_network_2010) plot(elk_regression_analysis)
To generate subsamples and obtain network metrics of the subsamples
subsampled_network_metrics( network, n_simulations = 100, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)) )
subsampled_network_metrics( network, n_simulations = 100, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)) )
network |
An igraph graph object consisting of observed network |
n_simulations |
Number of sub-samples to be obtained at each level |
subsampling_proportion |
A vector depicting the levels (in proportion) at which subsamples to be taken |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
A list of network metrics of class "Subsampled_Network_Metrics". Each element of list is a matrix whose columns correspond to subsampling_proportion and rows correspond to n_simulations. The entries of the matrix provide values of the corresponding metric.
data(elk_network_2010) elk_subsamples <- subsampled_network_metrics(elk_network_2010) plot(elk_subsamples, elk_network_2010, network_metrics_functions_list = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)))
data(elk_network_2010) elk_subsamples <- subsampled_network_metrics(elk_network_2010) plot(elk_subsamples, elk_network_2010, network_metrics_functions_list = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)))
To generate subsamples of the permuted networks and obtain network metrics of those subsamples
subsampled_permuted_network_metrics( networks_list, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)) )
subsampled_permuted_network_metrics( networks_list, subsampling_proportion = c(0.1, 0.3, 0.5, 0.7, 0.9), network_metrics_functions_list = c(edge_density = function(x) igraph::edge_density(x), diameter = function(x) igraph::diameter(x, weights = NA), transitivity = function(x) igraph::transitivity(x)) )
networks_list |
A list of igraph objects obtained by permuting the observed network |
subsampling_proportion |
A vector depicting the levels (in proportion) at which subsamples to be taken |
network_metrics_functions_list |
A list consisting of function definitions of the network metrics that the user wants to evaluate. Each element in the list should have an assigned name. Default = c("edge_density" = function(x) igraph::edge_density(x), "diameter" = function(x) igraph::diameter(x, weights = NA), "transitivity" = function(x) igraph::transitivity(x)) |
A list of network metrics of class "Subsampled_Permuted_Network_Metrics". Each element of list is a matrix whose columns correspond to subsampling_proportion and rows correspond to the number of networks in networks_list. The entries of the matrix provide values of the corresponding metric.
data(elk_2010_permutations) elk_subsamples_permuted_networks <- subsampled_permuted_network_metrics(elk_2010_permutations) plot(elk_subsamples_permuted_networks, elk_network_2010)
data(elk_2010_permutations) elk_subsamples_permuted_networks <- subsampled_permuted_network_metrics(elk_2010_permutations) plot(elk_subsamples_permuted_networks, elk_network_2010)