dna.density: Compute density for matrices

Description Usage Arguments Details Author(s) See Also Examples

View source: R/rDNA.R

Description

Compute the within- and between-block density for weighted or binary network matrices.

Usage

1
2
dna.density(network.matrix, partitions = "", weighted = FALSE, 
    verbose = FALSE)

Arguments

network.matrix

A co-occurrence or adjacency network which is saved as a matrix object. It should have the correct row and column labels assigned, otherwise partitions will not work.

partitions

An optional argument where the affiliation of row and column vertices to groups can be specified. The vertex types or groups of the row labels in the network.matrix can be submitted as a one-column matrix or data.frame with meaningful row names. The row and column names of the network.matrix are looked up in the partitions if specified. Alternatively, partitions can be given as a vector (see example). If the partitions do not have row names, the row names of the network matrix will be assumed. The output will be a group x group density table for the different partitions.

weighted

A boolean variable indicating whether the weight of an edge should be counted when the density is calculated.

verbose

A boolean variable indicating whether the results shall also be printed to the screen.

Details

This method computes the density of network matrices. It works for weighted or binary networks, and it can return within- and between-block density if actor types or the affiliation of actors to theoretical groups is given. For example, in a network of political actors, each actor may have a certain actor type: interest group, governmental actor, party etc. If the type of each row and column actor can be looked up in the one-column matrix given by the optional partitions argument, the result of the dna.density method will be a type x type matrix containing the densities within each actor type and between the various actor types. Within- and between block density for theoretical blocks is elsewhere referred to as node-mixing.

Author(s)

Philip Leifeld (http://www.philipleifeld.com)

See Also

dna.attributes dna.network

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# download files and initialize DNA:
download.file("http://www.philipleifeld.de/cms/upload/Downloads/dna-1.31.jar",
    destfile = "dna-1.31.jar", mode = "wb")
download.file("http://www.philipleifeld.de/cms/upload/Downloads/sample.dna", 
    destfile = "sample.dna", mode = "wb")
dna.init("dna-1.31.jar")

# create network matrix
nw <- dna.network("sample.dna")

# compute (binary) density (without partitions)
dna.density(nw)

# create vector with groups (assuming they correspond to rows in the matrix)
groups <- c("Con", "Con", "Con", "Pro", "Pro", "Pro", "Con")

# compute (weighted) density by partition
dna.density(nw, partitions = groups, weighted = TRUE)

rDNA documentation built on May 30, 2017, 12:15 a.m.