stat_mat: Descriptive statistics on flow matrix

View source: R/stat_mat.R

stat_matR Documentation

Descriptive statistics on flow matrix

Description

This function provides various indicators and graphical outputs on a flow matrix.

Usage

stat_mat(mat, output = "all", verbose = TRUE)

Arguments

mat

A square matrix of flows.

output

Graphical output. Choices are "all" for all graphics, "none" to avoid any graphical output, "degree" for degree distribution, "wdegree" for weighted degree distribution, "lorenz" for Lorenz curve of link weights and "boxplot" for boxplot of link weights (see 'Details').

verbose

A boolean, if TRUE, returns statistics in the console.

Details

Graphical ouputs concern outdegrees by default. If the matrix is transposed, outputs concern indegrees.

Value

The function returns a list of statistics and may plot graphics.

  • nblinks: number of cells with values > 0

  • density: number of links divided by number of possible links (also called gamma index by geographers), loops excluded

  • connectcomp: number of connected components (isolates included, weakly connected: use of clusters where mode = "weak")

  • connectcompx: number of connected components (isolates deleted, weakly connected: use of clusters where mode = "weak")

  • sizecomp: a data.frame of connected components: size and sum of flows per component (isolates included)

  • compocomp: a data.frame of connected components giving membership of units (isolates included)

  • degrees: a data.frame of nodes degrees and weighted degrees

  • sumflows: sum of flows

  • min: minimum flow

  • Q1: first quartile of flows

  • median: median flow

  • Q3: third quartile of flows

  • max: maximum flow

  • mean: mean flow

  • sd: standart deviation of flows

Examples

# Import data
nav <- read.csv(system.file("csv/nav.csv", package = "flows"))
myflows <- prepare_mat(x = nav, i = "i", j = "j", fij = "fij")

# Get statistics and graphs about the matrix
mystats <- stat_mat(mat = myflows, output = "all", verbose = TRUE)

# Size of connected components
mystats$sizecomp

# Sum of flows
mystats$sumflows

# Plot Lorenz curve only
stat_mat(mat = myflows, output = "lorenz", verbose = FALSE)

# Statistics only
mystats <- stat_mat(mat = myflows, output = "none", verbose = FALSE)
str(mystats)

rCarto/flows documentation built on May 10, 2024, 11:38 a.m.